* [PATCH] mtd: atmel_nand: fix the warning when CONFIG_OF is not defined
@ 2013-08-07 3:36 ` Josh Wu
0 siblings, 0 replies; 14+ messages in thread
From: Josh Wu @ 2013-08-07 3:36 UTC (permalink / raw)
To: linux-mtd, linux-arm-kernel, dedekind1
Cc: nicolas.ferre, computersforpeace, plagnioj, Josh Wu
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.
Signed-off-by: Josh Wu <josh.wu@atmel.com>
---
drivers/mtd/nand/atmel_nand.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 65b302c..ddcd575 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -2251,10 +2251,12 @@ 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[] = {
{ .compatible = "atmel,sama5d3-nfc" },
{ /* sentinel */ }
};
+#endif
static struct platform_driver atmel_nand_nfc_driver = {
.driver = {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH] mtd: atmel_nand: fix the warning when CONFIG_OF is not defined
@ 2013-08-07 3:36 ` Josh Wu
0 siblings, 0 replies; 14+ messages in thread
From: Josh Wu @ 2013-08-07 3:36 UTC (permalink / raw)
To: linux-arm-kernel
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.
Signed-off-by: Josh Wu <josh.wu@atmel.com>
---
drivers/mtd/nand/atmel_nand.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 65b302c..ddcd575 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -2251,10 +2251,12 @@ 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[] = {
{ .compatible = "atmel,sama5d3-nfc" },
{ /* sentinel */ }
};
+#endif
static struct platform_driver atmel_nand_nfc_driver = {
.driver = {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH] mtd: atmel_nand: fix the warning when CONFIG_OF is not defined
2013-08-07 3:36 ` Josh Wu
@ 2013-08-07 6:30 ` Artem Bityutskiy
-1 siblings, 0 replies; 14+ messages in thread
From: Artem Bityutskiy @ 2013-08-07 6:30 UTC (permalink / raw)
To: Josh Wu
Cc: plagnioj, computersforpeace, linux-mtd, linux-arm-kernel, nicolas.ferre
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.
>
> Signed-off-by: Josh Wu <josh.wu@atmel.com>
Pushed to l2-mtd.git, thanks!
--
Best Regards,
Artem Bityutskiy
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH] mtd: atmel_nand: fix the warning when CONFIG_OF is not defined
@ 2013-08-07 6:30 ` Artem Bityutskiy
0 siblings, 0 replies; 14+ messages in thread
From: Artem Bityutskiy @ 2013-08-07 6:30 UTC (permalink / raw)
To: linux-arm-kernel
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.
>
> Signed-off-by: Josh Wu <josh.wu@atmel.com>
Pushed to l2-mtd.git, thanks!
--
Best Regards,
Artem Bityutskiy
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] mtd: atmel_nand: fix the warning when CONFIG_OF is not defined
2013-08-07 3:36 ` Josh Wu
@ 2013-08-30 20:23 ` David Woodhouse
-1 siblings, 0 replies; 14+ messages in thread
From: David Woodhouse @ 2013-08-30 20:23 UTC (permalink / raw)
To: Josh Wu
Cc: dedekind1, nicolas.ferre, linux-mtd, computersforpeace, plagnioj,
linux-arm-kernel
[-- Attachment #1: Type: text/plain, Size: 1051 bytes --]
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?
> +#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() ?
--
David Woodhouse Open Source Technology Centre
David.Woodhouse@intel.com Intel Corporation
[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 5745 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH] mtd: atmel_nand: fix the warning when CONFIG_OF is not defined
@ 2013-08-30 20:23 ` David Woodhouse
0 siblings, 0 replies; 14+ messages in thread
From: David Woodhouse @ 2013-08-30 20:23 UTC (permalink / raw)
To: linux-arm-kernel
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?
> +#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() ?
--
David Woodhouse Open Source Technology Centre
David.Woodhouse at intel.com Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5745 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130830/c9bddb5e/attachment.bin>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] mtd: atmel_nand: fix the warning when CONFIG_OF is not defined
2013-08-30 20:23 ` David Woodhouse
@ 2013-08-31 17:04 ` Ezequiel Garcia
-1 siblings, 0 replies; 14+ messages in thread
From: Ezequiel Garcia @ 2013-08-31 17:04 UTC (permalink / raw)
To: David Woodhouse
Cc: dedekind1, nicolas.ferre, Josh Wu, linux-mtd, computersforpeace,
plagnioj, linux-arm-kernel
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<-----------------------------------
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 = {
-------------------------------->8-----------------------------------
Of course, these are untested. If they look OK and don't cause any trouble,
then I'll prepare proper patches.
--
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH] mtd: atmel_nand: fix the warning when CONFIG_OF is not defined
@ 2013-08-31 17:04 ` Ezequiel Garcia
0 siblings, 0 replies; 14+ messages in thread
From: Ezequiel Garcia @ 2013-08-31 17:04 UTC (permalink / raw)
To: linux-arm-kernel
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<-----------------------------------
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 = {
-------------------------------->8-----------------------------------
Of course, these are untested. If they look OK and don't cause any trouble,
then I'll prepare proper patches.
--
Ezequiel Garc?a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH] mtd: atmel_nand: fix the warning when CONFIG_OF is not defined
2013-08-31 17:04 ` Ezequiel Garcia
@ 2013-09-02 7:02 ` Josh Wu
-1 siblings, 0 replies; 14+ messages in thread
From: Josh Wu @ 2013-09-02 7:02 UTC (permalink / raw)
To: Ezequiel Garcia
Cc: dedekind1, David Woodhouse, nicolas.ferre, linux-mtd,
computersforpeace, plagnioj, linux-arm-kernel
Hi, Ezequiel
On 9/1/2013 1:04 AM, Ezequiel Garcia wrote:
> 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?
Thanks to point these out.
>
> 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<-----------------------------------
> 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 = {
> -------------------------------->8-----------------------------------
>
> Of course, these are untested. If they look OK and don't cause any trouble,
> then I'll prepare proper patches.
Looks nice to me. Your proposal patch does the right thing to remove the
CONFIG_OF.
So please sent them out. ;)
Best Regards,
Josh Wu
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH] mtd: atmel_nand: fix the warning when CONFIG_OF is not defined
@ 2013-09-02 7:02 ` Josh Wu
0 siblings, 0 replies; 14+ messages in thread
From: Josh Wu @ 2013-09-02 7:02 UTC (permalink / raw)
To: linux-arm-kernel
Hi, Ezequiel
On 9/1/2013 1:04 AM, Ezequiel Garcia wrote:
> 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?
Thanks to point these out.
>
> 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<-----------------------------------
> 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 = {
> -------------------------------->8-----------------------------------
>
> Of course, these are untested. If they look OK and don't cause any trouble,
> then I'll prepare proper patches.
Looks nice to me. Your proposal patch does the right thing to remove the
CONFIG_OF.
So please sent them out. ;)
Best Regards,
Josh Wu
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] mtd: atmel_nand: fix the warning when CONFIG_OF is not defined
2013-09-02 7:02 ` Josh Wu
@ 2013-09-02 17:13 ` Ezequiel Garcia
-1 siblings, 0 replies; 14+ messages in thread
From: Ezequiel Garcia @ 2013-09-02 17:13 UTC (permalink / raw)
To: Josh Wu
Cc: dedekind1, David Woodhouse, nicolas.ferre, linux-mtd,
computersforpeace, plagnioj, linux-arm-kernel
On Mon, Sep 02, 2013 at 03:02:00PM +0800, Josh Wu wrote:
> Hi, Ezequiel
>
> On 9/1/2013 1:04 AM, Ezequiel Garcia wrote:
> > 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?
>
> Thanks to point these out.
>
> >
> > 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<-----------------------------------
> > 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 = {
> > -------------------------------->8-----------------------------------
> >
> > Of course, these are untested. If they look OK and don't cause any trouble,
> > then I'll prepare proper patches.
>
> Looks nice to me. Your proposal patch does the right thing to remove the
> CONFIG_OF.
Great!
> So please sent them out. ;)
>
I'm a bit short on time these days, how about I send the first one
for the stub !OF addition and on top of that you send the atmel
patches?
--
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH] mtd: atmel_nand: fix the warning when CONFIG_OF is not defined
@ 2013-09-02 17:13 ` Ezequiel Garcia
0 siblings, 0 replies; 14+ messages in thread
From: Ezequiel Garcia @ 2013-09-02 17:13 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Sep 02, 2013 at 03:02:00PM +0800, Josh Wu wrote:
> Hi, Ezequiel
>
> On 9/1/2013 1:04 AM, Ezequiel Garcia wrote:
> > 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?
>
> Thanks to point these out.
>
> >
> > 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<-----------------------------------
> > 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 = {
> > -------------------------------->8-----------------------------------
> >
> > Of course, these are untested. If they look OK and don't cause any trouble,
> > then I'll prepare proper patches.
>
> Looks nice to me. Your proposal patch does the right thing to remove the
> CONFIG_OF.
Great!
> So please sent them out. ;)
>
I'm a bit short on time these days, how about I send the first one
for the stub !OF addition and on top of that you send the atmel
patches?
--
Ezequiel Garc?a, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] mtd: atmel_nand: fix the warning when CONFIG_OF is not defined
2013-09-02 17:13 ` Ezequiel Garcia
@ 2013-09-03 3:57 ` Josh Wu
-1 siblings, 0 replies; 14+ messages in thread
From: Josh Wu @ 2013-09-03 3:57 UTC (permalink / raw)
To: Ezequiel Garcia
Cc: dedekind1, David Woodhouse, nicolas.ferre, linux-mtd,
computersforpeace, plagnioj, linux-arm-kernel
Hi, Ezequiel
On 9/3/2013 1:13 AM, Ezequiel Garcia wrote:
> On Mon, Sep 02, 2013 at 03:02:00PM +0800, Josh Wu wrote:
>> Hi, Ezequiel
>>
>> On 9/1/2013 1:04 AM, Ezequiel Garcia wrote:
>>> 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?
>> Thanks to point these out.
>>
>>> 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<-----------------------------------
>>> 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 = {
>>> -------------------------------->8-----------------------------------
>>>
>>> Of course, these are untested. If they look OK and don't cause any trouble,
>>> then I'll prepare proper patches.
>> Looks nice to me. Your proposal patch does the right thing to remove the
>> CONFIG_OF.
> Great!
>
>> So please sent them out. ;)
>>
> I'm a bit short on time these days, how about I send the first one
> for the stub !OF addition and on top of that you send the atmel
> patches?
Okay.
Best Regards,
Josh Wu
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH] mtd: atmel_nand: fix the warning when CONFIG_OF is not defined
@ 2013-09-03 3:57 ` Josh Wu
0 siblings, 0 replies; 14+ messages in thread
From: Josh Wu @ 2013-09-03 3:57 UTC (permalink / raw)
To: linux-arm-kernel
Hi, Ezequiel
On 9/3/2013 1:13 AM, Ezequiel Garcia wrote:
> On Mon, Sep 02, 2013 at 03:02:00PM +0800, Josh Wu wrote:
>> Hi, Ezequiel
>>
>> On 9/1/2013 1:04 AM, Ezequiel Garcia wrote:
>>> 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?
>> Thanks to point these out.
>>
>>> 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<-----------------------------------
>>> 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 = {
>>> -------------------------------->8-----------------------------------
>>>
>>> Of course, these are untested. If they look OK and don't cause any trouble,
>>> then I'll prepare proper patches.
>> Looks nice to me. Your proposal patch does the right thing to remove the
>> CONFIG_OF.
> Great!
>
>> So please sent them out. ;)
>>
> I'm a bit short on time these days, how about I send the first one
> for the stub !OF addition and on top of that you send the atmel
> patches?
Okay.
Best Regards,
Josh Wu
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2013-09-03 3:57 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-07 3:36 [PATCH] mtd: atmel_nand: fix the warning when CONFIG_OF is not defined Josh Wu
2013-08-07 3:36 ` Josh Wu
2013-08-07 6:30 ` Artem Bityutskiy
2013-08-07 6:30 ` Artem Bityutskiy
2013-08-30 20:23 ` David Woodhouse
2013-08-30 20:23 ` David Woodhouse
2013-08-31 17:04 ` Ezequiel Garcia
2013-08-31 17:04 ` Ezequiel Garcia
2013-09-02 7:02 ` Josh Wu
2013-09-02 7:02 ` Josh Wu
2013-09-02 17:13 ` Ezequiel Garcia
2013-09-02 17:13 ` Ezequiel Garcia
2013-09-03 3:57 ` Josh Wu
2013-09-03 3:57 ` Josh Wu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.