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: 2852414 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7971D9F313 for ; Sat, 31 Aug 2013 17:04:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5C772202DB for ; Sat, 31 Aug 2013 17:04:57 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 498EB202CC for ; Sat, 31 Aug 2013 17:04:56 +0000 (UTC) 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.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 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 (---) 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-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 = {