Commit 3f26d1bf authored by Miquel Raynal's avatar Miquel Raynal
Browse files

mtd: Fix misuses of of_match_ptr()



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: default avatarkernel test robot <lkp@intel.com>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Acked-by: default avatarPaul Cercueil <paul@crapouillou.net>
Reviewed-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: default avatarPratyush Yadav <p.yadav@ti.com>
Link: https://lore.kernel.org/linux-mtd/20220127110631.1064705-1-miquel.raynal@bootlin.com
parent ca6263a0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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,
+1 −1
Original line number Diff line number Diff line
@@ -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,
+1 −1
Original line number Diff line number Diff line
@@ -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,
+1 −1
Original line number Diff line number Diff line
@@ -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,
};
+1 −1
Original line number Diff line number Diff line
@@ -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);
Loading