aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtdblock.c
diff options
context:
space:
mode:
authorAlexander Stein <alexander.stein@systec-electronic.com>2012-01-10 07:26:58 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2012-03-26 19:11:11 -0400
commit70d5098a4b1551864dd7df43f67b7f606a1a6438 (patch)
tree288f6f9cdb1866ea9648c6590448254c40af2c81 /drivers/mtd/mtdblock.c
parent2ff5e1532dd37e1bd8ac72da3f7f0e2b310102fb (diff)
mtd: mtdblock: call mtd_sync() only if opened for write
Because it is useless to call it if the device is opened in R/O mode, and also harmful: on CFI NOR flash it may block for long time waiting for erase operations to complete is another partition with a R/W file-system on this chip. Artem Bityutskiy: write commit message, amend the patch to match the latest tree (we use mtd_sync(), not mtd->sync() nowadays). Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/mtdblock.c')
-rw-r--r--drivers/mtd/mtdblock.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
index af6591237b9b..6c6d80736fad 100644
--- a/drivers/mtd/mtdblock.c
+++ b/drivers/mtd/mtdblock.c
@@ -321,8 +321,12 @@ static int mtdblock_release(struct mtd_blktrans_dev *mbd)
321 mutex_unlock(&mtdblk->cache_mutex); 321 mutex_unlock(&mtdblk->cache_mutex);
322 322
323 if (!--mtdblk->count) { 323 if (!--mtdblk->count) {
324 /* It was the last usage. Free the cache */ 324 /*
325 mtd_sync(mbd->mtd); 325 * It was the last usage. Free the cache, but only sync if
326 * opened for writing.
327 */
328 if (mbd->file_mode & FMODE_WRITE)
329 mtd_sync(mbd->mtd);
326 vfree(mtdblk->cache_data); 330 vfree(mtdblk->cache_data);
327 } 331 }
328 332