Skip to content

Commit 8f7e17d

Browse files
robherringbroonie
authored andcommitted
regulator: 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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 46537a8 commit 8f7e17d

File tree

7 files changed

+22
-42
lines changed

7 files changed

+22
-42
lines changed

drivers/regulator/lochnagar-regulator.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <linux/module.h>
1414
#include <linux/mutex.h>
1515
#include <linux/of.h>
16-
#include <linux/of_device.h>
1716
#include <linux/platform_device.h>
1817
#include <linux/regmap.h>
1918
#include <linux/regulator/driver.h>
@@ -243,7 +242,6 @@ static int lochnagar_regulator_probe(struct platform_device *pdev)
243242
struct device *dev = &pdev->dev;
244243
struct lochnagar *lochnagar = dev_get_drvdata(dev->parent);
245244
struct regulator_config config = { };
246-
const struct of_device_id *of_id;
247245
const struct regulator_desc *desc;
248246
struct regulator_dev *rdev;
249247
int ret;
@@ -252,12 +250,10 @@ static int lochnagar_regulator_probe(struct platform_device *pdev)
252250
config.regmap = lochnagar->regmap;
253251
config.driver_data = lochnagar;
254252

255-
of_id = of_match_device(lochnagar_of_match, dev);
256-
if (!of_id)
253+
desc = device_get_match_data(dev);
254+
if (!desc)
257255
return -EINVAL;
258256

259-
desc = of_id->data;
260-
261257
rdev = devm_regulator_register(dev, desc, &config);
262258
if (IS_ERR(rdev)) {
263259
ret = PTR_ERR(rdev);

drivers/regulator/palmas-regulator.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <linux/regmap.h>
2020
#include <linux/mfd/palmas.h>
2121
#include <linux/of.h>
22-
#include <linux/of_platform.h>
2322
#include <linux/regulator/of_regulator.h>
2423

2524
static const struct linear_range smps_low_ranges[] = {
@@ -1601,16 +1600,13 @@ static int palmas_regulators_probe(struct platform_device *pdev)
16011600
struct regulator_config config = { };
16021601
struct palmas_pmic *pmic;
16031602
const char *pdev_name;
1604-
const struct of_device_id *match;
16051603
int ret = 0;
16061604
unsigned int reg;
16071605

1608-
match = of_match_device(of_match_ptr(of_palmas_match_tbl), &pdev->dev);
1609-
1610-
if (!match)
1606+
driver_data = (struct palmas_pmic_driver_data *)device_get_match_data(&pdev->dev);
1607+
if (!driver_data)
16111608
return -ENODATA;
16121609

1613-
driver_data = (struct palmas_pmic_driver_data *)match->data;
16141610
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
16151611
if (!pdata)
16161612
return -ENOMEM;

drivers/regulator/qcom-labibb-regulator.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,6 @@ static int qcom_labibb_regulator_probe(struct platform_device *pdev)
764764
struct device *dev = &pdev->dev;
765765
struct regulator_config cfg = {};
766766
struct device_node *reg_node;
767-
const struct of_device_id *match;
768767
const struct labibb_regulator_data *reg_data;
769768
struct regmap *reg_regmap;
770769
unsigned int type;
@@ -776,11 +775,11 @@ static int qcom_labibb_regulator_probe(struct platform_device *pdev)
776775
return -ENODEV;
777776
}
778777

779-
match = of_match_device(qcom_labibb_match, &pdev->dev);
780-
if (!match)
778+
reg_data = device_get_match_data(&pdev->dev);
779+
if (!reg_data)
781780
return -ENODEV;
782781

783-
for (reg_data = match->data; reg_data->name; reg_data++) {
782+
for (; reg_data->name; reg_data++) {
784783
char *sc_irq_name;
785784
int irq = 0;
786785

drivers/regulator/qcom_rpm-regulator.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,6 @@ MODULE_DEVICE_TABLE(of, rpm_of_match);
937937
static int rpm_reg_probe(struct platform_device *pdev)
938938
{
939939
const struct rpm_regulator_data *reg;
940-
const struct of_device_id *match;
941940
struct regulator_config config = { };
942941
struct regulator_dev *rdev;
943942
struct qcom_rpm_reg *vreg;
@@ -949,13 +948,13 @@ static int rpm_reg_probe(struct platform_device *pdev)
949948
return -ENODEV;
950949
}
951950

952-
match = of_match_device(rpm_of_match, &pdev->dev);
953-
if (!match) {
951+
reg = device_get_match_data(&pdev->dev);
952+
if (!reg) {
954953
dev_err(&pdev->dev, "failed to match device\n");
955954
return -ENODEV;
956955
}
957956

958-
for (reg = match->data; reg->name; reg++) {
957+
for (; reg->name; reg++) {
959958
vreg = devm_kmemdup(&pdev->dev, reg->template, sizeof(*vreg), GFP_KERNEL);
960959
if (!vreg)
961960
return -ENOMEM;

drivers/regulator/qcom_spmi-regulator.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2468,7 +2468,6 @@ static int qcom_spmi_regulator_probe(struct platform_device *pdev)
24682468
{
24692469
const struct spmi_regulator_data *reg;
24702470
const struct spmi_voltage_range *range;
2471-
const struct of_device_id *match;
24722471
struct regulator_config config = { };
24732472
struct regulator_dev *rdev;
24742473
struct spmi_regulator *vreg;
@@ -2491,8 +2490,8 @@ static int qcom_spmi_regulator_probe(struct platform_device *pdev)
24912490
if (!regmap)
24922491
return -ENODEV;
24932492

2494-
match = of_match_device(qcom_spmi_regulator_match, &pdev->dev);
2495-
if (!match)
2493+
reg = device_get_match_data(&pdev->dev);
2494+
if (!reg)
24962495
return -ENODEV;
24972496

24982497
if (of_find_property(node, "qcom,saw-reg", &lenp)) {
@@ -2503,7 +2502,7 @@ static int qcom_spmi_regulator_probe(struct platform_device *pdev)
25032502
dev_err(dev, "ERROR reading SAW regmap\n");
25042503
}
25052504

2506-
for (reg = match->data; reg->name; reg++) {
2505+
for (; reg->name; reg++) {
25072506

25082507
if (saw_regmap) {
25092508
reg_node = of_get_child_by_name(node, reg->name);

drivers/regulator/stm32-booster.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include <linux/mfd/syscon.h>
66
#include <linux/module.h>
7-
#include <linux/of_device.h>
7+
#include <linux/of.h>
88
#include <linux/platform_device.h>
99
#include <linux/regmap.h>
1010
#include <linux/regulator/driver.h>
@@ -83,8 +83,7 @@ static int stm32_booster_probe(struct platform_device *pdev)
8383
if (IS_ERR(regmap))
8484
return PTR_ERR(regmap);
8585

86-
desc = (const struct regulator_desc *)
87-
of_match_device(dev->driver->of_match_table, dev)->data;
86+
desc = device_get_match_data(dev);
8887

8988
config.regmap = regmap;
9089
config.dev = dev;

drivers/regulator/ti-abb-regulator.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <linux/err.h>
1515
#include <linux/io.h>
1616
#include <linux/module.h>
17-
#include <linux/of_device.h>
1817
#include <linux/of.h>
1918
#include <linux/platform_device.h>
2019
#include <linux/regulator/driver.h>
@@ -688,7 +687,6 @@ MODULE_DEVICE_TABLE(of, ti_abb_of_match);
688687
static int ti_abb_probe(struct platform_device *pdev)
689688
{
690689
struct device *dev = &pdev->dev;
691-
const struct of_device_id *match;
692690
struct resource *res;
693691
struct ti_abb *abb;
694692
struct regulator_init_data *initdata = NULL;
@@ -699,21 +697,15 @@ static int ti_abb_probe(struct platform_device *pdev)
699697
char *pname;
700698
int ret = 0;
701699

702-
match = of_match_device(ti_abb_of_match, dev);
703-
if (!match) {
704-
/* We do not expect this to happen */
705-
dev_err(dev, "%s: Unable to match device\n", __func__);
706-
return -ENODEV;
707-
}
708-
if (!match->data) {
709-
dev_err(dev, "%s: Bad data in match\n", __func__);
710-
return -EINVAL;
711-
}
712-
713700
abb = devm_kzalloc(dev, sizeof(struct ti_abb), GFP_KERNEL);
714701
if (!abb)
715702
return -ENOMEM;
716-
abb->regs = match->data;
703+
704+
abb->regs = device_get_match_data(dev);
705+
if (!abb->regs) {
706+
dev_err(dev, "%s: Bad data in match\n", __func__);
707+
return -EINVAL;
708+
}
717709

718710
/* Map ABB resources */
719711
if (abb->regs->setup_off || abb->regs->control_off) {
@@ -866,7 +858,7 @@ static struct platform_driver ti_abb_driver = {
866858
.driver = {
867859
.name = "ti_abb",
868860
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
869-
.of_match_table = of_match_ptr(ti_abb_of_match),
861+
.of_match_table = ti_abb_of_match,
870862
},
871863
};
872864
module_platform_driver(ti_abb_driver);

0 commit comments

Comments
 (0)