[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220908003107.220143-5-sebastian.reichel@collabora.com>
Date: Thu, 8 Sep 2022 02:30:58 +0200
From: Sebastian Reichel <sebastian.reichel@...labora.com>
To: Heiko Stuebner <heiko@...ech.de>, Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Lee Jones <lee@...nel.org>
Cc: Michael Turquette <mturquette@...libre.com>,
Stephen Boyd <sboyd@...nel.org>,
Linus Walleij <linus.walleij@...aro.org>,
Mark Brown <broonie@...nel.org>,
Liam Girdwood <lgirdwood@...il.com>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
Alessandro Zummo <a.zummo@...ertech.it>,
linux-rockchip@...ts.infradead.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org,
Sebastian Reichel <sebastian.reichel@...labora.com>,
kernel@...labora.com
Subject: [PATCHv2 04/13] 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@...nel.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@...labora.com>
---
drivers/regulator/rk808-regulator.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/drivers/regulator/rk808-regulator.c b/drivers/regulator/rk808-regulator.c
index 127dc2e2e690..ce9c64cadeba 100644
--- a/drivers/regulator/rk808-regulator.c
+++ b/drivers/regulator/rk808-regulator.c
@@ -14,7 +14,6 @@
#include <linux/delay.h>
#include <linux/gpio.h>
-#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/of_gpio.h>
@@ -1286,19 +1285,23 @@ static int rk808_regulator_dt_parse_pdata(struct device *dev,
static int rk808_regulator_probe(struct platform_device *pdev)
{
struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent);
- struct i2c_client *client = rk808->i2c;
struct regulator_config config = {};
struct regulator_dev *rk808_rdev;
struct rk808_regulator_data *pdata;
const struct regulator_desc *regulators;
+ struct regmap *regmap;
int ret, i, nregulators;
+ regmap = dev_get_regmap(pdev->dev.parent, NULL);
+ if (!regmap)
+ return -ENODEV;
+
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return -ENOMEM;
- ret = rk808_regulator_dt_parse_pdata(&pdev->dev, &client->dev,
- rk808->regmap, pdata);
+ ret = rk808_regulator_dt_parse_pdata(&pdev->dev, pdev->dev.parent,
+ regmap, pdata);
if (ret < 0)
return ret;
@@ -1326,21 +1329,22 @@ static int rk808_regulator_probe(struct platform_device *pdev)
nregulators = RK818_NUM_REGULATORS;
break;
default:
- dev_err(&client->dev, "unsupported RK8XX ID %lu\n",
+ dev_err(&pdev->dev, "unsupported RK8XX ID %lu\n",
rk808->variant);
return -EINVAL;
}
- config.dev = &client->dev;
+ config.dev = &pdev->dev;
+ config.dev->of_node = pdev->dev.parent->of_node;
config.driver_data = pdata;
- config.regmap = rk808->regmap;
+ config.regmap = regmap;
/* Instantiate the regulators */
for (i = 0; i < nregulators; i++) {
rk808_rdev = devm_regulator_register(&pdev->dev,
®ulators[i], &config);
if (IS_ERR(rk808_rdev)) {
- dev_err(&client->dev,
+ dev_err(&pdev->dev,
"failed to register %d regulator\n", i);
return PTR_ERR(rk808_rdev);
}
--
2.35.1
Powered by blists - more mailing lists