Skip to content

Commit 830fafc

Browse files
robherringlag-linaro
authored andcommitted
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 <[email protected]> Signed-off-by: Rob Herring <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 15d71e6 commit 830fafc

File tree

8 files changed

+26
-58
lines changed

8 files changed

+26
-58
lines changed

drivers/mfd/axp20x.c

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
#include <linux/mfd/axp20x.h>
2323
#include <linux/mfd/core.h>
2424
#include <linux/module.h>
25-
#include <linux/of_device.h>
25+
#include <linux/of.h>
26+
#include <linux/property.h>
2627
#include <linux/reboot.h>
2728
#include <linux/regmap.h>
2829
#include <linux/regulator/consumer.h>
@@ -1131,27 +1132,10 @@ static int axp20x_power_off(struct sys_off_data *data)
11311132
int axp20x_match_device(struct axp20x_dev *axp20x)
11321133
{
11331134
struct device *dev = axp20x->dev;
1134-
const struct acpi_device_id *acpi_id;
1135-
const struct of_device_id *of_id;
11361135
const struct mfd_cell *cells_no_irq = NULL;
11371136
int nr_cells_no_irq = 0;
11381137

1139-
if (dev->of_node) {
1140-
of_id = of_match_device(dev->driver->of_match_table, dev);
1141-
if (!of_id) {
1142-
dev_err(dev, "Unable to match OF ID\n");
1143-
return -ENODEV;
1144-
}
1145-
axp20x->variant = (long)of_id->data;
1146-
} else {
1147-
acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev);
1148-
if (!acpi_id || !acpi_id->driver_data) {
1149-
dev_err(dev, "Unable to match ACPI ID and data\n");
1150-
return -ENODEV;
1151-
}
1152-
axp20x->variant = (long)acpi_id->driver_data;
1153-
}
1154-
1138+
axp20x->variant = (long)device_get_match_data(dev);
11551139
switch (axp20x->variant) {
11561140
case AXP152_ID:
11571141
axp20x->nr_cells = ARRAY_SIZE(axp152_cells);

drivers/mfd/hi6421-pmic-core.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
#include <linux/mfd/core.h>
1616
#include <linux/mfd/hi6421-pmic.h>
1717
#include <linux/module.h>
18-
#include <linux/of_device.h>
18+
#include <linux/of.h>
1919
#include <linux/platform_device.h>
20+
#include <linux/property.h>
2021
#include <linux/regmap.h>
2122

2223
static const struct mfd_cell hi6421_devs[] = {
@@ -50,16 +51,12 @@ MODULE_DEVICE_TABLE(of, of_hi6421_pmic_match);
5051
static int hi6421_pmic_probe(struct platform_device *pdev)
5152
{
5253
struct hi6421_pmic *pmic;
53-
const struct of_device_id *id;
5454
const struct mfd_cell *subdevs;
5555
enum hi6421_type type;
5656
void __iomem *base;
5757
int n_subdevs, ret;
5858

59-
id = of_match_device(of_hi6421_pmic_match, &pdev->dev);
60-
if (!id)
61-
return -EINVAL;
62-
type = (uintptr_t)id->data;
59+
type = (uintptr_t)device_get_match_data(&pdev->dev);
6360

6461
pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL);
6562
if (!pmic)

drivers/mfd/mxs-lradc.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
#include <linux/mfd/mxs-lradc.h>
1717
#include <linux/module.h>
1818
#include <linux/of.h>
19-
#include <linux/of_device.h>
2019
#include <linux/platform_device.h>
20+
#include <linux/property.h>
2121
#include <linux/slab.h>
2222

2323
#define ADC_CELL 0
@@ -125,7 +125,6 @@ MODULE_DEVICE_TABLE(of, mxs_lradc_dt_ids);
125125

126126
static int mxs_lradc_probe(struct platform_device *pdev)
127127
{
128-
const struct of_device_id *of_id;
129128
struct device *dev = &pdev->dev;
130129
struct device_node *node = dev->of_node;
131130
struct mxs_lradc *lradc;
@@ -138,11 +137,7 @@ static int mxs_lradc_probe(struct platform_device *pdev)
138137
if (!lradc)
139138
return -ENOMEM;
140139

141-
of_id = of_match_device(mxs_lradc_dt_ids, &pdev->dev);
142-
if (!of_id)
143-
return -EINVAL;
144-
145-
lradc->soc = (uintptr_t)of_id->data;
140+
lradc->soc = (enum mxs_lradc_id)device_get_match_data(&pdev->dev);
146141

147142
lradc->clk = devm_clk_get(&pdev->dev, NULL);
148143
if (IS_ERR(lradc->clk)) {

drivers/mfd/qcom-spmi-pmic.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
#include <linux/gfp.h>
99
#include <linux/kernel.h>
1010
#include <linux/module.h>
11+
#include <linux/of.h>
12+
#include <linux/of_device.h>
13+
#include <linux/of_platform.h>
1114
#include <linux/spmi.h>
1215
#include <linux/types.h>
1316
#include <linux/regmap.h>
14-
#include <linux/of_platform.h>
1517
#include <soc/qcom/qcom-spmi-pmic.h>
1618

1719
#define PMIC_REV2 0x101
@@ -264,7 +266,7 @@ static int pmic_spmi_probe(struct spmi_device *sdev)
264266
if (!ctx)
265267
return -ENOMEM;
266268

267-
ctx->num_usids = (uintptr_t)of_device_get_match_data(&sdev->dev);
269+
ctx->num_usids = (uintptr_t)device_get_match_data(&sdev->dev);
268270

269271
/* Only the first slave id for a PMIC contains this information */
270272
if (sdev->usid % ctx->num_usids == 0) {

drivers/mfd/qcom_rpm.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#include <linux/module.h>
99
#include <linux/platform_device.h>
10+
#include <linux/property.h>
11+
#include <linux/of.h>
1012
#include <linux/of_platform.h>
1113
#include <linux/io.h>
1214
#include <linux/interrupt.h>
@@ -528,7 +530,6 @@ static irqreturn_t qcom_rpm_wakeup_interrupt(int irq, void *dev)
528530

529531
static int qcom_rpm_probe(struct platform_device *pdev)
530532
{
531-
const struct of_device_id *match;
532533
struct device_node *syscon_np;
533534
struct qcom_rpm *rpm;
534535
u32 fw_version[3];
@@ -570,10 +571,9 @@ static int qcom_rpm_probe(struct platform_device *pdev)
570571
if (irq_wakeup < 0)
571572
return irq_wakeup;
572573

573-
match = of_match_device(qcom_rpm_of_match, &pdev->dev);
574-
if (!match)
574+
rpm->data = device_get_match_data(&pdev->dev);
575+
if (!rpm->data)
575576
return -ENODEV;
576-
rpm->data = match->data;
577577

578578
rpm->status_regs = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
579579
if (IS_ERR(rpm->status_regs))

drivers/mfd/tps65910.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <linux/regmap.h>
2020
#include <linux/mfd/tps65910.h>
2121
#include <linux/of.h>
22-
#include <linux/of_device.h>
22+
#include <linux/property.h>
2323

2424
static const struct resource rtc_resources[] = {
2525
{
@@ -374,16 +374,9 @@ static struct tps65910_board *tps65910_parse_dt(struct i2c_client *client,
374374
struct device_node *np = client->dev.of_node;
375375
struct tps65910_board *board_info;
376376
unsigned int prop;
377-
const struct of_device_id *match;
378377
int ret;
379378

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);
387380

388381
board_info = devm_kzalloc(&client->dev, sizeof(*board_info),
389382
GFP_KERNEL);

drivers/mfd/twl4030-power.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
#include <linux/pm.h>
2828
#include <linux/mfd/twl.h>
2929
#include <linux/platform_device.h>
30+
#include <linux/property.h>
3031
#include <linux/of.h>
31-
#include <linux/of_device.h>
3232

3333
#include <asm/mach-types.h>
3434

@@ -883,7 +883,6 @@ static int twl4030_power_probe(struct platform_device *pdev)
883883
{
884884
const struct twl4030_power_data *pdata = dev_get_platdata(&pdev->dev);
885885
struct device_node *node = pdev->dev.of_node;
886-
const struct of_device_id *match;
887886
int err = 0;
888887
int err2 = 0;
889888
u8 val;
@@ -904,10 +903,8 @@ static int twl4030_power_probe(struct platform_device *pdev)
904903
return err;
905904
}
906905

907-
match = of_match_device(of_match_ptr(twl4030_power_of_match),
908-
&pdev->dev);
909-
if (match && match->data)
910-
pdata = match->data;
906+
if (node)
907+
pdata = device_get_match_data(&pdev->dev);
911908

912909
if (pdata) {
913910
err = twl4030_power_configure_scripts(pdata);

drivers/mfd/twl6030-irq.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
#include <linux/kthread.h>
2525
#include <linux/mfd/twl.h>
2626
#include <linux/platform_device.h>
27+
#include <linux/property.h>
2728
#include <linux/suspend.h>
2829
#include <linux/of.h>
2930
#include <linux/irqdomain.h>
30-
#include <linux/of_device.h>
3131

3232
#include "twl-core.h"
3333

@@ -368,10 +368,10 @@ int twl6030_init_irq(struct device *dev, int irq_num)
368368
int nr_irqs;
369369
int status;
370370
u8 mask[3];
371-
const struct of_device_id *of_id;
371+
const int *irq_tbl;
372372

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) {
375375
dev_err(dev, "Unknown TWL device model\n");
376376
return -EINVAL;
377377
}
@@ -409,7 +409,7 @@ int twl6030_init_irq(struct device *dev, int irq_num)
409409

410410
twl6030_irq->pm_nb.notifier_call = twl6030_irq_pm_notifier;
411411
atomic_set(&twl6030_irq->wakeirqs, 0);
412-
twl6030_irq->irq_mapping_tbl = of_id->data;
412+
twl6030_irq->irq_mapping_tbl = irq_tbl;
413413

414414
twl6030_irq->irq_domain =
415415
irq_domain_add_linear(node, nr_irqs,

0 commit comments

Comments
 (0)