Commit 327cf292 authored by Artem Bityutskiy's avatar Artem Bityutskiy Committed by David Woodhouse

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: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 1dbebd32
...@@ -650,8 +650,7 @@ static int reclaim_block(partition_t *part) ...@@ -650,8 +650,7 @@ static int reclaim_block(partition_t *part)
if (queued) { if (queued) {
pr_debug("ftl_cs: waiting for transfer " pr_debug("ftl_cs: waiting for transfer "
"unit to be prepared...\n"); "unit to be prepared...\n");
if (part->mbd.mtd->sync) mtd_sync(part->mbd.mtd);
mtd_sync(part->mbd.mtd);
} else { } else {
static int ne = 0; static int ne = 0;
if (++ne < 5) if (++ne < 5)
......
...@@ -322,8 +322,7 @@ static int mtdblock_release(struct mtd_blktrans_dev *mbd) ...@@ -322,8 +322,7 @@ static int mtdblock_release(struct mtd_blktrans_dev *mbd)
if (!--mtdblk->count) { if (!--mtdblk->count) {
/* It was the last usage. Free the cache */ /* It was the last usage. Free the cache */
if (mbd->mtd->sync) mtd_sync(mbd->mtd);
mtd_sync(mbd->mtd);
vfree(mtdblk->cache_data); vfree(mtdblk->cache_data);
} }
...@@ -341,9 +340,7 @@ static int mtdblock_flush(struct mtd_blktrans_dev *dev) ...@@ -341,9 +340,7 @@ static int mtdblock_flush(struct mtd_blktrans_dev *dev)
mutex_lock(&mtdblk->cache_mutex); mutex_lock(&mtdblk->cache_mutex);
write_cached_data(mtdblk); write_cached_data(mtdblk);
mutex_unlock(&mtdblk->cache_mutex); mutex_unlock(&mtdblk->cache_mutex);
mtd_sync(dev->mtd);
if (dev->mtd->sync)
mtd_sync(dev->mtd);
return 0; return 0;
} }
......
...@@ -154,7 +154,7 @@ static int mtdchar_close(struct inode *inode, struct file *file) ...@@ -154,7 +154,7 @@ static int mtdchar_close(struct inode *inode, struct file *file)
pr_debug("MTD_close\n"); pr_debug("MTD_close\n");
/* Only sync if opened RW */ /* Only sync if opened RW */
if ((file->f_mode & FMODE_WRITE) && mtd->sync) if ((file->f_mode & FMODE_WRITE))
mtd_sync(mtd); mtd_sync(mtd);
iput(mfi->ino); iput(mfi->ino);
......
...@@ -1047,8 +1047,7 @@ static int mtdswap_flush(struct mtd_blktrans_dev *dev) ...@@ -1047,8 +1047,7 @@ static int mtdswap_flush(struct mtd_blktrans_dev *dev)
{ {
struct mtdswap_dev *d = MTDSWAP_MBD_TO_MTDSWAP(dev); struct mtdswap_dev *d = MTDSWAP_MBD_TO_MTDSWAP(dev);
if (d->mtd->sync) mtd_sync(d->mtd);
mtd_sync(d->mtd);
return 0; return 0;
} }
......
...@@ -448,8 +448,7 @@ static int reclaim_block(struct partition *part, u_long *old_sector) ...@@ -448,8 +448,7 @@ static int reclaim_block(struct partition *part, u_long *old_sector)
int rc; int rc;
/* we have a race if sync doesn't exist */ /* we have a race if sync doesn't exist */
if (part->mbd.mtd->sync) mtd_sync(part->mbd.mtd);
mtd_sync(part->mbd.mtd);
score = 0x7fffffff; /* MAX_INT */ score = 0x7fffffff; /* MAX_INT */
best_block = -1; best_block = -1;
......
...@@ -714,9 +714,7 @@ int ubi_sync(int ubi_num) ...@@ -714,9 +714,7 @@ int ubi_sync(int ubi_num)
if (!ubi) if (!ubi)
return -ENODEV; return -ENODEV;
if (ubi->mtd->sync) mtd_sync(ubi->mtd);
mtd_sync(ubi->mtd);
ubi_put_device(ubi); ubi_put_device(ubi);
return 0; return 0;
} }
......
...@@ -336,9 +336,7 @@ static void jffs2_put_super (struct super_block *sb) ...@@ -336,9 +336,7 @@ static void jffs2_put_super (struct super_block *sb)
jffs2_flash_cleanup(c); jffs2_flash_cleanup(c);
kfree(c->inocache_list); kfree(c->inocache_list);
jffs2_clear_xattr_subsystem(c); jffs2_clear_xattr_subsystem(c);
if (c->mtd->sync) mtd_sync(c->mtd);
mtd_sync(c->mtd);
D1(printk(KERN_DEBUG "jffs2_put_super returning\n")); D1(printk(KERN_DEBUG "jffs2_put_super returning\n"));
} }
......
...@@ -119,8 +119,7 @@ static void logfs_mtd_sync(struct super_block *sb) ...@@ -119,8 +119,7 @@ static void logfs_mtd_sync(struct super_block *sb)
{ {
struct mtd_info *mtd = logfs_super(sb)->s_mtd; struct mtd_info *mtd = logfs_super(sb)->s_mtd;
if (mtd->sync) mtd_sync(mtd);
mtd_sync(mtd);
} }
static int logfs_mtd_readpage(void *_sb, struct page *page) static int logfs_mtd_readpage(void *_sb, struct page *page)
......
...@@ -399,7 +399,8 @@ int mtd_writev(struct mtd_info *mtd, const struct kvec *vecs, ...@@ -399,7 +399,8 @@ int mtd_writev(struct mtd_info *mtd, const struct kvec *vecs,
static inline void mtd_sync(struct mtd_info *mtd) static inline void mtd_sync(struct mtd_info *mtd)
{ {
mtd->sync(mtd); if (mtd->sync)
mtd->sync(mtd);
} }
/* Chip-supported device locking */ /* Chip-supported device locking */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment