Commit 5111c931 authored by Sebastian Reichel's avatar Sebastian Reichel Committed by Mark Brown

regulator: rk808: cleanup parent device usage

By overridering the device's of_node a bit earlier we can
get the GPIOs and any other DT properties from our own
device instead of relying on the parent device.
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
Link: https://lore.kernel.org/r/20230504173618.142075-13-sebastian.reichel@collabora.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 1b9e86d4
...@@ -1245,20 +1245,19 @@ static const struct regulator_desc rk818_reg[] = { ...@@ -1245,20 +1245,19 @@ static const struct regulator_desc rk818_reg[] = {
}; };
static int rk808_regulator_dt_parse_pdata(struct device *dev, static int rk808_regulator_dt_parse_pdata(struct device *dev,
struct device *client_dev,
struct regmap *map, struct regmap *map,
struct rk808_regulator_data *pdata) struct rk808_regulator_data *pdata)
{ {
struct device_node *np; struct device_node *np;
int tmp, ret = 0, i; int tmp, ret = 0, i;
np = of_get_child_by_name(client_dev->of_node, "regulators"); np = of_get_child_by_name(dev->of_node, "regulators");
if (!np) if (!np)
return -ENXIO; return -ENXIO;
for (i = 0; i < ARRAY_SIZE(pdata->dvs_gpio); i++) { for (i = 0; i < ARRAY_SIZE(pdata->dvs_gpio); i++) {
pdata->dvs_gpio[i] = pdata->dvs_gpio[i] =
devm_gpiod_get_index_optional(client_dev, "dvs", i, devm_gpiod_get_index_optional(dev, "dvs", i,
GPIOD_OUT_LOW); GPIOD_OUT_LOW);
if (IS_ERR(pdata->dvs_gpio[i])) { if (IS_ERR(pdata->dvs_gpio[i])) {
ret = PTR_ERR(pdata->dvs_gpio[i]); ret = PTR_ERR(pdata->dvs_gpio[i]);
...@@ -1292,6 +1291,9 @@ static int rk808_regulator_probe(struct platform_device *pdev) ...@@ -1292,6 +1291,9 @@ static int rk808_regulator_probe(struct platform_device *pdev)
struct regmap *regmap; struct regmap *regmap;
int ret, i, nregulators; int ret, i, nregulators;
pdev->dev.of_node = pdev->dev.parent->of_node;
pdev->dev.of_node_reused = true;
regmap = dev_get_regmap(pdev->dev.parent, NULL); regmap = dev_get_regmap(pdev->dev.parent, NULL);
if (!regmap) if (!regmap)
return -ENODEV; return -ENODEV;
...@@ -1300,8 +1302,7 @@ static int rk808_regulator_probe(struct platform_device *pdev) ...@@ -1300,8 +1302,7 @@ static int rk808_regulator_probe(struct platform_device *pdev)
if (!pdata) if (!pdata)
return -ENOMEM; return -ENOMEM;
ret = rk808_regulator_dt_parse_pdata(&pdev->dev, pdev->dev.parent, ret = rk808_regulator_dt_parse_pdata(&pdev->dev, regmap, pdata);
regmap, pdata);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1335,8 +1336,6 @@ static int rk808_regulator_probe(struct platform_device *pdev) ...@@ -1335,8 +1336,6 @@ static int rk808_regulator_probe(struct platform_device *pdev)
} }
config.dev = &pdev->dev; config.dev = &pdev->dev;
config.dev->of_node = pdev->dev.parent->of_node;
config.dev->of_node_reused = true;
config.driver_data = pdata; config.driver_data = pdata;
config.regmap = regmap; config.regmap = regmap;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment