From patchwork Sat Aug 31 17:04:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 271544 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from casper.infradead.org (unknown [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2999A2C00B3 for ; Sun, 1 Sep 2013 03:05:05 +1000 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VFobJ-0001tg-R6; Sat, 31 Aug 2013 17:04:42 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VFobH-0008Rm-KP; Sat, 31 Aug 2013 17:04:39 +0000 Received: from top.free-electrons.com ([176.31.233.9] helo=mail.free-electrons.com) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VFobE-0008Qh-3s; Sat, 31 Aug 2013 17:04:37 +0000 Received: by mail.free-electrons.com (Postfix, from userid 106) id 61B72825; Sat, 31 Aug 2013 19:04:33 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.3.2 Received: from localhost (unknown [190.2.109.158]) by mail.free-electrons.com (Postfix) with ESMTPSA id AF8EC60B; Sat, 31 Aug 2013 19:04:29 +0200 (CEST) Date: Sat, 31 Aug 2013 14:04:23 -0300 From: Ezequiel Garcia To: David Woodhouse Subject: Re: [PATCH] mtd: atmel_nand: fix the warning when CONFIG_OF is not defined Message-ID: <20130831170422.GA21617@localhost> References: <1375846569-9499-1-git-send-email-josh.wu@atmel.com> <1377894233.22372.86.camel@shinybook.infradead.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1377894233.22372.86.camel@shinybook.infradead.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130831_130436_360646_AAF6265B X-CRM114-Status: GOOD ( 24.61 ) X-Spam-Score: -3.7 (---) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-3.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -2.5 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: dedekind1@gmail.com, nicolas.ferre@atmel.com, Josh Wu , linux-mtd@lists.infradead.org, computersforpeace@gmail.com, plagnioj@jcrosoft.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org On Fri, Aug 30, 2013 at 09:23:53PM +0100, David Woodhouse wrote: > On Wed, 2013-08-07 at 11:36 +0800, Josh Wu wrote: > > This patch fix following warning: > > > > drivers/mtd/nand/atmel_nand.c:2007: warning: 'atmel_nand_nfc_match' defined but not used > > > > This patch add '#if defined(CONFIG_OF)' block to guard around the definition of > > atmel_nand_nfc_match, in order to avoid the warning when kernel is configurated > > as non-dt supported. > > Ick. This driver is littered with CONFIG_OF checks. Yet I've just seen a > patch to pxa3xx_nand which *removes* ifdefs, on the basis that all the > of_match_ functions/macros will just 'do the right thing'. Can't we do > that here too? We might just need to add __maybe_unused? > We can. We just need to provide a few dummy functions in linux/of_mtd.h just like the other of_xxx() are doing. See below! > > +#if defined(CONFIG_OF) > > static struct of_device_id atmel_nand_nfc_match[] = { > > { .compatible = "atmel,sama5d3-nfc" }, > > { /* sentinel */ } > > }; > > +#endif > > Also, why doesn't this one appear in a MODULE_DEVICE_TABLE() ? > Indeed. And why doesn't it have a "const" keyword? So, in order to remove the CONFIG_OF safely from this driver, and avoid any stupid warnings, we need to first implement these dummies: --------------------------------8<----------------------------------- -------------------------------->8----------------------------------- Of course, these are untested. If they look OK and don't cause any trouble, then I'll prepare proper patches. diff --git a/include/linux/of_mtd.h b/include/linux/of_mtd.h index ed7f267..66f173e 100644 --- a/include/linux/of_mtd.h +++ b/include/linux/of_mtd.h @@ -14,6 +14,21 @@ int of_get_nand_ecc_mode(struct device_node *np); int of_get_nand_bus_width(struct device_node *np); bool of_get_nand_on_flash_bbt(struct device_node *np); +#else +static inline int of_get_nand_ecc_mode(struct device_node *np) +{ + return -ENOSYS; +} + +static inline int of_get_nand_bus_width(struct device_node *np) +{ + return -ENOSYS; +} + +static inline bool of_get_nand_on_flash_bbt(struct device_node *np) +{ + return false; +} #endif #endif /* __LINUX_OF_MTD_H */ -------------------------------->8----------------------------------- And then, with this little patch, we get rid of the ugly CONFIG_OF check from the atmel_nand driver: --------------------------------8<----------------------------------- diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c index 0e365da..ac58098 100644 --- a/drivers/mtd/nand/atmel_nand.c +++ b/drivers/mtd/nand/atmel_nand.c @@ -1448,7 +1448,6 @@ static void atmel_nand_hwctl(struct mtd_info *mtd, int mode) ecc_writel(host->ecc, CR, ATMEL_ECC_RST); } -#if defined(CONFIG_OF) static int atmel_of_init_port(struct atmel_nand_host *host, struct device_node *np) { @@ -1456,7 +1455,7 @@ static int atmel_of_init_port(struct atmel_nand_host *host, u32 offset[2]; int ecc_mode; struct atmel_nand_data *board = &host->board; - enum of_gpio_flags flags; + enum of_gpio_flags flags = 0; if (of_property_read_u32(np, "atmel,nand-addr-offset", &val) == 0) { if (val >= 32) { @@ -1539,13 +1538,6 @@ static int atmel_of_init_port(struct atmel_nand_host *host, return 0; } -#else -static int atmel_of_init_port(struct atmel_nand_host *host, - struct device_node *np) -{ - return -EINVAL; -} -#endif static int __init atmel_hw_nand_init_params(struct platform_device *pdev, struct atmel_nand_host *host) @@ -2205,14 +2197,12 @@ static int __exit atmel_nand_remove(struct platform_device *pdev) return 0; } -#if defined(CONFIG_OF) static const struct of_device_id atmel_nand_dt_ids[] = { { .compatible = "atmel,at91rm9200-nand" }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, atmel_nand_dt_ids); -#endif static int atmel_nand_nfc_probe(struct platform_device *pdev) { @@ -2251,12 +2241,11 @@ static int atmel_nand_nfc_probe(struct platform_device *pdev) return 0; } -#if defined(CONFIG_OF) -static struct of_device_id atmel_nand_nfc_match[] = { +static const struct of_device_id atmel_nand_nfc_match[] = { { .compatible = "atmel,sama5d3-nfc" }, { /* sentinel */ } }; -#endif +MODULE_DEVICE_TABLE(of, atmel_nand_nfc_match); static struct platform_driver atmel_nand_nfc_driver = { .driver = {