Skip to content

Commit

Permalink
drivers: gpio: use of_match_ptr() and ACPI_PTR() macros
Browse files Browse the repository at this point in the history
The of_match_ptr(foo) macro evaluates to foo, only if
CONFIG_OF is set, otherwise to NULL. Same does ACPI_PTR with
CONFIG_ACPI. That's very helpful for drivers that can be used
with or without oftree / acpi.

Even though most of the drivers touched here probably don't
actually need that, it's also nice for consistency to make it
the de-facto standard and change all drivers to use the
of_match_ptr() and ACPI_PTR() macros.

A nice side effect: in some situations, when compiled w/o
CONFIG_OF/CONFIG_ACPI, the corresponding match tables could
automatically become unreferenced and optimized-away by the
compiler, w/o explicitly cluttering the code w/ ifdef's.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
  • Loading branch information
metux authored and intel-lab-lkp committed Nov 17, 2020
1 parent 27b5ea2 commit 36e4dc1
Show file tree
Hide file tree
Showing 59 changed files with 62 additions and 62 deletions.
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-74x164.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ MODULE_DEVICE_TABLE(of, gen_74x164_dt_ids);
static struct spi_driver gen_74x164_driver = {
.driver = {
.name = "74x164",
.of_match_table = gen_74x164_dt_ids,
.of_match_table = of_match_ptr(gen_74x164_dt_ids),
},
.probe = gen_74x164_probe,
.remove = gen_74x164_remove,
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-74xx-mmio.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static int mmio_74xx_gpio_probe(struct platform_device *pdev)
static struct platform_driver mmio_74xx_gpio_driver = {
.driver = {
.name = "74xx-mmio-gpio",
.of_match_table = mmio_74xx_gpio_ids,
.of_match_table = of_match_ptr(mmio_74xx_gpio_ids),
},
.probe = mmio_74xx_gpio_probe,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-adnp.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ MODULE_DEVICE_TABLE(of, adnp_of_match);
static struct i2c_driver adnp_i2c_driver = {
.driver = {
.name = "gpio-adnp",
.of_match_table = adnp_of_match,
.of_match_table = of_match_ptr(adnp_of_match),
},
.probe = adnp_i2c_probe,
.id_table = adnp_i2c_id,
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-aspeed-sgpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ static int __init aspeed_sgpio_probe(struct platform_device *pdev)
static struct platform_driver aspeed_sgpio_driver = {
.driver = {
.name = KBUILD_MODNAME,
.of_match_table = aspeed_sgpio_of_table,
.of_match_table = of_match_ptr(aspeed_sgpio_of_table),
},
};

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-aspeed.c
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev)
static struct platform_driver aspeed_gpio_driver = {
.driver = {
.name = KBUILD_MODNAME,
.of_match_table = aspeed_gpio_of_table,
.of_match_table = of_match_ptr(aspeed_gpio_of_table),
},
};

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-ath79.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ static int ath79_gpio_probe(struct platform_device *pdev)
static struct platform_driver ath79_gpio_driver = {
.driver = {
.name = "ath79-gpio",
.of_match_table = ath79_gpio_of_match,
.of_match_table = of_match_ptr(ath79_gpio_of_match),
},
.probe = ath79_gpio_probe,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-bcm-kona.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ static int bcm_kona_gpio_probe(struct platform_device *pdev)
static struct platform_driver bcm_kona_gpio_driver = {
.driver = {
.name = "bcm-kona-gpio",
.of_match_table = bcm_kona_gpio_of_match,
.of_match_table = of_match_ptr(bcm_kona_gpio_of_match),
},
.probe = bcm_kona_gpio_probe,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-brcmstb.c
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ MODULE_DEVICE_TABLE(of, brcmstb_gpio_of_match);
static struct platform_driver brcmstb_gpio_driver = {
.driver = {
.name = "brcmstb-gpio",
.of_match_table = brcmstb_gpio_of_match,
.of_match_table = of_match_ptr(brcmstb_gpio_of_match),
.pm = &brcmstb_gpio_pm_ops,
},
.probe = brcmstb_gpio_probe,
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-cadence.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ static const struct of_device_id cdns_of_ids[] = {
static struct platform_driver cdns_gpio_driver = {
.driver = {
.name = "cdns-gpio",
.of_match_table = cdns_of_ids,
.of_match_table = of_match_ptr(cdns_of_ids),
},
.probe = cdns_gpio_probe,
.remove = cdns_gpio_remove,
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-creg-snps.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ static int creg_gpio_probe(struct platform_device *pdev)
static struct platform_driver creg_gpio_snps_driver = {
.driver = {
.name = "snps-creg-gpio",
.of_match_table = creg_gpio_ids,
.of_match_table = of_match_ptr(creg_gpio_ids),
},
.probe = creg_gpio_probe,
};
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpio/gpio-dwapb.c
Original file line number Diff line number Diff line change
Expand Up @@ -822,8 +822,8 @@ static struct platform_driver dwapb_gpio_driver = {
.driver = {
.name = DWAPB_DRIVER_NAME,
.pm = &dwapb_gpio_pm_ops,
.of_match_table = dwapb_of_match,
.acpi_match_table = dwapb_acpi_match,
.of_match_table = of_match_ptr(dwapb_of_match),
.acpi_match_table = ACPI_PTR(dwapb_acpi_match),
},
.probe = dwapb_gpio_probe,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-eic-sprd.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ static struct platform_driver sprd_eic_driver = {
.probe = sprd_eic_probe,
.driver = {
.name = "sprd-eic",
.of_match_table = sprd_eic_of_match,
.of_match_table = of_match_ptr(sprd_eic_of_match),
},
};

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-em.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ static struct platform_driver em_gio_device_driver = {
.probe = em_gio_probe,
.driver = {
.name = "em_gio",
.of_match_table = em_gio_dt_ids,
.of_match_table = of_match_ptr(em_gio_dt_ids),
}
};

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-ge.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static int __init gef_gpio_probe(struct platform_device *pdev)
static struct platform_driver gef_gpio_driver = {
.driver = {
.name = "gef-gpio",
.of_match_table = gef_gpio_ids,
.of_match_table = of_match_ptr(gef_gpio_ids),
},
};
module_platform_driver_probe(gef_gpio_driver, gef_gpio_probe);
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-grgpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ MODULE_DEVICE_TABLE(of, grgpio_match);
static struct platform_driver grgpio_driver = {
.driver = {
.name = "grgpio",
.of_match_table = grgpio_match,
.of_match_table = of_match_ptr(grgpio_match),
},
.probe = grgpio_probe,
.remove = grgpio_remove,
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-gw-pld.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ MODULE_DEVICE_TABLE(of, gw_pld_dt_ids);
static struct i2c_driver gw_pld_driver = {
.driver = {
.name = "gw_pld",
.of_match_table = gw_pld_dt_ids,
.of_match_table = of_match_ptr(gw_pld_dt_ids),
},
.probe = gw_pld_probe,
.id_table = gw_pld_id,
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-hlwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ MODULE_DEVICE_TABLE(of, hlwd_gpio_match);
static struct platform_driver hlwd_gpio_driver = {
.driver = {
.name = "gpio-hlwd",
.of_match_table = hlwd_gpio_match,
.of_match_table = of_match_ptr(hlwd_gpio_match),
},
.probe = hlwd_gpio_probe,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-logicvc.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ MODULE_DEVICE_TABLE(of, logicivc_gpio_of_table);
static struct platform_driver logicvc_gpio_driver = {
.driver = {
.name = "gpio-logicvc",
.of_match_table = logicivc_gpio_of_table,
.of_match_table = of_match_ptr(logicivc_gpio_of_table),
},
.probe = logicvc_gpio_probe,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-lp3943.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ static struct platform_driver lp3943_gpio_driver = {
.probe = lp3943_gpio_probe,
.driver = {
.name = "lp3943-gpio",
.of_match_table = lp3943_gpio_of_match,
.of_match_table = of_match_ptr(lp3943_gpio_of_match),
},
};
module_platform_driver(lp3943_gpio_driver);
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-lpc18xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ static struct platform_driver lpc18xx_gpio_driver = {
.remove = lpc18xx_gpio_remove,
.driver = {
.name = "lpc18xx-gpio",
.of_match_table = lpc18xx_gpio_match,
.of_match_table = of_match_ptr(lpc18xx_gpio_match),
},
};
module_platform_driver(lpc18xx_gpio_driver);
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-mb86s7x.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ MODULE_DEVICE_TABLE(acpi, mb86s70_gpio_acpi_ids);
static struct platform_driver mb86s70_gpio_driver = {
.driver = {
.name = "mb86s70-gpio",
.of_match_table = mb86s70_gpio_dt_ids,
.of_match_table = of_match_ptr(mb86s70_gpio_dt_ids),
.acpi_match_table = ACPI_PTR(mb86s70_gpio_acpi_ids),
},
.probe = mb86s70_gpio_probe,
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-mm-lantiq.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static struct platform_driver ltq_mm_driver = {
.remove = ltq_mm_remove,
.driver = {
.name = "gpio-mm-ltq",
.of_match_table = ltq_mm_match,
.of_match_table = of_match_ptr(ltq_mm_match),
},
};

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-moxtet.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ static const enum turris_mox_module_id moxtet_gpio_module_table[] = {
static struct moxtet_driver moxtet_gpio_driver = {
.driver = {
.name = "moxtet-gpio",
.of_match_table = moxtet_gpio_dt_ids,
.of_match_table = of_match_ptr(moxtet_gpio_dt_ids),
.probe = moxtet_gpio_probe,
},
.id_table = moxtet_gpio_module_table,
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpio/gpio-mpc5200.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ static const struct of_device_id mpc52xx_wkup_gpiochip_match[] = {
static struct platform_driver mpc52xx_wkup_gpiochip_driver = {
.driver = {
.name = "mpc5200-gpio-wkup",
.of_match_table = mpc52xx_wkup_gpiochip_match,
.of_match_table = of_match_ptr(mpc52xx_wkup_gpiochip_match),
},
.probe = mpc52xx_wkup_gpiochip_probe,
.remove = mpc52xx_gpiochip_remove,
Expand Down Expand Up @@ -335,7 +335,7 @@ static const struct of_device_id mpc52xx_simple_gpiochip_match[] = {
static struct platform_driver mpc52xx_simple_gpiochip_driver = {
.driver = {
.name = "mpc5200-gpio",
.of_match_table = mpc52xx_simple_gpiochip_match,
.of_match_table = of_match_ptr(mpc52xx_simple_gpiochip_match),
},
.probe = mpc52xx_simple_gpiochip_probe,
.remove = mpc52xx_gpiochip_remove,
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-mpc8xxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ static struct platform_driver mpc8xxx_plat_driver = {
.remove = mpc8xxx_remove,
.driver = {
.name = "gpio-mpc8xxx",
.of_match_table = mpc8xxx_gpio_ids,
.of_match_table = of_match_ptr(mpc8xxx_gpio_ids),
},
};

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-mt7621.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ static struct platform_driver mediatek_gpio_driver = {
.probe = mediatek_gpio_probe,
.driver = {
.name = "mt7621_gpio",
.of_match_table = mediatek_gpio_match,
.of_match_table = of_match_ptr(mediatek_gpio_match),
},
};

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-mvebu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,7 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
static struct platform_driver mvebu_gpio_driver = {
.driver = {
.name = "mvebu-gpio",
.of_match_table = mvebu_gpio_of_match,
.of_match_table = of_match_ptr(mvebu_gpio_of_match),
},
.probe = mvebu_gpio_probe,
.suspend = mvebu_gpio_suspend,
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-mxc.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ static struct syscore_ops mxc_gpio_syscore_ops = {
static struct platform_driver mxc_gpio_driver = {
.driver = {
.name = "gpio-mxc",
.of_match_table = mxc_gpio_dt_ids,
.of_match_table = of_match_ptr(mxc_gpio_dt_ids),
.suppress_bind_attrs = true,
},
.probe = mxc_gpio_probe,
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-mxs.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ static int mxs_gpio_probe(struct platform_device *pdev)
static struct platform_driver mxs_gpio_driver = {
.driver = {
.name = "gpio-mxs",
.of_match_table = mxs_gpio_dt_ids,
.of_match_table = of_match_ptr(mxs_gpio_dt_ids),
.suppress_bind_attrs = true,
},
.probe = mxs_gpio_probe,
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-octeon.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ MODULE_DEVICE_TABLE(of, octeon_gpio_match);
static struct platform_driver octeon_gpio_driver = {
.driver = {
.name = "octeon_gpio",
.of_match_table = octeon_gpio_match,
.of_match_table = of_match_ptr(octeon_gpio_match),
},
.probe = octeon_gpio_probe,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-omap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,7 @@ static struct platform_driver omap_gpio_driver = {
.driver = {
.name = "omap_gpio",
.pm = &gpio_pm_ops,
.of_match_table = omap_gpio_match,
.of_match_table = of_match_ptr(omap_gpio_match),
},
};

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-palmas.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ static int palmas_gpio_probe(struct platform_device *pdev)

static struct platform_driver palmas_gpio_driver = {
.driver.name = "palmas-gpio",
.driver.of_match_table = of_palmas_gpio_match,
.driver.of_match_table = of_match_ptr(of_palmas_gpio_match),
.probe = palmas_gpio_probe,
};

Expand Down
4 changes: 2 additions & 2 deletions drivers/gpio/gpio-pca953x.c
Original file line number Diff line number Diff line change
Expand Up @@ -1284,8 +1284,8 @@ static struct i2c_driver pca953x_driver = {
.driver = {
.name = "pca953x",
.pm = &pca953x_pm_ops,
.of_match_table = pca953x_dt_ids,
.acpi_match_table = pca953x_acpi_ids,
.of_match_table = of_match_ptr(pca953x_dt_ids),
.acpi_match_table = ACPI_PTR(pca953x_acpi_ids),
},
.probe = pca953x_probe,
.remove = pca953x_remove,
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-pca9570.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ MODULE_DEVICE_TABLE(of, pca9570_of_match_table);
static struct i2c_driver pca9570_driver = {
.driver = {
.name = "pca9570",
.of_match_table = pca9570_of_match_table,
.of_match_table = of_match_ptr(pca9570_of_match_table),
},
.probe_new = pca9570_probe,
.id_table = pca9570_id_table,
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-pisosr.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ MODULE_DEVICE_TABLE(of, pisosr_gpio_of_match_table);
static struct spi_driver pisosr_gpio_driver = {
.driver = {
.name = "pisosr-gpio",
.of_match_table = pisosr_gpio_of_match_table,
.of_match_table = of_match_ptr(pisosr_gpio_of_match_table),
},
.probe = pisosr_gpio_probe,
.remove = pisosr_gpio_remove,
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-pmic-eic-sprd.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ static struct platform_driver sprd_pmic_eic_driver = {
.probe = sprd_pmic_eic_probe,
.driver = {
.name = "sprd-pmic-eic",
.of_match_table = sprd_pmic_eic_of_match,
.of_match_table = of_match_ptr(sprd_pmic_eic_of_match),
},
};

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-rda.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ static struct platform_driver rda_gpio_driver = {
.probe = rda_gpio_probe,
.driver = {
.name = "rda-gpio",
.of_match_table = rda_gpio_of_match,
.of_match_table = of_match_ptr(rda_gpio_of_match),
},
};

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-sl28cpld.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ static struct platform_driver sl28cpld_gpio_driver = {
.probe = sl28cpld_gpio_probe,
.driver = {
.name = "sl28cpld-gpio",
.of_match_table = sl28cpld_gpio_of_match,
.of_match_table = of_match_ptr(sl28cpld_gpio_of_match),
},
};
module_platform_driver(sl28cpld_gpio_driver);
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-spear-spics.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ static struct platform_driver spics_gpio_driver = {
.probe = spics_gpio_probe,
.driver = {
.name = "spear-spics-gpio",
.of_match_table = spics_gpio_of_match,
.of_match_table = of_match_ptr(spics_gpio_of_match),
},
};

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-sprd.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ static struct platform_driver sprd_gpio_driver = {
.probe = sprd_gpio_probe,
.driver = {
.name = "sprd-gpio",
.of_match_table = sprd_gpio_of_match,
.of_match_table = of_match_ptr(sprd_gpio_of_match),
},
};

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-stp-xway.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ static struct platform_driver xway_stp_driver = {
.probe = xway_stp_probe,
.driver = {
.name = "gpio-stp-xway",
.of_match_table = xway_stp_match,
.of_match_table = of_match_ptr(xway_stp_match),
},
};

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-syscon.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ static int syscon_gpio_probe(struct platform_device *pdev)
static struct platform_driver syscon_gpio_driver = {
.driver = {
.name = "gpio-syscon",
.of_match_table = syscon_gpio_ids,
.of_match_table = of_match_ptr(syscon_gpio_ids),
},
.probe = syscon_gpio_probe,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpio/gpio-tb10x.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ static struct platform_driver tb10x_gpio_driver = {
.remove = tb10x_gpio_remove,
.driver = {
.name = "tb10x-gpio",
.of_match_table = tb10x_gpio_dt_ids,
.of_match_table = of_match_ptr(tb10x_gpio_dt_ids),
}
};

Expand Down
Loading

0 comments on commit 36e4dc1

Please sign in to comment.