From patchwork Fri Dec 23 18:11:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Bityutskiy X-Patchwork-Id: 133133 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 0C715B70DC for ; Sat, 24 Dec 2011 05:17:17 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Re9eu-0008Ty-M2; Fri, 23 Dec 2011 18:15:57 +0000 Received: from mga03.intel.com ([143.182.124.21]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Re9aI-0005S9-3a for linux-mtd@lists.infradead.org; Fri, 23 Dec 2011 18:11:13 +0000 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 23 Dec 2011 10:11:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.71,315,1320652800"; d="scan'208";a="88999437" Received: from sauron.fi.intel.com ([10.237.72.160]) by azsmga001.ch.intel.com with ESMTP; 23 Dec 2011 10:11:07 -0800 From: Artem Bityutskiy To: linux-mtd@lists.infradead.org Subject: [PATCH 28/28] mtd: introduce mtd_put_device interface Date: Fri, 23 Dec 2011 20:11:20 +0200 Message-Id: <1324663880-22477-29-git-send-email-dedekind1@gmail.com> X-Mailer: git-send-email 1.7.7.4 In-Reply-To: <1324663880-22477-1-git-send-email-dedekind1@gmail.com> References: <1324663880-22477-1-git-send-email-dedekind1@gmail.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.4 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [143.182.124.21 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.1 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 Cc: Artem Bityutskiy , Mike Dunn 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 Signed-off-by: Artem Bityutskiy --- drivers/mtd/mtdcore.c | 2 +- fs/logfs/super.c | 6 +++--- include/linux/mtd/mtd.h | 18 ++++++++++++------ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index fbecbe8..8395b61 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -677,7 +677,7 @@ void __put_mtd_device(struct mtd_info *mtd) BUG_ON(mtd->usecount < 0); if (mtd->put_device) - mtd->put_device(mtd); + mtd_put_device(mtd); module_put(mtd->owner); } diff --git a/fs/logfs/super.c b/fs/logfs/super.c index e795c234..2234d29 100644 --- a/fs/logfs/super.c +++ b/fs/logfs/super.c @@ -503,7 +503,7 @@ static void logfs_kill_sb(struct super_block *sb) logfs_cleanup_rw(sb); if (super->s_erase_page) __free_page(super->s_erase_page); - super->s_devops->put_device(super); + mtd_put_device(super); logfs_mempool_destroy(super->s_btree_pool); logfs_mempool_destroy(super->s_alias_pool); kfree(super); @@ -522,14 +522,14 @@ static struct dentry *logfs_get_sb_device(struct logfs_super *super, err = -EINVAL; sb = sget(type, logfs_sb_test, logfs_sb_set, super); if (IS_ERR(sb)) { - super->s_devops->put_device(super); + mtd_put_device(super); kfree(super); return ERR_CAST(sb); } if (sb->s_root) { /* Device is already in use */ - super->s_devops->put_device(super); + mtd_put_device(super); kfree(super); return dget(sb->s_root); } diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 0e696b7..e8c4409 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -215,6 +215,7 @@ struct mtd_info { int (*suspend) (struct mtd_info *mtd); void (*resume) (struct mtd_info *mtd); int (*get_device) (struct mtd_info *mtd); + void (*put_device) (struct mtd_info *mtd); /* Backing device capabilities for this device * - provides mmap capabilities @@ -233,12 +234,6 @@ struct mtd_info { struct module *owner; struct device dev; int usecount; - - /* If the driver is something smart, like UBI, it may need to maintain - * its own reference counting. The below functions are only for driver. - * The driver may register its callbacks. These callbacks are not - * supposed to be called by MTD users */ - void (*put_device) (struct mtd_info *mtd); }; /* @@ -414,11 +409,22 @@ static inline int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs) return mtd->block_markbad(mtd, ofs); } +/* + * If the driver is something smart, like UBI, it may need to maintain its own + * reference counting. The below functions are only for driver. The driver may + * register its callbacks. These callbacks are not supposed to be called by MTD + * users. + */ static inline int mtd_get_device(struct mtd_info *mtd) { return mtd->get_device(mtd); } +static inline void mtd_put_device(struct mtd_info *mtd) +{ + return mtd->put_device(mtd); +} + static inline struct mtd_info *dev_to_mtd(struct device *dev) { return dev ? dev_get_drvdata(dev) : NULL;