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

mfd: Use device_get_match_data() in a bunch of drivers

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.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20231017203612.2701060-1-robh@kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Rob Herring and committed by
Lee Jones
830fafce 15d71e67

+26 -58
+3 -19
drivers/mfd/axp20x.c
··· 22 22 #include <linux/mfd/axp20x.h> 23 23 #include <linux/mfd/core.h> 24 24 #include <linux/module.h> 25 - #include <linux/of_device.h> 25 + #include <linux/of.h> 26 + #include <linux/property.h> 26 27 #include <linux/reboot.h> 27 28 #include <linux/regmap.h> 28 29 #include <linux/regulator/consumer.h> ··· 1132 1131 int axp20x_match_device(struct axp20x_dev *axp20x) 1133 1132 { 1134 1133 struct device *dev = axp20x->dev; 1135 - const struct acpi_device_id *acpi_id; 1136 - const struct of_device_id *of_id; 1137 1134 const struct mfd_cell *cells_no_irq = NULL; 1138 1135 int nr_cells_no_irq = 0; 1139 1136 1140 - if (dev->of_node) { 1141 - of_id = of_match_device(dev->driver->of_match_table, dev); 1142 - if (!of_id) { 1143 - dev_err(dev, "Unable to match OF ID\n"); 1144 - return -ENODEV; 1145 - } 1146 - axp20x->variant = (long)of_id->data; 1147 - } else { 1148 - acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev); 1149 - if (!acpi_id || !acpi_id->driver_data) { 1150 - dev_err(dev, "Unable to match ACPI ID and data\n"); 1151 - return -ENODEV; 1152 - } 1153 - axp20x->variant = (long)acpi_id->driver_data; 1154 - } 1155 - 1137 + axp20x->variant = (long)device_get_match_data(dev); 1156 1138 switch (axp20x->variant) { 1157 1139 case AXP152_ID: 1158 1140 axp20x->nr_cells = ARRAY_SIZE(axp152_cells);
+3 -6
drivers/mfd/hi6421-pmic-core.c
··· 15 15 #include <linux/mfd/core.h> 16 16 #include <linux/mfd/hi6421-pmic.h> 17 17 #include <linux/module.h> 18 - #include <linux/of_device.h> 18 + #include <linux/of.h> 19 19 #include <linux/platform_device.h> 20 + #include <linux/property.h> 20 21 #include <linux/regmap.h> 21 22 22 23 static const struct mfd_cell hi6421_devs[] = { ··· 51 50 static int hi6421_pmic_probe(struct platform_device *pdev) 52 51 { 53 52 struct hi6421_pmic *pmic; 54 - const struct of_device_id *id; 55 53 const struct mfd_cell *subdevs; 56 54 enum hi6421_type type; 57 55 void __iomem *base; 58 56 int n_subdevs, ret; 59 57 60 - id = of_match_device(of_hi6421_pmic_match, &pdev->dev); 61 - if (!id) 62 - return -EINVAL; 63 - type = (uintptr_t)id->data; 58 + type = (uintptr_t)device_get_match_data(&pdev->dev); 64 59 65 60 pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL); 66 61 if (!pmic)
+2 -7
drivers/mfd/mxs-lradc.c
··· 16 16 #include <linux/mfd/mxs-lradc.h> 17 17 #include <linux/module.h> 18 18 #include <linux/of.h> 19 - #include <linux/of_device.h> 20 19 #include <linux/platform_device.h> 20 + #include <linux/property.h> 21 21 #include <linux/slab.h> 22 22 23 23 #define ADC_CELL 0 ··· 125 125 126 126 static int mxs_lradc_probe(struct platform_device *pdev) 127 127 { 128 - const struct of_device_id *of_id; 129 128 struct device *dev = &pdev->dev; 130 129 struct device_node *node = dev->of_node; 131 130 struct mxs_lradc *lradc; ··· 137 138 if (!lradc) 138 139 return -ENOMEM; 139 140 140 - of_id = of_match_device(mxs_lradc_dt_ids, &pdev->dev); 141 - if (!of_id) 142 - return -EINVAL; 143 - 144 - lradc->soc = (uintptr_t)of_id->data; 141 + lradc->soc = (enum mxs_lradc_id)device_get_match_data(&pdev->dev); 145 142 146 143 lradc->clk = devm_clk_get(&pdev->dev, NULL); 147 144 if (IS_ERR(lradc->clk)) {
+4 -2
drivers/mfd/qcom-spmi-pmic.c
··· 8 8 #include <linux/gfp.h> 9 9 #include <linux/kernel.h> 10 10 #include <linux/module.h> 11 + #include <linux/of.h> 12 + #include <linux/of_device.h> 13 + #include <linux/of_platform.h> 11 14 #include <linux/spmi.h> 12 15 #include <linux/types.h> 13 16 #include <linux/regmap.h> 14 - #include <linux/of_platform.h> 15 17 #include <soc/qcom/qcom-spmi-pmic.h> 16 18 17 19 #define PMIC_REV2 0x101 ··· 266 264 if (!ctx) 267 265 return -ENOMEM; 268 266 269 - ctx->num_usids = (uintptr_t)of_device_get_match_data(&sdev->dev); 267 + ctx->num_usids = (uintptr_t)device_get_match_data(&sdev->dev); 270 268 271 269 /* Only the first slave id for a PMIC contains this information */ 272 270 if (sdev->usid % ctx->num_usids == 0) {
+4 -4
drivers/mfd/qcom_rpm.c
··· 7 7 8 8 #include <linux/module.h> 9 9 #include <linux/platform_device.h> 10 + #include <linux/property.h> 11 + #include <linux/of.h> 10 12 #include <linux/of_platform.h> 11 13 #include <linux/io.h> 12 14 #include <linux/interrupt.h> ··· 530 528 531 529 static int qcom_rpm_probe(struct platform_device *pdev) 532 530 { 533 - const struct of_device_id *match; 534 531 struct device_node *syscon_np; 535 532 struct qcom_rpm *rpm; 536 533 u32 fw_version[3]; ··· 571 570 if (irq_wakeup < 0) 572 571 return irq_wakeup; 573 572 574 - match = of_match_device(qcom_rpm_of_match, &pdev->dev); 575 - if (!match) 573 + rpm->data = device_get_match_data(&pdev->dev); 574 + if (!rpm->data) 576 575 return -ENODEV; 577 - rpm->data = match->data; 578 576 579 577 rpm->status_regs = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); 580 578 if (IS_ERR(rpm->status_regs))
+2 -9
drivers/mfd/tps65910.c
··· 19 19 #include <linux/regmap.h> 20 20 #include <linux/mfd/tps65910.h> 21 21 #include <linux/of.h> 22 - #include <linux/of_device.h> 22 + #include <linux/property.h> 23 23 24 24 static const struct resource rtc_resources[] = { 25 25 { ··· 374 374 struct device_node *np = client->dev.of_node; 375 375 struct tps65910_board *board_info; 376 376 unsigned int prop; 377 - const struct of_device_id *match; 378 377 int ret; 379 378 380 - match = of_match_device(tps65910_of_match, &client->dev); 381 - if (!match) { 382 - dev_err(&client->dev, "Failed to find matching dt id\n"); 383 - return NULL; 384 - } 385 - 386 - *chip_id = (unsigned long)match->data; 379 + *chip_id = (unsigned long)device_get_match_data(&client->dev); 387 380 388 381 board_info = devm_kzalloc(&client->dev, sizeof(*board_info), 389 382 GFP_KERNEL);
+3 -6
drivers/mfd/twl4030-power.c
··· 27 27 #include <linux/pm.h> 28 28 #include <linux/mfd/twl.h> 29 29 #include <linux/platform_device.h> 30 + #include <linux/property.h> 30 31 #include <linux/of.h> 31 - #include <linux/of_device.h> 32 32 33 33 #include <asm/mach-types.h> 34 34 ··· 883 883 { 884 884 const struct twl4030_power_data *pdata = dev_get_platdata(&pdev->dev); 885 885 struct device_node *node = pdev->dev.of_node; 886 - const struct of_device_id *match; 887 886 int err = 0; 888 887 int err2 = 0; 889 888 u8 val; ··· 903 904 return err; 904 905 } 905 906 906 - match = of_match_device(of_match_ptr(twl4030_power_of_match), 907 - &pdev->dev); 908 - if (match && match->data) 909 - pdata = match->data; 907 + if (node) 908 + pdata = device_get_match_data(&pdev->dev); 910 909 911 910 if (pdata) { 912 911 err = twl4030_power_configure_scripts(pdata);
+5 -5
drivers/mfd/twl6030-irq.c
··· 24 24 #include <linux/kthread.h> 25 25 #include <linux/mfd/twl.h> 26 26 #include <linux/platform_device.h> 27 + #include <linux/property.h> 27 28 #include <linux/suspend.h> 28 29 #include <linux/of.h> 29 30 #include <linux/irqdomain.h> 30 - #include <linux/of_device.h> 31 31 32 32 #include "twl-core.h" 33 33 ··· 368 368 int nr_irqs; 369 369 int status; 370 370 u8 mask[3]; 371 - const struct of_device_id *of_id; 371 + const int *irq_tbl; 372 372 373 - of_id = of_match_device(twl6030_of_match, dev); 374 - if (!of_id || !of_id->data) { 373 + irq_tbl = device_get_match_data(dev); 374 + if (!irq_tbl) { 375 375 dev_err(dev, "Unknown TWL device model\n"); 376 376 return -EINVAL; 377 377 } ··· 409 409 410 410 twl6030_irq->pm_nb.notifier_call = twl6030_irq_pm_notifier; 411 411 atomic_set(&twl6030_irq->wakeirqs, 0); 412 - twl6030_irq->irq_mapping_tbl = of_id->data; 412 + twl6030_irq->irq_mapping_tbl = irq_tbl; 413 413 414 414 twl6030_irq->irq_domain = 415 415 irq_domain_add_linear(node, nr_irqs,