mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-01 10:43:43 +00:00
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 <robh@kernel.org> Link: https://lore.kernel.org/r/20231017203442.2699322-1-robh@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
46537a8676
commit
8f7e17d847
@ -13,7 +13,6 @@
|
|||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/mutex.h>
|
#include <linux/mutex.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/of_device.h>
|
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <linux/regmap.h>
|
#include <linux/regmap.h>
|
||||||
#include <linux/regulator/driver.h>
|
#include <linux/regulator/driver.h>
|
||||||
@ -243,7 +242,6 @@ static int lochnagar_regulator_probe(struct platform_device *pdev)
|
|||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct lochnagar *lochnagar = dev_get_drvdata(dev->parent);
|
struct lochnagar *lochnagar = dev_get_drvdata(dev->parent);
|
||||||
struct regulator_config config = { };
|
struct regulator_config config = { };
|
||||||
const struct of_device_id *of_id;
|
|
||||||
const struct regulator_desc *desc;
|
const struct regulator_desc *desc;
|
||||||
struct regulator_dev *rdev;
|
struct regulator_dev *rdev;
|
||||||
int ret;
|
int ret;
|
||||||
@ -252,12 +250,10 @@ static int lochnagar_regulator_probe(struct platform_device *pdev)
|
|||||||
config.regmap = lochnagar->regmap;
|
config.regmap = lochnagar->regmap;
|
||||||
config.driver_data = lochnagar;
|
config.driver_data = lochnagar;
|
||||||
|
|
||||||
of_id = of_match_device(lochnagar_of_match, dev);
|
desc = device_get_match_data(dev);
|
||||||
if (!of_id)
|
if (!desc)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
desc = of_id->data;
|
|
||||||
|
|
||||||
rdev = devm_regulator_register(dev, desc, &config);
|
rdev = devm_regulator_register(dev, desc, &config);
|
||||||
if (IS_ERR(rdev)) {
|
if (IS_ERR(rdev)) {
|
||||||
ret = PTR_ERR(rdev);
|
ret = PTR_ERR(rdev);
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
#include <linux/regmap.h>
|
#include <linux/regmap.h>
|
||||||
#include <linux/mfd/palmas.h>
|
#include <linux/mfd/palmas.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/of_platform.h>
|
|
||||||
#include <linux/regulator/of_regulator.h>
|
#include <linux/regulator/of_regulator.h>
|
||||||
|
|
||||||
static const struct linear_range smps_low_ranges[] = {
|
static const struct linear_range smps_low_ranges[] = {
|
||||||
@ -1601,16 +1600,13 @@ static int palmas_regulators_probe(struct platform_device *pdev)
|
|||||||
struct regulator_config config = { };
|
struct regulator_config config = { };
|
||||||
struct palmas_pmic *pmic;
|
struct palmas_pmic *pmic;
|
||||||
const char *pdev_name;
|
const char *pdev_name;
|
||||||
const struct of_device_id *match;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
unsigned int reg;
|
unsigned int reg;
|
||||||
|
|
||||||
match = of_match_device(of_match_ptr(of_palmas_match_tbl), &pdev->dev);
|
driver_data = (struct palmas_pmic_driver_data *)device_get_match_data(&pdev->dev);
|
||||||
|
if (!driver_data)
|
||||||
if (!match)
|
|
||||||
return -ENODATA;
|
return -ENODATA;
|
||||||
|
|
||||||
driver_data = (struct palmas_pmic_driver_data *)match->data;
|
|
||||||
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
|
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
|
||||||
if (!pdata)
|
if (!pdata)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -764,7 +764,6 @@ static int qcom_labibb_regulator_probe(struct platform_device *pdev)
|
|||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct regulator_config cfg = {};
|
struct regulator_config cfg = {};
|
||||||
struct device_node *reg_node;
|
struct device_node *reg_node;
|
||||||
const struct of_device_id *match;
|
|
||||||
const struct labibb_regulator_data *reg_data;
|
const struct labibb_regulator_data *reg_data;
|
||||||
struct regmap *reg_regmap;
|
struct regmap *reg_regmap;
|
||||||
unsigned int type;
|
unsigned int type;
|
||||||
@ -776,11 +775,11 @@ static int qcom_labibb_regulator_probe(struct platform_device *pdev)
|
|||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
match = of_match_device(qcom_labibb_match, &pdev->dev);
|
reg_data = device_get_match_data(&pdev->dev);
|
||||||
if (!match)
|
if (!reg_data)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
for (reg_data = match->data; reg_data->name; reg_data++) {
|
for (; reg_data->name; reg_data++) {
|
||||||
char *sc_irq_name;
|
char *sc_irq_name;
|
||||||
int irq = 0;
|
int irq = 0;
|
||||||
|
|
||||||
|
@ -937,7 +937,6 @@ MODULE_DEVICE_TABLE(of, rpm_of_match);
|
|||||||
static int rpm_reg_probe(struct platform_device *pdev)
|
static int rpm_reg_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
const struct rpm_regulator_data *reg;
|
const struct rpm_regulator_data *reg;
|
||||||
const struct of_device_id *match;
|
|
||||||
struct regulator_config config = { };
|
struct regulator_config config = { };
|
||||||
struct regulator_dev *rdev;
|
struct regulator_dev *rdev;
|
||||||
struct qcom_rpm_reg *vreg;
|
struct qcom_rpm_reg *vreg;
|
||||||
@ -949,13 +948,13 @@ static int rpm_reg_probe(struct platform_device *pdev)
|
|||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
match = of_match_device(rpm_of_match, &pdev->dev);
|
reg = device_get_match_data(&pdev->dev);
|
||||||
if (!match) {
|
if (!reg) {
|
||||||
dev_err(&pdev->dev, "failed to match device\n");
|
dev_err(&pdev->dev, "failed to match device\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (reg = match->data; reg->name; reg++) {
|
for (; reg->name; reg++) {
|
||||||
vreg = devm_kmemdup(&pdev->dev, reg->template, sizeof(*vreg), GFP_KERNEL);
|
vreg = devm_kmemdup(&pdev->dev, reg->template, sizeof(*vreg), GFP_KERNEL);
|
||||||
if (!vreg)
|
if (!vreg)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -2468,7 +2468,6 @@ static int qcom_spmi_regulator_probe(struct platform_device *pdev)
|
|||||||
{
|
{
|
||||||
const struct spmi_regulator_data *reg;
|
const struct spmi_regulator_data *reg;
|
||||||
const struct spmi_voltage_range *range;
|
const struct spmi_voltage_range *range;
|
||||||
const struct of_device_id *match;
|
|
||||||
struct regulator_config config = { };
|
struct regulator_config config = { };
|
||||||
struct regulator_dev *rdev;
|
struct regulator_dev *rdev;
|
||||||
struct spmi_regulator *vreg;
|
struct spmi_regulator *vreg;
|
||||||
@ -2491,8 +2490,8 @@ static int qcom_spmi_regulator_probe(struct platform_device *pdev)
|
|||||||
if (!regmap)
|
if (!regmap)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
match = of_match_device(qcom_spmi_regulator_match, &pdev->dev);
|
reg = device_get_match_data(&pdev->dev);
|
||||||
if (!match)
|
if (!reg)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
if (of_find_property(node, "qcom,saw-reg", &lenp)) {
|
if (of_find_property(node, "qcom,saw-reg", &lenp)) {
|
||||||
@ -2503,7 +2502,7 @@ static int qcom_spmi_regulator_probe(struct platform_device *pdev)
|
|||||||
dev_err(dev, "ERROR reading SAW regmap\n");
|
dev_err(dev, "ERROR reading SAW regmap\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (reg = match->data; reg->name; reg++) {
|
for (; reg->name; reg++) {
|
||||||
|
|
||||||
if (saw_regmap) {
|
if (saw_regmap) {
|
||||||
reg_node = of_get_child_by_name(node, reg->name);
|
reg_node = of_get_child_by_name(node, reg->name);
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include <linux/mfd/syscon.h>
|
#include <linux/mfd/syscon.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/of_device.h>
|
#include <linux/of.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <linux/regmap.h>
|
#include <linux/regmap.h>
|
||||||
#include <linux/regulator/driver.h>
|
#include <linux/regulator/driver.h>
|
||||||
@ -83,8 +83,7 @@ static int stm32_booster_probe(struct platform_device *pdev)
|
|||||||
if (IS_ERR(regmap))
|
if (IS_ERR(regmap))
|
||||||
return PTR_ERR(regmap);
|
return PTR_ERR(regmap);
|
||||||
|
|
||||||
desc = (const struct regulator_desc *)
|
desc = device_get_match_data(dev);
|
||||||
of_match_device(dev->driver->of_match_table, dev)->data;
|
|
||||||
|
|
||||||
config.regmap = regmap;
|
config.regmap = regmap;
|
||||||
config.dev = dev;
|
config.dev = dev;
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/of_device.h>
|
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <linux/regulator/driver.h>
|
#include <linux/regulator/driver.h>
|
||||||
@ -688,7 +687,6 @@ MODULE_DEVICE_TABLE(of, ti_abb_of_match);
|
|||||||
static int ti_abb_probe(struct platform_device *pdev)
|
static int ti_abb_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
const struct of_device_id *match;
|
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
struct ti_abb *abb;
|
struct ti_abb *abb;
|
||||||
struct regulator_init_data *initdata = NULL;
|
struct regulator_init_data *initdata = NULL;
|
||||||
@ -699,21 +697,15 @@ static int ti_abb_probe(struct platform_device *pdev)
|
|||||||
char *pname;
|
char *pname;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
match = of_match_device(ti_abb_of_match, dev);
|
|
||||||
if (!match) {
|
|
||||||
/* We do not expect this to happen */
|
|
||||||
dev_err(dev, "%s: Unable to match device\n", __func__);
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
if (!match->data) {
|
|
||||||
dev_err(dev, "%s: Bad data in match\n", __func__);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
abb = devm_kzalloc(dev, sizeof(struct ti_abb), GFP_KERNEL);
|
abb = devm_kzalloc(dev, sizeof(struct ti_abb), GFP_KERNEL);
|
||||||
if (!abb)
|
if (!abb)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
abb->regs = match->data;
|
|
||||||
|
abb->regs = device_get_match_data(dev);
|
||||||
|
if (!abb->regs) {
|
||||||
|
dev_err(dev, "%s: Bad data in match\n", __func__);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Map ABB resources */
|
/* Map ABB resources */
|
||||||
if (abb->regs->setup_off || abb->regs->control_off) {
|
if (abb->regs->setup_off || abb->regs->control_off) {
|
||||||
@ -866,7 +858,7 @@ static struct platform_driver ti_abb_driver = {
|
|||||||
.driver = {
|
.driver = {
|
||||||
.name = "ti_abb",
|
.name = "ti_abb",
|
||||||
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
|
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
|
||||||
.of_match_table = of_match_ptr(ti_abb_of_match),
|
.of_match_table = ti_abb_of_match,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
module_platform_driver(ti_abb_driver);
|
module_platform_driver(ti_abb_driver);
|
||||||
|
Loading…
Reference in New Issue
Block a user