Skip to content

Commit 5111c93

Browse files
srebroonie
authored andcommitted
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: Sebastian Reichel <sebastian.reichel@collabora.com> Link: https://lore.kernel.org/r/20230504173618.142075-13-sebastian.reichel@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 1b9e86d commit 5111c93

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

drivers/regulator/rk808-regulator.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,20 +1245,19 @@ static const struct regulator_desc rk818_reg[] = {
12451245
};
12461246

12471247
static int rk808_regulator_dt_parse_pdata(struct device *dev,
1248-
struct device *client_dev,
12491248
struct regmap *map,
12501249
struct rk808_regulator_data *pdata)
12511250
{
12521251
struct device_node *np;
12531252
int tmp, ret = 0, i;
12541253

1255-
np = of_get_child_by_name(client_dev->of_node, "regulators");
1254+
np = of_get_child_by_name(dev->of_node, "regulators");
12561255
if (!np)
12571256
return -ENXIO;
12581257

12591258
for (i = 0; i < ARRAY_SIZE(pdata->dvs_gpio); i++) {
12601259
pdata->dvs_gpio[i] =
1261-
devm_gpiod_get_index_optional(client_dev, "dvs", i,
1260+
devm_gpiod_get_index_optional(dev, "dvs", i,
12621261
GPIOD_OUT_LOW);
12631262
if (IS_ERR(pdata->dvs_gpio[i])) {
12641263
ret = PTR_ERR(pdata->dvs_gpio[i]);
@@ -1292,6 +1291,9 @@ static int rk808_regulator_probe(struct platform_device *pdev)
12921291
struct regmap *regmap;
12931292
int ret, i, nregulators;
12941293

1294+
pdev->dev.of_node = pdev->dev.parent->of_node;
1295+
pdev->dev.of_node_reused = true;
1296+
12951297
regmap = dev_get_regmap(pdev->dev.parent, NULL);
12961298
if (!regmap)
12971299
return -ENODEV;
@@ -1300,8 +1302,7 @@ static int rk808_regulator_probe(struct platform_device *pdev)
13001302
if (!pdata)
13011303
return -ENOMEM;
13021304

1303-
ret = rk808_regulator_dt_parse_pdata(&pdev->dev, pdev->dev.parent,
1304-
regmap, pdata);
1305+
ret = rk808_regulator_dt_parse_pdata(&pdev->dev, regmap, pdata);
13051306
if (ret < 0)
13061307
return ret;
13071308

@@ -1335,8 +1336,6 @@ static int rk808_regulator_probe(struct platform_device *pdev)
13351336
}
13361337

13371338
config.dev = &pdev->dev;
1338-
config.dev->of_node = pdev->dev.parent->of_node;
1339-
config.dev->of_node_reused = true;
13401339
config.driver_data = pdata;
13411340
config.regmap = regmap;
13421341

0 commit comments

Comments
 (0)