mtd: atmel_nand: fix the warning when CONFIG_OF is not defined
Subsystems (4)
PATCH 1/1 mtd: atmel_nand: fix the warning when CONFIG_OF is not defined
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.
--- drivers/mtd/nand/atmel_nand.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mtd/nand/atmel_nand.c +2 -0
@@ -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 = {
Signature · 1 line
1.7.9.5
Artem Bityutskiy
AppliedPATCH 1/1 mtd: atmel_nand: fix the warning when CONFIG_OF is not defined
Quoted 9 lines · Josh Wu
This patch fix following warning:
drivers/mtd/nand/atmel_nand.c:2007: warning: 'atmel_nand_nfc_match' defined but not usedThis patch add '#if
defined(CONFIG_OF)' block to guard around the definition ofatmel_nand_nfc_match, in order to avoid the warning when kernel is configurated as non-dt supported.Signed-off-by Josh Wu <[email protected]>
Pushed to l2-mtd.git, thanks!
Signature · 2 lines
Best Regards, Artem Bityutskiy
PATCH 1/1 mtd: atmel_nand: fix the warning when CONFIG_OF is not defined
In reply to Josh WuQuoted 7 lines · Josh Wu
This patch fix following warning:
drivers/mtd/nand/atmel_nand.c:2007: warning: 'atmel_nand_nfc_match' defined but not usedThis patch add '#if
defined(CONFIG_OF)' block to guard around the definition ofatmel_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?
drivers/mtd/nand/atmel_nand.c static int atmel_nand_nfc_probe(struct platform_device *pdev) · line 2259
Quoted 6 lines
drivers/mtd/nand/atmel_nand.c +2
-0+#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() ?
Signature · 9 lines
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>
PATCH 1/1 mtd: atmel_nand: fix the warning when CONFIG_OF is not defined
Quoted 5 lines · David Woodhouse
Quoted 4 lines · Josh Wu
This patch fix following warning:
drivers/mtd/nand/atmel_nand.c:2007: warning: 'atmel_nand_nfc_match' defined but not used
Quoted 9 lines
Quoted 3 lines
This patch add '#if
defined(CONFIG_OF)' block to guard around the definition ofatmel_nand_nfc_match, in order to avoid the warning when kernel is configurated as non-dt supported.Ick. This driver is littered with
CONFIG_OFchecks. Yet I've just seen a patch topxa3xx_nandwhich *removes* ifdefs, on the basis that all theof_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!
Quoted 9 lines
Review
Quoted 6 lines
(quoted diff) +2
-0+#if defined(CONFIG_OF) static struct of_device_id atmel_nand_nfc_match[] = { { .compatible = "atmel,sama5d3-nfc" }, { /* sentinel */ } }; +#endifAlso, 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<-----------------------------------
include/linux/of_mtd.h +15 -0
@@ -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<-----------------------------------
drivers/mtd/nand/atmel_nand.c +3 -14
@@ -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.
Signature · 3 lines
Ezequiel Garc?a, Free Electrons Embedded Linux, Kernel and Android Engineering http://free-electrons.com
PATCH 1/1 mtd: atmel_nand: fix the warning when CONFIG_OF is not defined
Hi, Ezequiel
Quoted 25 lines · Ezequiel Garcia
Quoted 5 lines · David Woodhouse
Quoted 4 lines · Josh Wu
This patch fix following warning:
drivers/mtd/nand/atmel_nand.c:2007: warning: 'atmel_nand_nfc_match' defined but not usedQuoted 8 lines
Quoted 3 lines
This patch add '#if
defined(CONFIG_OF)' block to guard around the definition ofatmel_nand_nfc_match, in order to avoid the warning when kernel is configurated as non-dt supported.Ick. This driver is littered with
CONFIG_OFchecks. Yet I've just seen a patch topxa3xx_nandwhich *removes* ifdefs, on the basis that all theof_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.hjust like the otherof_xxx()are doing. See below!Quoted 8 lines
drivers/mtd/nand/atmel_nand.c static int atmel_nand_nfc_probe(struct platform_device *pdev)
Quoted 6 lines
drivers/mtd/nand/atmel_nand.c +2
-0+#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()?
Quoted 1 line
Indeed. And why doesn't it have a "const" keyword?
Thanks to point these out.
Quoted 105 lines
So, in order to remove the
CONFIG_OFsafely from this driver, and avoid any stupid warnings, we need to first implement these dummies:--------------------------------8<-----------------------------------
include/linux/of_mtd.h +15
-1@@ -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_OFcheck from theatmel_nanddriver:--------------------------------8<-----------------------------------
drivers/mtd/nand/atmel_nand.c +3
-15@@ -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-----------------------------------
Quoted 2 lines
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
PATCH 1/1 mtd: atmel_nand: fix the warning when CONFIG_OF is not defined
Quoted 137 lines · Josh Wu
Hi, Ezequiel
Quoted 25 lines · Ezequiel Garcia
Quoted 5 lines · David Woodhouse
Quoted 4 lines · Josh Wu
This patch fix following warning:
drivers/mtd/nand/atmel_nand.c:2007: warning: 'atmel_nand_nfc_match' defined but not usedQuoted 8 lines
Quoted 3 lines
This patch add '#if
defined(CONFIG_OF)' block to guard around the definition ofatmel_nand_nfc_match, in order to avoid the warning when kernel is configurated as non-dt supported.Ick. This driver is littered with
CONFIG_OFchecks. Yet I've just seen a patch topxa3xx_nandwhich *removes* ifdefs, on the basis that all theof_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.hjust like the otherof_xxx()are doing. See below!Quoted 8 lines
drivers/mtd/nand/atmel_nand.c static int atmel_nand_nfc_probe(struct platform_device *pdev)
Quoted 6 lines
drivers/mtd/nand/atmel_nand.c +2
-0+#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()?Quoted 1 line
Indeed. And why doesn't it have a "const" keyword?
Thanks to point these out.
Quoted 105 lines
So, in order to remove the
CONFIG_OFsafely from this driver, and avoid any stupid warnings, we need to first implement these dummies:--------------------------------8<-----------------------------------
include/linux/of_mtd.h +15
-1@@ -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_OFcheck from theatmel_nanddriver:--------------------------------8<-----------------------------------
drivers/mtd/nand/atmel_nand.c +3
-15@@ -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-----------------------------------
Quoted 5 lines
Quoted 2 lines
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!
Quoted 2 lines
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?
Signature · 3 lines
Ezequiel Garc?a, Free Electrons Embedded Linux, Kernel and Android Engineering http://free-electrons.com
PATCH 1/1 mtd: atmel_nand: fix the warning when CONFIG_OF is not defined
Hi, Ezequiel
Quoted 140 lines · Ezequiel Garcia
Quoted 131 lines · Josh Wu
Hi, Ezequiel
Quoted 25 lines · Ezequiel Garcia
Quoted 5 lines · David Woodhouse
Quoted 4 lines · Josh Wu
This patch fix following warning:
drivers/mtd/nand/atmel_nand.c:2007: warning: 'atmel_nand_nfc_match' defined but not usedQuoted 8 lines
Quoted 3 lines
This patch add '#if
defined(CONFIG_OF)' block to guard around the definition ofatmel_nand_nfc_match, in order to avoid the warning when kernel is configurated as non-dt supported.Ick. This driver is littered with
CONFIG_OFchecks. Yet I've just seen a patch topxa3xx_nandwhich *removes* ifdefs, on the basis that all theof_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.hjust like the otherof_xxx()are doing. See below!Quoted 8 lines
drivers/mtd/nand/atmel_nand.c static int atmel_nand_nfc_probe(struct platform_device *pdev)
Quoted 6 lines
drivers/mtd/nand/atmel_nand.c +2
-0+#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()?Quoted 1 line
Indeed. And why doesn't it have a "const" keyword?
Thanks to point these out.
Quoted 100 lines
So, in order to remove the
CONFIG_OFsafely from this driver, and avoid any stupid warnings, we need to first implement these dummies:--------------------------------8<-----------------------------------
include/linux/of_mtd.h +15
-1@@ -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_OFcheck from theatmel_nanddriver:--------------------------------8<-----------------------------------
drivers/mtd/nand/atmel_nand.c +3
-14@@ -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);Quoted 8 lines
Quoted 6 lines
drivers/mtd/nand/atmel_nand.c +0
-1static 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.
Quoted 7 lines
Great!
Quoted 2 lines
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