From patchwork Mon Jan 2 12:20:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Bityutskiy X-Patchwork-Id: 133830 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B1A4EB6F68 for ; Mon, 2 Jan 2012 23:21:45 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Rhgsc-0004OR-3N; Mon, 02 Jan 2012 12:20:42 +0000 Received: from mga01.intel.com ([192.55.52.88]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Rhgqu-0003TG-2Z for linux-mtd@lists.infradead.org; Mon, 02 Jan 2012 12:18:58 +0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 02 Jan 2012 04:18:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.71,315,1320652800"; d="scan'208";a="102310022" Received: from sauron.fi.intel.com ([10.237.72.160]) by fmsmga001.fm.intel.com with ESMTP; 02 Jan 2012 04:18:54 -0800 From: Artem Bityutskiy To: linux-mtd@lists.infradead.org Subject: [PATCH 12/17] mtd: do not use mtd->sync directly Date: Mon, 2 Jan 2012 14:20:42 +0200 Message-Id: <1325506847-23470-13-git-send-email-dedekind1@gmail.com> X-Mailer: git-send-email 1.7.7.4 In-Reply-To: <1325506847-23470-1-git-send-email-dedekind1@gmail.com> References: <1325506847-23470-1-git-send-email-dedekind1@gmail.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-5.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [192.55.52.88 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (dedekind1[at]gmail.com) 0.0 DKIM_ADSP_CUSTOM_MED No valid author signature, adsp_override is CUSTOM_MED 0.8 SPF_NEUTRAL SPF: sender does not match SPF record (neutral) 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (dedekind1[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.9 NML_ADSP_CUSTOM_MED ADSP custom_med hit, and not from a mailing list X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Artem Bityutskiy 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 --- drivers/mtd/ftl.c | 3 +-- drivers/mtd/mtdblock.c | 7 ++----- drivers/mtd/mtdchar.c | 2 +- drivers/mtd/mtdswap.c | 3 +-- drivers/mtd/rfd_ftl.c | 3 +-- drivers/mtd/ubi/kapi.c | 4 +--- fs/jffs2/super.c | 4 +--- fs/logfs/dev_mtd.c | 3 +-- include/linux/mtd/mtd.h | 3 ++- 9 files changed, 11 insertions(+), 21 deletions(-) diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c index c9c9029..19d6372 100644 --- a/drivers/mtd/ftl.c +++ b/drivers/mtd/ftl.c @@ -650,8 +650,7 @@ 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); + mtd_sync(part->mbd.mtd); } else { static int ne = 0; if (++ne < 5) diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c index 496e1a6..af65912 100644 --- a/drivers/mtd/mtdblock.c +++ b/drivers/mtd/mtdblock.c @@ -322,8 +322,7 @@ 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); + mtd_sync(mbd->mtd); vfree(mtdblk->cache_data); } @@ -341,9 +340,7 @@ 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); + mtd_sync(dev->mtd); return 0; } diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index 2020a16..23a5110 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c @@ -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); diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c index 4441c08..fe4426c 100644 --- a/drivers/mtd/mtdswap.c +++ b/drivers/mtd/mtdswap.c @@ -1047,8 +1047,7 @@ 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); + mtd_sync(d->mtd); return 0; } diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c index 5426d42..233b946 100644 --- a/drivers/mtd/rfd_ftl.c +++ b/drivers/mtd/rfd_ftl.c @@ -448,8 +448,7 @@ 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); + mtd_sync(part->mbd.mtd); score = 0x7fffffff; /* MAX_INT */ best_block = -1; diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c index 9f265cc..9fdb353 100644 --- a/drivers/mtd/ubi/kapi.c +++ b/drivers/mtd/ubi/kapi.c @@ -714,9 +714,7 @@ int ubi_sync(int ubi_num) if (!ubi) return -ENODEV; - if (ubi->mtd->sync) - mtd_sync(ubi->mtd); - + mtd_sync(ubi->mtd); ubi_put_device(ubi); return 0; } diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c index e78bf3c..5863a36 100644 --- a/fs/jffs2/super.c +++ b/fs/jffs2/super.c @@ -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); - + mtd_sync(c->mtd); D1(printk(KERN_DEBUG "jffs2_put_super returning\n")); } diff --git a/fs/logfs/dev_mtd.c b/fs/logfs/dev_mtd.c index 136c736..3f465882 100644 --- a/fs/logfs/dev_mtd.c +++ b/fs/logfs/dev_mtd.c @@ -119,8 +119,7 @@ static void logfs_mtd_sync(struct super_block *sb) { 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) diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index a58ecf4..305f12b 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -399,7 +399,8 @@ int mtd_writev(struct mtd_info *mtd, const struct kvec *vecs, static inline void mtd_sync(struct mtd_info *mtd) { - mtd->sync(mtd); + if (mtd->sync) + mtd->sync(mtd); } /* Chip-supported device locking */