From patchwork Thu Feb 26 23:18:16 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Brownell X-Patchwork-Id: 24143 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 51A66DDF8E for ; Fri, 6 Mar 2009 17:38:08 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1LfTfm-0004jY-Rj; Fri, 06 Mar 2009 06:36:42 +0000 Received: from smtp124.sbc.mail.sp1.yahoo.com ([69.147.64.97]) by bombadil.infradead.org with smtp (Exim 4.69 #1 (Red Hat Linux)) id 1LcpUg-0004mK-NW for linux-mtd@lists.infradead.org; Thu, 26 Feb 2009 23:18:21 +0000 Received: (qmail 36967 invoked from network); 26 Feb 2009 23:18:17 -0000 Received: from unknown (HELO pogo) (david-b@69.226.224.20 with plain) by smtp124.sbc.mail.sp1.yahoo.com with SMTP; 26 Feb 2009 23:18:17 -0000 X-YMail-OSG: T8dHRCwVM1mn97S0VcwqXv6Y.Qi0GPpQ7n0QKCiqXL5OSmkPGQRPE.yTJ0VphAzVx0LgUN1dqkOebX.HvqclR3TZXKlzDVauVUJI_hJWUXca4So2f8fqIY_bB9uTSN41VWA1R6bxZXSkiuwIKLUKM2sQQ4UMmpoWsR6ffFIZRCQmVyUSq2XNe_x5mqHiEF1G_qMz_9G2DhvcI62OpXpFq3Z2Kp9wyWtqjwk24Q-- X-Yahoo-Newman-Property: ymail-3 From: David Brownell To: Andrew Morton , linux-mtd@lists.infradead.org Subject: [patch 2.6.29-rc6-mmotm] MTD: partitioning utility predicates Date: Thu, 26 Feb 2009 15:18:16 -0800 User-Agent: KMail/1.9.10 References: <200902241509.54649.david-b@pacbell.net> <20090226123341.a2421733.akpm@linux-foundation.org> In-Reply-To: <20090226123341.a2421733.akpm@linux-foundation.org> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200902261518.16378.david-b@pacbell.net> X-Bad-Reply: References and In-Reply-To but no 'Re:' in Subject. X-Spam-Score: 0.4 (/) X-Spam-Report: SpamAssassin version 3.2.5 on bombadil.infradead.org summary: Content analysis details: (0.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.4 SUBJECT_FUZZY_TION Attempt to obfuscate words in Subject: X-Mailman-Approved-At: Fri, 06 Mar 2009 01:34:11 -0500 Cc: linux-kernel@vger.kernel.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: David Brownell Move mtd_has_partitions() and mtd_has_cmdlinepart() inlines from a DaVinci-specific driver to the header. Use those to eliminate #ifdefs in two drivers which had their own definitions of mtd_has_partitions(). Signed-off-by: David Brownell --- Quite a lot of other MTD drivers could benefit from using use one or both of these to remove #ifdeffery. Maybe some Janitors would like to help? drivers/mtd/devices/m25p80.c | 17 ++++++----------- drivers/mtd/devices/mtd_dataflash.c | 16 ++++++---------- drivers/mtd/nand/davinci_nand.c | 13 ------------- include/linux/mtd/partitions.h | 12 ++++++++++++ 4 files changed, 24 insertions(+), 34 deletions(-) --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -65,12 +65,6 @@ #define FAST_READ_DUMMY_BYTE 0 #endif -#ifdef CONFIG_MTD_PARTITIONS -#define mtd_has_partitions() (1) -#else -#define mtd_has_partitions() (0) -#endif - /****************************************************************************/ struct m25p { @@ -708,12 +702,13 @@ static int __devinit m25p_probe(struct s struct mtd_partition *parts = NULL; int nr_parts = 0; -#ifdef CONFIG_MTD_CMDLINE_PARTS - static const char *part_probes[] = { "cmdlinepart", NULL, }; + if (mtd_has_cmdlinepart()) { + static const char *part_probes[] + = { "cmdlinepart", NULL, }; - nr_parts = parse_mtd_partitions(&flash->mtd, - part_probes, &parts, 0); -#endif + nr_parts = parse_mtd_partitions(&flash->mtd, + part_probes, &parts, 0); + } if (nr_parts <= 0 && data && data->parts) { parts = data->parts; --- a/drivers/mtd/devices/mtd_dataflash.c +++ b/drivers/mtd/devices/mtd_dataflash.c @@ -98,12 +98,6 @@ struct dataflash { struct mtd_info mtd; }; -#ifdef CONFIG_MTD_PARTITIONS -#define mtd_has_partitions() (1) -#else -#define mtd_has_partitions() (0) -#endif - /* ......................................................................... */ /* @@ -682,11 +676,13 @@ add_dataflash_otp(struct spi_device *spi struct mtd_partition *parts; int nr_parts = 0; -#ifdef CONFIG_MTD_CMDLINE_PARTS - static const char *part_probes[] = { "cmdlinepart", NULL, }; + if (mtd_has_cmdlinepart()) { + static const char *part_probes[] + = { "cmdlinepart", NULL, }; - nr_parts = parse_mtd_partitions(device, part_probes, &parts, 0); -#endif + nr_parts = parse_mtd_partitions(device, + part_probes, &parts, 0); + } if (nr_parts <= 0 && pdata && pdata->parts) { parts = pdata->parts; --- a/drivers/mtd/nand/davinci_nand.c +++ b/drivers/mtd/nand/davinci_nand.c @@ -39,19 +39,6 @@ #include -#ifdef CONFIG_MTD_PARTITIONS -static inline int mtd_has_partitions(void) { return 1; } -#else -static inline int mtd_has_partitions(void) { return 0; } -#endif - -#ifdef CONFIG_MTD_CMDLINE_PARTS -static inline int mtd_has_cmdlinepart(void) { return 1; } -#else -static inline int mtd_has_cmdlinepart(void) { return 0; } -#endif - - /* * This is a device driver for the NAND flash controller found on the * various DaVinci family chips. It handles up to four SoC chipselects, --- a/include/linux/mtd/partitions.h +++ b/include/linux/mtd/partitions.h @@ -76,4 +76,16 @@ int __devinit of_mtd_parse_partitions(st struct device_node *node, struct mtd_partition **pparts); +#ifdef CONFIG_MTD_PARTITIONS +static inline int mtd_has_partitions(void) { return 1; } +#else +static inline int mtd_has_partitions(void) { return 0; } +#endif + +#ifdef CONFIG_MTD_CMDLINE_PARTS +static inline int mtd_has_cmdlinepart(void) { return 1; } +#else +static inline int mtd_has_cmdlinepart(void) { return 0; } +#endif + #endif