mtd: Fix misuses of of_match_ptr()
authorMiquel Raynal <miquel.raynal@bootlin.com>
Thu, 27 Jan 2022 11:06:31 +0000 (12:06 +0100)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Mon, 31 Jan 2022 16:18:03 +0000 (17:18 +0100)
of_match_ptr() either expands to NULL if !CONFIG_OF, or is transparent
otherwise. There are several drivers using this macro which keep their
of_device_id array enclosed within an #ifdef CONFIG_OF check, these are
considered fine. However, When misused, the of_device_id array pointed
by this macro will produce a warning because it is finally unused when
compiled without OF support.

A number of fixes are possible:
- Always depend on CONFIG_OF, but this will not always work and may
  break boards.
- Enclose the compatible array by #ifdef's, this may save a bit of
  memory but will reduce build coverage.
- Tell the compiler the array may be unused, if this can be avoided,
  let's not do this.
- Just drop the macro, setting the of_device_id array for a non OF
  enabled platform is not an issue, it will just be unused.

The latter solution seems the more appropriate, so let's use it.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Paul Cercueil <paul@crapouillou.net>
Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Pratyush Yadav <p.yadav@ti.com>
Link: https://lore.kernel.org/linux-mtd/20220127110631.1064705-1-miquel.raynal@bootlin.com
drivers/mtd/devices/mchp23k256.c
drivers/mtd/devices/mchp48l640.c
drivers/mtd/nand/raw/atmel/nand-controller.c
drivers/mtd/nand/raw/atmel/pmecc.c
drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c
drivers/mtd/nand/raw/ingenic/jz4780_bch.c
drivers/mtd/nand/raw/mtk_ecc.c
drivers/mtd/nand/raw/omap2.c
drivers/mtd/nand/raw/renesas-nand-controller.c
drivers/mtd/nand/raw/sh_flctl.c

index a8b31bddf14b8ddb44f52c8be183d871436c4bc8..bf51eebf052c9c37f662155443f8bdc28e4b14c5 100644 (file)
@@ -234,7 +234,7 @@ MODULE_DEVICE_TABLE(of, mchp23k256_of_table);
 static struct spi_driver mchp23k256_driver = {
        .driver = {
                .name   = "mchp23k256",
-               .of_match_table = of_match_ptr(mchp23k256_of_table),
+               .of_match_table = mchp23k256_of_table,
        },
        .probe          = mchp23k256_probe,
        .remove         = mchp23k256_remove,
index 231a1079019607aedabd80487a80e10f9d0b3854..4ec505b3f4a629d83cccd6537131aec2fab9870e 100644 (file)
@@ -362,7 +362,7 @@ MODULE_DEVICE_TABLE(of, mchp48l640_of_table);
 static struct spi_driver mchp48l640_driver = {
        .driver = {
                .name   = "mchp48l640",
-               .of_match_table = of_match_ptr(mchp48l640_of_table),
+               .of_match_table = mchp48l640_of_table,
        },
        .probe          = mchp48l640_probe,
        .remove         = mchp48l640_remove,
index f3276ee9e4fe73afefc4eaf4c2f9575c8dc3c962..4ecbaccf5526ffa51453cc944037610a5c0e17b3 100644 (file)
@@ -2648,7 +2648,7 @@ static SIMPLE_DEV_PM_OPS(atmel_nand_controller_pm_ops, NULL,
 static struct platform_driver atmel_nand_controller_driver = {
        .driver = {
                .name = "atmel-nand-controller",
-               .of_match_table = of_match_ptr(atmel_nand_controller_of_ids),
+               .of_match_table = atmel_nand_controller_of_ids,
                .pm = &atmel_nand_controller_pm_ops,
        },
        .probe = atmel_nand_controller_probe,
index 498e41ccabbd36d93acc9cce097b626633cdf427..43ebd78816c03f77678ec70dc8c342fb668f1a11 100644 (file)
@@ -1003,7 +1003,7 @@ static int atmel_pmecc_probe(struct platform_device *pdev)
 static struct platform_driver atmel_pmecc_driver = {
        .driver = {
                .name = "atmel-pmecc",
-               .of_match_table = of_match_ptr(atmel_pmecc_match),
+               .of_match_table = atmel_pmecc_match,
        },
        .probe = atmel_pmecc_probe,
 };
index b18861bdcdc887223a4431db27b58ef3f96f50e9..ff26c10f295dfd75ce6c30574f0d726b0ed276a6 100644 (file)
@@ -567,7 +567,7 @@ static struct platform_driver ingenic_nand_driver = {
        .remove         = ingenic_nand_remove,
        .driver = {
                .name   = DRV_NAME,
-               .of_match_table = of_match_ptr(ingenic_nand_dt_match),
+               .of_match_table = ingenic_nand_dt_match,
        },
 };
 module_platform_driver(ingenic_nand_driver);
index d67dbfff76ccf40dd22846a2a5850c9b0cdfee5d..12b5b0484fe978513649fb7bcb1e2d4182b666d5 100644 (file)
@@ -260,7 +260,7 @@ static struct platform_driver jz4780_bch_driver = {
        .probe          = jz4780_bch_probe,
        .driver = {
                .name   = "jz4780-bch",
-               .of_match_table = of_match_ptr(jz4780_bch_dt_match),
+               .of_match_table = jz4780_bch_dt_match,
        },
 };
 module_platform_driver(jz4780_bch_driver);
index 1b47964cb6da2ce042ad537ab2c249389541c4bf..e7df3dac705e24715f5077a9fbf094a7ca394ea0 100644 (file)
@@ -579,7 +579,7 @@ static struct platform_driver mtk_ecc_driver = {
        .probe  = mtk_ecc_probe,
        .driver = {
                .name  = "mtk-ecc",
-               .of_match_table = of_match_ptr(mtk_ecc_dt_match),
+               .of_match_table = mtk_ecc_dt_match,
 #ifdef CONFIG_PM_SLEEP
                .pm = &mtk_ecc_pm_ops,
 #endif
index f0bbbe401e76c6e5698c11bf365e3ce71dd274c1..58c32a11792e65d427f16a05bb17b2891e32e7d3 100644 (file)
@@ -2298,7 +2298,7 @@ static struct platform_driver omap_nand_driver = {
        .remove         = omap_nand_remove,
        .driver         = {
                .name   = DRIVER_NAME,
-               .of_match_table = of_match_ptr(omap_nand_ids),
+               .of_match_table = omap_nand_ids,
        },
 };
 
index 428e08362956853d55ecb669d63a745c6c959bc3..6db063b230a927ee1de084d86dab5bd615667320 100644 (file)
@@ -1412,7 +1412,7 @@ MODULE_DEVICE_TABLE(of, rnandc_id_table);
 static struct platform_driver rnandc_driver = {
        .driver = {
                .name = "renesas-nandc",
-               .of_match_table = of_match_ptr(rnandc_id_table),
+               .of_match_table = rnandc_id_table,
        },
        .probe = rnandc_probe,
        .remove = rnandc_remove,
index 13df4bdf792af38dd011be93713bbe76654a9c9a..b85b9c6fcc4249f58d36047c01175bfb1ab6f661 100644 (file)
@@ -1220,7 +1220,7 @@ static struct platform_driver flctl_driver = {
        .remove         = flctl_remove,
        .driver = {
                .name   = "sh_flctl",
-               .of_match_table = of_match_ptr(of_flctl_match),
+               .of_match_table = of_flctl_match,
        },
 };