Commit 327cf2922b4edf0439b219469722d2a502e37349

Authored by Artem Bityutskiy
Committed by David Woodhouse
1 parent 1dbebd3256

mtd: do not use mtd->sync directly

This patch teaches 'mtd_sync()' to do nothing when the MTD driver does
not have the '->sync()' method, which allows us to remove all direct
'mtd->sync' accesses.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

Showing 9 changed files with 11 additions and 21 deletions Side-by-side Diff

... ... @@ -650,8 +650,7 @@
650 650 if (queued) {
651 651 pr_debug("ftl_cs: waiting for transfer "
652 652 "unit to be prepared...\n");
653   - if (part->mbd.mtd->sync)
654   - mtd_sync(part->mbd.mtd);
  653 + mtd_sync(part->mbd.mtd);
655 654 } else {
656 655 static int ne = 0;
657 656 if (++ne < 5)
drivers/mtd/mtdblock.c
... ... @@ -322,8 +322,7 @@
322 322  
323 323 if (!--mtdblk->count) {
324 324 /* It was the last usage. Free the cache */
325   - if (mbd->mtd->sync)
326   - mtd_sync(mbd->mtd);
  325 + mtd_sync(mbd->mtd);
327 326 vfree(mtdblk->cache_data);
328 327 }
329 328  
... ... @@ -341,9 +340,7 @@
341 340 mutex_lock(&mtdblk->cache_mutex);
342 341 write_cached_data(mtdblk);
343 342 mutex_unlock(&mtdblk->cache_mutex);
344   -
345   - if (dev->mtd->sync)
346   - mtd_sync(dev->mtd);
  343 + mtd_sync(dev->mtd);
347 344 return 0;
348 345 }
349 346  
drivers/mtd/mtdchar.c
... ... @@ -154,7 +154,7 @@
154 154 pr_debug("MTD_close\n");
155 155  
156 156 /* Only sync if opened RW */
157   - if ((file->f_mode & FMODE_WRITE) && mtd->sync)
  157 + if ((file->f_mode & FMODE_WRITE))
158 158 mtd_sync(mtd);
159 159  
160 160 iput(mfi->ino);
drivers/mtd/mtdswap.c
... ... @@ -1047,8 +1047,7 @@
1047 1047 {
1048 1048 struct mtdswap_dev *d = MTDSWAP_MBD_TO_MTDSWAP(dev);
1049 1049  
1050   - if (d->mtd->sync)
1051   - mtd_sync(d->mtd);
  1050 + mtd_sync(d->mtd);
1052 1051 return 0;
1053 1052 }
1054 1053  
drivers/mtd/rfd_ftl.c
... ... @@ -448,8 +448,7 @@
448 448 int rc;
449 449  
450 450 /* we have a race if sync doesn't exist */
451   - if (part->mbd.mtd->sync)
452   - mtd_sync(part->mbd.mtd);
  451 + mtd_sync(part->mbd.mtd);
453 452  
454 453 score = 0x7fffffff; /* MAX_INT */
455 454 best_block = -1;
drivers/mtd/ubi/kapi.c
... ... @@ -714,9 +714,7 @@
714 714 if (!ubi)
715 715 return -ENODEV;
716 716  
717   - if (ubi->mtd->sync)
718   - mtd_sync(ubi->mtd);
719   -
  717 + mtd_sync(ubi->mtd);
720 718 ubi_put_device(ubi);
721 719 return 0;
722 720 }
... ... @@ -336,9 +336,7 @@
336 336 jffs2_flash_cleanup(c);
337 337 kfree(c->inocache_list);
338 338 jffs2_clear_xattr_subsystem(c);
339   - if (c->mtd->sync)
340   - mtd_sync(c->mtd);
341   -
  339 + mtd_sync(c->mtd);
342 340 D1(printk(KERN_DEBUG "jffs2_put_super returning\n"));
343 341 }
344 342  
... ... @@ -119,8 +119,7 @@
119 119 {
120 120 struct mtd_info *mtd = logfs_super(sb)->s_mtd;
121 121  
122   - if (mtd->sync)
123   - mtd_sync(mtd);
  122 + mtd_sync(mtd);
124 123 }
125 124  
126 125 static int logfs_mtd_readpage(void *_sb, struct page *page)
include/linux/mtd/mtd.h
... ... @@ -399,7 +399,8 @@
399 399  
400 400 static inline void mtd_sync(struct mtd_info *mtd)
401 401 {
402   - mtd->sync(mtd);
  402 + if (mtd->sync)
  403 + mtd->sync(mtd);
403 404 }
404 405  
405 406 /* Chip-supported device locking */