Skip to content

Commit 647e573

Browse files
srebroonie
authored andcommitted
regulator: rk808: reduce 'struct rk808' usage
Reduce usage of 'struct rk808' (driver data of the parent MFD), so that only the chip variant field is still being accessed directly. This allows restructuring the MFD driver to support SPI based PMICs. Acked-by: Mark Brown <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 0b21b4d commit 647e573

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

drivers/regulator/rk808-regulator.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#include <linux/delay.h>
1616
#include <linux/gpio.h>
17-
#include <linux/i2c.h>
1817
#include <linux/module.h>
1918
#include <linux/of_device.h>
2019
#include <linux/of_gpio.h>
@@ -1286,19 +1285,23 @@ static int rk808_regulator_dt_parse_pdata(struct device *dev,
12861285
static int rk808_regulator_probe(struct platform_device *pdev)
12871286
{
12881287
struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent);
1289-
struct i2c_client *client = rk808->i2c;
12901288
struct regulator_config config = {};
12911289
struct regulator_dev *rk808_rdev;
12921290
struct rk808_regulator_data *pdata;
12931291
const struct regulator_desc *regulators;
1292+
struct regmap *regmap;
12941293
int ret, i, nregulators;
12951294

1295+
regmap = dev_get_regmap(pdev->dev.parent, NULL);
1296+
if (!regmap)
1297+
return -ENODEV;
1298+
12961299
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
12971300
if (!pdata)
12981301
return -ENOMEM;
12991302

1300-
ret = rk808_regulator_dt_parse_pdata(&pdev->dev, &client->dev,
1301-
rk808->regmap, pdata);
1303+
ret = rk808_regulator_dt_parse_pdata(&pdev->dev, pdev->dev.parent,
1304+
regmap, pdata);
13021305
if (ret < 0)
13031306
return ret;
13041307

@@ -1326,21 +1329,22 @@ static int rk808_regulator_probe(struct platform_device *pdev)
13261329
nregulators = RK818_NUM_REGULATORS;
13271330
break;
13281331
default:
1329-
dev_err(&client->dev, "unsupported RK8XX ID %lu\n",
1332+
dev_err(&pdev->dev, "unsupported RK8XX ID %lu\n",
13301333
rk808->variant);
13311334
return -EINVAL;
13321335
}
13331336

1334-
config.dev = &client->dev;
1337+
config.dev = &pdev->dev;
1338+
config.dev->of_node = pdev->dev.parent->of_node;
13351339
config.driver_data = pdata;
1336-
config.regmap = rk808->regmap;
1340+
config.regmap = regmap;
13371341

13381342
/* Instantiate the regulators */
13391343
for (i = 0; i < nregulators; i++) {
13401344
rk808_rdev = devm_regulator_register(&pdev->dev,
13411345
&regulators[i], &config);
13421346
if (IS_ERR(rk808_rdev)) {
1343-
dev_err(&client->dev,
1347+
dev_err(&pdev->dev,
13441348
"failed to register %d regulator\n", i);
13451349
return PTR_ERR(rk808_rdev);
13461350
}

0 commit comments

Comments
 (0)