Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <broonie@kernel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Link: https://lore.kernel.org/r/20221020204251.108565-3-sebastian.reichel@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Sebastian Reichel and committed by
Mark Brown
647e5735 0b21b4dc

+12 -8
+12 -8
drivers/regulator/rk808-regulator.c
··· 14 14 15 15 #include <linux/delay.h> 16 16 #include <linux/gpio.h> 17 - #include <linux/i2c.h> 18 17 #include <linux/module.h> 19 18 #include <linux/of_device.h> 20 19 #include <linux/of_gpio.h> ··· 1285 1286 static int rk808_regulator_probe(struct platform_device *pdev) 1286 1287 { 1287 1288 struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent); 1288 - struct i2c_client *client = rk808->i2c; 1289 1289 struct regulator_config config = {}; 1290 1290 struct regulator_dev *rk808_rdev; 1291 1291 struct rk808_regulator_data *pdata; 1292 1292 const struct regulator_desc *regulators; 1293 + struct regmap *regmap; 1293 1294 int ret, i, nregulators; 1295 + 1296 + regmap = dev_get_regmap(pdev->dev.parent, NULL); 1297 + if (!regmap) 1298 + return -ENODEV; 1294 1299 1295 1300 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); 1296 1301 if (!pdata) 1297 1302 return -ENOMEM; 1298 1303 1299 - ret = rk808_regulator_dt_parse_pdata(&pdev->dev, &client->dev, 1300 - rk808->regmap, pdata); 1304 + ret = rk808_regulator_dt_parse_pdata(&pdev->dev, pdev->dev.parent, 1305 + regmap, pdata); 1301 1306 if (ret < 0) 1302 1307 return ret; 1303 1308 ··· 1329 1326 nregulators = RK818_NUM_REGULATORS; 1330 1327 break; 1331 1328 default: 1332 - dev_err(&client->dev, "unsupported RK8XX ID %lu\n", 1329 + dev_err(&pdev->dev, "unsupported RK8XX ID %lu\n", 1333 1330 rk808->variant); 1334 1331 return -EINVAL; 1335 1332 } 1336 1333 1337 - config.dev = &client->dev; 1334 + config.dev = &pdev->dev; 1335 + config.dev->of_node = pdev->dev.parent->of_node; 1338 1336 config.driver_data = pdata; 1339 - config.regmap = rk808->regmap; 1337 + config.regmap = regmap; 1340 1338 1341 1339 /* Instantiate the regulators */ 1342 1340 for (i = 0; i < nregulators; i++) { 1343 1341 rk808_rdev = devm_regulator_register(&pdev->dev, 1344 1342 &regulators[i], &config); 1345 1343 if (IS_ERR(rk808_rdev)) { 1346 - dev_err(&client->dev, 1344 + dev_err(&pdev->dev, 1347 1345 "failed to register %d regulator\n", i); 1348 1346 return PTR_ERR(rk808_rdev); 1349 1347 }