Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pinctrl: Use device_get_match_data()

Use preferred device_get_match_data() instead of of_match_device() to
get the driver match data. With this, adjust the includes to explicitly
include the correct headers.

Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://lore.kernel.org/r/20231009172923.2457844-18-robh@kernel.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Rob Herring and committed by
Linus Walleij
63bffc2d e2b0bac1

+59 -108
+2 -6
drivers/pinctrl/bcm/pinctrl-ns.c
··· 7 7 #include <linux/io.h> 8 8 #include <linux/module.h> 9 9 #include <linux/of.h> 10 - #include <linux/of_device.h> 11 10 #include <linux/pinctrl/pinconf-generic.h> 12 11 #include <linux/pinctrl/pinctrl.h> 13 12 #include <linux/pinctrl/pinmux.h> 14 13 #include <linux/platform_device.h> 14 + #include <linux/property.h> 15 15 #include <linux/slab.h> 16 16 17 17 #include "../core.h" ··· 208 208 static int ns_pinctrl_probe(struct platform_device *pdev) 209 209 { 210 210 struct device *dev = &pdev->dev; 211 - const struct of_device_id *of_id; 212 211 struct ns_pinctrl *ns_pinctrl; 213 212 struct pinctrl_desc *pctldesc; 214 213 struct pinctrl_pin_desc *pin; ··· 224 225 225 226 ns_pinctrl->dev = dev; 226 227 227 - of_id = of_match_device(ns_pinctrl_of_match_table, dev); 228 - if (!of_id) 229 - return -EINVAL; 230 - ns_pinctrl->chipset_flag = (uintptr_t)of_id->data; 228 + ns_pinctrl->chipset_flag = (uintptr_t)device_get_match_data(dev); 231 229 232 230 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, 233 231 "cru_gpio_control");
+3 -5
drivers/pinctrl/berlin/berlin-bg2.c
··· 8 8 */ 9 9 10 10 #include <linux/init.h> 11 - #include <linux/of_device.h> 11 + #include <linux/of.h> 12 12 #include <linux/platform_device.h> 13 + #include <linux/property.h> 13 14 #include <linux/regmap.h> 14 15 15 16 #include "berlin.h" ··· 228 227 229 228 static int berlin2_pinctrl_probe(struct platform_device *pdev) 230 229 { 231 - const struct of_device_id *match = 232 - of_match_device(berlin2_pinctrl_match, &pdev->dev); 233 - 234 - return berlin_pinctrl_probe(pdev, match->data); 230 + return berlin_pinctrl_probe(pdev, device_get_match_data(&pdev->dev)); 235 231 } 236 232 237 233 static struct platform_driver berlin2_pinctrl_driver = {
+3 -5
drivers/pinctrl/berlin/berlin-bg2cd.c
··· 8 8 */ 9 9 10 10 #include <linux/init.h> 11 - #include <linux/of_device.h> 11 + #include <linux/of.h> 12 12 #include <linux/platform_device.h> 13 + #include <linux/property.h> 13 14 #include <linux/regmap.h> 14 15 15 16 #include "berlin.h" ··· 173 172 174 173 static int berlin2cd_pinctrl_probe(struct platform_device *pdev) 175 174 { 176 - const struct of_device_id *match = 177 - of_match_device(berlin2cd_pinctrl_match, &pdev->dev); 178 - 179 - return berlin_pinctrl_probe(pdev, match->data); 175 + return berlin_pinctrl_probe(pdev, device_get_match_data(&pdev->dev)); 180 176 } 181 177 182 178 static struct platform_driver berlin2cd_pinctrl_driver = {
+3 -5
drivers/pinctrl/berlin/berlin-bg2q.c
··· 8 8 */ 9 9 10 10 #include <linux/init.h> 11 - #include <linux/of_device.h> 11 + #include <linux/of.h> 12 12 #include <linux/platform_device.h> 13 + #include <linux/property.h> 13 14 #include <linux/regmap.h> 14 15 15 16 #include "berlin.h" ··· 390 389 391 390 static int berlin2q_pinctrl_probe(struct platform_device *pdev) 392 391 { 393 - const struct of_device_id *match = 394 - of_match_device(berlin2q_pinctrl_match, &pdev->dev); 395 - 396 - return berlin_pinctrl_probe(pdev, match->data); 392 + return berlin_pinctrl_probe(pdev, device_get_match_data(&pdev->dev)); 397 393 } 398 394 399 395 static struct platform_driver berlin2q_pinctrl_driver = {
+5 -4
drivers/pinctrl/berlin/berlin-bg4ct.c
··· 8 8 */ 9 9 10 10 #include <linux/init.h> 11 - #include <linux/of_device.h> 11 + #include <linux/of.h> 12 12 #include <linux/platform_device.h> 13 + #include <linux/property.h> 13 14 #include <linux/regmap.h> 14 15 15 16 #include "berlin.h" ··· 450 449 451 450 static int berlin4ct_pinctrl_probe(struct platform_device *pdev) 452 451 { 453 - const struct of_device_id *match = 454 - of_match_device(berlin4ct_pinctrl_match, &pdev->dev); 452 + const struct berlin_pinctrl_desc *desc = 453 + device_get_match_data(&pdev->dev); 455 454 struct regmap_config *rmconfig; 456 455 struct regmap *regmap; 457 456 struct resource *res; ··· 474 473 if (IS_ERR(regmap)) 475 474 return PTR_ERR(regmap); 476 475 477 - return berlin_pinctrl_probe_regmap(pdev, match->data, regmap); 476 + return berlin_pinctrl_probe_regmap(pdev, desc, regmap); 478 477 } 479 478 480 479 static struct platform_driver berlin4ct_pinctrl_driver = {
+5 -4
drivers/pinctrl/berlin/pinctrl-as370.c
··· 8 8 */ 9 9 10 10 #include <linux/init.h> 11 - #include <linux/of_device.h> 11 + #include <linux/of.h> 12 12 #include <linux/platform_device.h> 13 + #include <linux/property.h> 13 14 #include <linux/regmap.h> 14 15 15 16 #include "berlin.h" ··· 331 330 332 331 static int as370_pinctrl_probe(struct platform_device *pdev) 333 332 { 334 - const struct of_device_id *match = 335 - of_match_device(as370_pinctrl_match, &pdev->dev); 333 + const struct berlin_pinctrl_desc *desc = 334 + device_get_match_data(&pdev->dev); 336 335 struct regmap_config *rmconfig; 337 336 struct regmap *regmap; 338 337 struct resource *res; ··· 355 354 if (IS_ERR(regmap)) 356 355 return PTR_ERR(regmap); 357 356 358 - return berlin_pinctrl_probe_regmap(pdev, match->data, regmap); 357 + return berlin_pinctrl_probe_regmap(pdev, desc, regmap); 359 358 } 360 359 361 360 static struct platform_driver as370_pinctrl_driver = {
+2 -7
drivers/pinctrl/mvebu/pinctrl-armada-38x.c
··· 12 12 #include <linux/io.h> 13 13 #include <linux/platform_device.h> 14 14 #include <linux/of.h> 15 - #include <linux/of_device.h> 16 15 #include <linux/pinctrl/pinctrl.h> 16 + #include <linux/property.h> 17 17 18 18 #include "pinctrl-mvebu.h" 19 19 ··· 404 404 static int armada_38x_pinctrl_probe(struct platform_device *pdev) 405 405 { 406 406 struct mvebu_pinctrl_soc_info *soc = &armada_38x_pinctrl_info; 407 - const struct of_device_id *match = 408 - of_match_device(armada_38x_pinctrl_of_match, &pdev->dev); 409 407 410 - if (!match) 411 - return -ENODEV; 412 - 413 - soc->variant = (unsigned) match->data & 0xff; 408 + soc->variant = (unsigned)device_get_match_data(&pdev->dev) & 0xff; 414 409 soc->controls = armada_38x_mpp_controls; 415 410 soc->ncontrols = ARRAY_SIZE(armada_38x_mpp_controls); 416 411 soc->gpioranges = armada_38x_mpp_gpio_ranges;
+2 -7
drivers/pinctrl/mvebu/pinctrl-armada-39x.c
··· 12 12 #include <linux/io.h> 13 13 #include <linux/platform_device.h> 14 14 #include <linux/of.h> 15 - #include <linux/of_device.h> 16 15 #include <linux/pinctrl/pinctrl.h> 16 + #include <linux/property.h> 17 17 18 18 #include "pinctrl-mvebu.h" 19 19 ··· 386 386 static int armada_39x_pinctrl_probe(struct platform_device *pdev) 387 387 { 388 388 struct mvebu_pinctrl_soc_info *soc = &armada_39x_pinctrl_info; 389 - const struct of_device_id *match = 390 - of_match_device(armada_39x_pinctrl_of_match, &pdev->dev); 391 389 392 - if (!match) 393 - return -ENODEV; 394 - 395 - soc->variant = (unsigned) match->data & 0xff; 390 + soc->variant = (unsigned)device_get_match_data(&pdev->dev) & 0xff; 396 391 soc->controls = armada_39x_mpp_controls; 397 392 soc->ncontrols = ARRAY_SIZE(armada_39x_mpp_controls); 398 393 soc->gpioranges = armada_39x_mpp_gpio_ranges;
+1 -4
drivers/pinctrl/mvebu/pinctrl-armada-ap806.c
··· 13 13 #include <linux/io.h> 14 14 #include <linux/platform_device.h> 15 15 #include <linux/of.h> 16 - #include <linux/of_device.h> 17 16 #include <linux/pinctrl/pinctrl.h> 18 17 19 18 #include "pinctrl-mvebu.h" ··· 105 106 static int armada_ap806_pinctrl_probe(struct platform_device *pdev) 106 107 { 107 108 struct mvebu_pinctrl_soc_info *soc = &armada_ap806_pinctrl_info; 108 - const struct of_device_id *match = 109 - of_match_device(armada_ap806_pinctrl_of_match, &pdev->dev); 110 109 111 - if (!match || !pdev->dev.parent) 110 + if (!pdev->dev.parent) 112 111 return -ENODEV; 113 112 114 113 soc->variant = 0; /* no variants for Armada AP806 */
+2 -4
drivers/pinctrl/mvebu/pinctrl-armada-cp110.c
··· 12 12 #include <linux/io.h> 13 13 #include <linux/mfd/syscon.h> 14 14 #include <linux/of.h> 15 - #include <linux/of_device.h> 16 15 #include <linux/pinctrl/pinctrl.h> 17 16 #include <linux/platform_device.h> 17 + #include <linux/property.h> 18 18 19 19 #include "pinctrl-mvebu.h" 20 20 ··· 638 638 static int armada_cp110_pinctrl_probe(struct platform_device *pdev) 639 639 { 640 640 struct mvebu_pinctrl_soc_info *soc; 641 - const struct of_device_id *match = 642 - of_match_device(armada_cp110_pinctrl_of_match, &pdev->dev); 643 641 int i; 644 642 645 643 if (!pdev->dev.parent) ··· 648 650 if (!soc) 649 651 return -ENOMEM; 650 652 651 - soc->variant = (unsigned long) match->data & 0xff; 653 + soc->variant = (unsigned long)device_get_match_data(&pdev->dev) & 0xff; 652 654 soc->controls = armada_cp110_mpp_controls; 653 655 soc->ncontrols = ARRAY_SIZE(armada_cp110_mpp_controls); 654 656 soc->modes = armada_cp110_mpp_modes;
+2 -7
drivers/pinctrl/mvebu/pinctrl-armada-xp.c
··· 19 19 #include <linux/platform_device.h> 20 20 #include <linux/clk.h> 21 21 #include <linux/of.h> 22 - #include <linux/of_device.h> 23 22 #include <linux/pinctrl/pinctrl.h> 23 + #include <linux/property.h> 24 24 #include <linux/bitops.h> 25 25 26 26 #include "pinctrl-mvebu.h" ··· 568 568 static int armada_xp_pinctrl_probe(struct platform_device *pdev) 569 569 { 570 570 struct mvebu_pinctrl_soc_info *soc = &armada_xp_pinctrl_info; 571 - const struct of_device_id *match = 572 - of_match_device(armada_xp_pinctrl_of_match, &pdev->dev); 573 571 int nregs; 574 572 575 - if (!match) 576 - return -ENODEV; 577 - 578 - soc->variant = (unsigned) match->data & 0xff; 573 + soc->variant = (unsigned)device_get_match_data(&pdev->dev) & 0xff; 579 574 580 575 switch (soc->variant) { 581 576 case V_MV78230:
+2 -4
drivers/pinctrl/mvebu/pinctrl-dove.c
··· 12 12 #include <linux/platform_device.h> 13 13 #include <linux/clk.h> 14 14 #include <linux/of.h> 15 - #include <linux/of_device.h> 16 15 #include <linux/mfd/syscon.h> 17 16 #include <linux/pinctrl/pinctrl.h> 17 + #include <linux/property.h> 18 18 #include <linux/regmap.h> 19 19 20 20 #include "pinctrl-mvebu.h" ··· 765 765 { 766 766 struct resource *res, *mpp_res; 767 767 struct resource fb_res; 768 - const struct of_device_id *match = 769 - of_match_device(dove_pinctrl_of_match, &pdev->dev); 770 768 struct mvebu_mpp_ctrl_data *mpp_data; 771 769 void __iomem *base; 772 770 int i; 773 771 774 - pdev->dev.platform_data = (void *)match->data; 772 + pdev->dev.platform_data = (void *)device_get_match_data(&pdev->dev); 775 773 776 774 /* 777 775 * General MPP Configuration Register is part of pdma registers.
+2 -5
drivers/pinctrl/mvebu/pinctrl-kirkwood.c
··· 11 11 #include <linux/platform_device.h> 12 12 #include <linux/clk.h> 13 13 #include <linux/of.h> 14 - #include <linux/of_device.h> 15 14 #include <linux/pinctrl/pinctrl.h> 15 + #include <linux/property.h> 16 16 17 17 #include "pinctrl-mvebu.h" 18 18 ··· 470 470 471 471 static int kirkwood_pinctrl_probe(struct platform_device *pdev) 472 472 { 473 - const struct of_device_id *match = 474 - of_match_device(kirkwood_pinctrl_of_match, &pdev->dev); 475 - 476 - pdev->dev.platform_data = (void *)match->data; 473 + pdev->dev.platform_data = (void *)device_get_match_data(&pdev->dev); 477 474 478 475 return mvebu_pinctrl_simple_mmio_probe(pdev); 479 476 }
+2 -5
drivers/pinctrl/mvebu/pinctrl-orion.c
··· 19 19 #include <linux/platform_device.h> 20 20 #include <linux/clk.h> 21 21 #include <linux/of.h> 22 - #include <linux/of_device.h> 23 22 #include <linux/pinctrl/pinctrl.h> 23 + #include <linux/property.h> 24 24 25 25 #include "pinctrl-mvebu.h" 26 26 ··· 218 218 219 219 static int orion_pinctrl_probe(struct platform_device *pdev) 220 220 { 221 - const struct of_device_id *match = 222 - of_match_device(orion_pinctrl_of_match, &pdev->dev); 223 - 224 - pdev->dev.platform_data = (void*)match->data; 221 + pdev->dev.platform_data = (void*)device_get_match_data(&pdev->dev); 225 222 226 223 mpp_base = devm_platform_ioremap_resource(pdev, 0); 227 224 if (IS_ERR(mpp_base))
+2 -7
drivers/pinctrl/nomadik/pinctrl-abx500.c
··· 17 17 #include <linux/of.h> 18 18 #include <linux/of_device.h> 19 19 #include <linux/platform_device.h> 20 + #include <linux/property.h> 20 21 #include <linux/seq_file.h> 21 22 #include <linux/slab.h> 22 23 #include <linux/types.h> ··· 986 985 static int abx500_gpio_probe(struct platform_device *pdev) 987 986 { 988 987 struct device_node *np = pdev->dev.of_node; 989 - const struct of_device_id *match; 990 988 struct abx500_pinctrl *pct; 991 989 unsigned int id = -1; 992 990 int ret; ··· 1006 1006 pct->chip.parent = &pdev->dev; 1007 1007 pct->chip.base = -1; /* Dynamic allocation */ 1008 1008 1009 - match = of_match_device(abx500_gpio_match, &pdev->dev); 1010 - if (!match) { 1011 - dev_err(&pdev->dev, "gpio dt not matching\n"); 1012 - return -ENODEV; 1013 - } 1014 - id = (unsigned long)match->data; 1009 + id = (unsigned long)device_get_match_data(&pdev->dev); 1015 1010 1016 1011 /* Poke in other ASIC variants here */ 1017 1012 switch (id) {
+4 -6
drivers/pinctrl/nomadik/pinctrl-nomadik.c
··· 16 16 #include <linux/interrupt.h> 17 17 #include <linux/io.h> 18 18 #include <linux/kernel.h> 19 + #include <linux/of.h> 19 20 #include <linux/of_address.h> 20 - #include <linux/of_device.h> 21 + #include <linux/of_platform.h> 21 22 #include <linux/platform_device.h> 23 + #include <linux/property.h> 22 24 #include <linux/seq_file.h> 23 25 #include <linux/slab.h> 24 26 #include <linux/spinlock.h> ··· 1840 1838 1841 1839 static int nmk_pinctrl_probe(struct platform_device *pdev) 1842 1840 { 1843 - const struct of_device_id *match; 1844 1841 struct device_node *np = pdev->dev.of_node; 1845 1842 struct device_node *prcm_np; 1846 1843 struct nmk_pinctrl *npct; ··· 1850 1849 if (!npct) 1851 1850 return -ENOMEM; 1852 1851 1853 - match = of_match_device(nmk_pinctrl_match, &pdev->dev); 1854 - if (!match) 1855 - return -ENODEV; 1856 - version = (unsigned int) match->data; 1852 + version = (unsigned int)device_get_match_data(&pdev->dev); 1857 1853 1858 1854 /* Poke in other ASIC variants here */ 1859 1855 if (version == PINCTRL_NMK_STN8815)
+5 -6
drivers/pinctrl/pinctrl-at91.c
··· 12 12 #include <linux/interrupt.h> 13 13 #include <linux/io.h> 14 14 #include <linux/of.h> 15 - #include <linux/of_address.h> 16 - #include <linux/of_device.h> 17 - #include <linux/of_irq.h> 15 + #include <linux/platform_device.h> 18 16 #include <linux/pm.h> 17 + #include <linux/property.h> 19 18 #include <linux/seq_file.h> 20 19 #include <linux/slab.h> 21 20 #include <linux/string_helpers.h> ··· 1301 1302 if (!np) 1302 1303 return -ENODEV; 1303 1304 1304 - info->dev = dev; 1305 - info->ops = of_device_get_match_data(dev); 1305 + info->dev = &pdev->dev; 1306 + info->ops = device_get_match_data(&pdev->dev); 1306 1307 at91_pinctrl_child_count(info, np); 1307 1308 1308 1309 /* ··· 1844 1845 if (IS_ERR(at91_chip->regbase)) 1845 1846 return PTR_ERR(at91_chip->regbase); 1846 1847 1847 - at91_chip->ops = of_device_get_match_data(dev); 1848 + at91_chip->ops = device_get_match_data(dev); 1848 1849 at91_chip->pioc_virq = irq; 1849 1850 1850 1851 at91_chip->clock = devm_clk_get_enabled(dev, NULL);
+4 -7
drivers/pinctrl/pinctrl-xway.c
··· 11 11 #include <linux/gpio/driver.h> 12 12 #include <linux/slab.h> 13 13 #include <linux/module.h> 14 - #include <linux/of_platform.h> 15 - #include <linux/of_address.h> 14 + #include <linux/of.h> 16 15 #include <linux/ioport.h> 17 16 #include <linux/io.h> 18 17 #include <linux/device.h> 19 18 #include <linux/platform_device.h> 19 + #include <linux/property.h> 20 20 21 21 #include "pinctrl-lantiq.h" 22 22 ··· 1451 1451 1452 1452 static int pinmux_xway_probe(struct platform_device *pdev) 1453 1453 { 1454 - const struct of_device_id *match; 1455 1454 const struct pinctrl_xway_soc *xway_soc; 1456 1455 int ret, i; 1457 1456 ··· 1459 1460 if (IS_ERR(xway_info.membase[0])) 1460 1461 return PTR_ERR(xway_info.membase[0]); 1461 1462 1462 - match = of_match_device(xway_match, &pdev->dev); 1463 - if (match) 1464 - xway_soc = (const struct pinctrl_xway_soc *) match->data; 1465 - else 1463 + xway_soc = device_get_match_data(&pdev->dev); 1464 + if (!xway_soc) 1466 1465 xway_soc = &danube_pinctrl; 1467 1466 1468 1467 /* find out how many pads we have */
+8 -10
drivers/pinctrl/ti/pinctrl-ti-iodelay.c
··· 14 14 #include <linux/io.h> 15 15 #include <linux/module.h> 16 16 #include <linux/of.h> 17 - #include <linux/of_device.h> 17 + #include <linux/platform_device.h> 18 + #include <linux/property.h> 18 19 #include <linux/regmap.h> 19 20 #include <linux/seq_file.h> 20 21 #include <linux/slab.h> ··· 823 822 { 824 823 struct device *dev = &pdev->dev; 825 824 struct device_node *np = of_node_get(dev->of_node); 826 - const struct of_device_id *match; 827 825 struct resource *res; 828 826 struct ti_iodelay_device *iod; 829 827 int ret = 0; ··· 833 833 goto exit_out; 834 834 } 835 835 836 - match = of_match_device(ti_iodelay_of_match, dev); 837 - if (!match) { 838 - ret = -EINVAL; 839 - dev_err(dev, "No DATA match\n"); 840 - goto exit_out; 841 - } 842 - 843 836 iod = devm_kzalloc(dev, sizeof(*iod), GFP_KERNEL); 844 837 if (!iod) { 845 838 ret = -ENOMEM; 846 839 goto exit_out; 847 840 } 848 841 iod->dev = dev; 849 - iod->reg_data = match->data; 842 + iod->reg_data = device_get_match_data(dev); 843 + if (!iod->reg_data) { 844 + ret = -EINVAL; 845 + dev_err(dev, "No DATA match\n"); 846 + goto exit_out; 847 + } 850 848 851 849 /* So far We can assume there is only 1 bank of registers */ 852 850 iod->reg_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);