Browse Source

[MTD] Only call mtd->sync() method in mtdchar close if opened for write.

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Joakim Tjernlund 18 years ago
parent
commit
7eafaed55f
1 changed files with 2 additions and 1 deletions
  1. 2 1
      drivers/mtd/mtdchar.c

+ 2 - 1
drivers/mtd/mtdchar.c

@@ -135,7 +135,8 @@ static int mtd_close(struct inode *inode, struct file *file)
 
 	DEBUG(MTD_DEBUG_LEVEL0, "MTD_close\n");
 
-	if (mtd->sync)
+	/* Only sync if opened RW */
+	if ((file->f_mode & 2) && mtd->sync)
 		mtd->sync(mtd);
 
 	put_mtd_device(mtd);