Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Artem Bityutskiy and committed by
David Woodhouse
327cf292 1dbebd32

+11 -21
+1 -2
drivers/mtd/ftl.c
··· 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)
+2 -5
drivers/mtd/mtdblock.c
··· 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 ··· 340 341 mutex_lock(&mtdblk->cache_mutex); 341 342 write_cached_data(mtdblk); 342 343 mutex_unlock(&mtdblk->cache_mutex); 343 - 344 - if (dev->mtd->sync) 345 - mtd_sync(dev->mtd); 344 + mtd_sync(dev->mtd); 346 345 return 0; 347 346 } 348 347
+1 -1
drivers/mtd/mtdchar.c
··· 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);
+1 -2
drivers/mtd/mtdswap.c
··· 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
+1 -2
drivers/mtd/rfd_ftl.c
··· 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;
+1 -3
drivers/mtd/ubi/kapi.c
··· 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 }
+1 -3
fs/jffs2/super.c
··· 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
+1 -2
fs/logfs/dev_mtd.c
··· 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)
+2 -1
include/linux/mtd/mtd.h
··· 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 */