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>
This commit is contained in:
parent
1dbebd3256
commit
327cf2922b
9 changed files with 11 additions and 21 deletions
|
@ -650,7 +650,6 @@ static int reclaim_block(partition_t *part)
|
|||
if (queued) {
|
||||
pr_debug("ftl_cs: waiting for transfer "
|
||||
"unit to be prepared...\n");
|
||||
if (part->mbd.mtd->sync)
|
||||
mtd_sync(part->mbd.mtd);
|
||||
} else {
|
||||
static int ne = 0;
|
||||
|
|
|
@ -322,7 +322,6 @@ static int mtdblock_release(struct mtd_blktrans_dev *mbd)
|
|||
|
||||
if (!--mtdblk->count) {
|
||||
/* It was the last usage. Free the cache */
|
||||
if (mbd->mtd->sync)
|
||||
mtd_sync(mbd->mtd);
|
||||
vfree(mtdblk->cache_data);
|
||||
}
|
||||
|
@ -341,8 +340,6 @@ static int mtdblock_flush(struct mtd_blktrans_dev *dev)
|
|||
mutex_lock(&mtdblk->cache_mutex);
|
||||
write_cached_data(mtdblk);
|
||||
mutex_unlock(&mtdblk->cache_mutex);
|
||||
|
||||
if (dev->mtd->sync)
|
||||
mtd_sync(dev->mtd);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ static int mtdchar_close(struct inode *inode, struct file *file)
|
|||
pr_debug("MTD_close\n");
|
||||
|
||||
/* Only sync if opened RW */
|
||||
if ((file->f_mode & FMODE_WRITE) && mtd->sync)
|
||||
if ((file->f_mode & FMODE_WRITE))
|
||||
mtd_sync(mtd);
|
||||
|
||||
iput(mfi->ino);
|
||||
|
|
|
@ -1047,7 +1047,6 @@ static int mtdswap_flush(struct mtd_blktrans_dev *dev)
|
|||
{
|
||||
struct mtdswap_dev *d = MTDSWAP_MBD_TO_MTDSWAP(dev);
|
||||
|
||||
if (d->mtd->sync)
|
||||
mtd_sync(d->mtd);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -448,7 +448,6 @@ static int reclaim_block(struct partition *part, u_long *old_sector)
|
|||
int rc;
|
||||
|
||||
/* we have a race if sync doesn't exist */
|
||||
if (part->mbd.mtd->sync)
|
||||
mtd_sync(part->mbd.mtd);
|
||||
|
||||
score = 0x7fffffff; /* MAX_INT */
|
||||
|
|
|
@ -714,9 +714,7 @@ int ubi_sync(int ubi_num)
|
|||
if (!ubi)
|
||||
return -ENODEV;
|
||||
|
||||
if (ubi->mtd->sync)
|
||||
mtd_sync(ubi->mtd);
|
||||
|
||||
ubi_put_device(ubi);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -336,9 +336,7 @@ static void jffs2_put_super (struct super_block *sb)
|
|||
jffs2_flash_cleanup(c);
|
||||
kfree(c->inocache_list);
|
||||
jffs2_clear_xattr_subsystem(c);
|
||||
if (c->mtd->sync)
|
||||
mtd_sync(c->mtd);
|
||||
|
||||
D1(printk(KERN_DEBUG "jffs2_put_super returning\n"));
|
||||
}
|
||||
|
||||
|
|
|
@ -119,7 +119,6 @@ static void logfs_mtd_sync(struct super_block *sb)
|
|||
{
|
||||
struct mtd_info *mtd = logfs_super(sb)->s_mtd;
|
||||
|
||||
if (mtd->sync)
|
||||
mtd_sync(mtd);
|
||||
}
|
||||
|
||||
|
|
|
@ -399,6 +399,7 @@ int mtd_writev(struct mtd_info *mtd, const struct kvec *vecs,
|
|||
|
||||
static inline void mtd_sync(struct mtd_info *mtd)
|
||||
{
|
||||
if (mtd->sync)
|
||||
mtd->sync(mtd);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue