[PATCH 2/2] regulator: act8945a: get rid of redundant structure

From: Raag Jadav
Date: Mon Jun 05 2023 - 06:49:07 EST


Remove struct act8945a_pmic, as we no longer need drvdata.

Signed-off-by: Raag Jadav <raagjadav@xxxxxxxxx>
---
drivers/regulator/act8945a-regulator.c | 29 ++++++++------------------
1 file changed, 9 insertions(+), 20 deletions(-)

diff --git a/drivers/regulator/act8945a-regulator.c b/drivers/regulator/act8945a-regulator.c
index bd54d76efcbc..73504253acc9 100644
--- a/drivers/regulator/act8945a-regulator.c
+++ b/drivers/regulator/act8945a-regulator.c
@@ -67,10 +67,6 @@ enum {
ACT8945A_ID_LDO4,
};

-struct act8945a_pmic {
- struct regmap *regmap;
-};
-
static const struct linear_range act8945a_voltage_ranges[] = {
REGULATOR_LINEAR_RANGE(600000, 0, 23, 25000),
REGULATOR_LINEAR_RANGE(1200000, 24, 47, 50000),
@@ -301,17 +297,13 @@ static int act8945a_pmic_probe(struct platform_device *pdev)
{
struct regulator_config config = { };
const struct regulator_desc *regulators;
- struct act8945a_pmic *act8945a;
struct regulator_dev *rdev;
+ struct regmap *regmap;
int i, num_regulators;
bool voltage_select;

- act8945a = devm_kzalloc(&pdev->dev, sizeof(*act8945a), GFP_KERNEL);
- if (!act8945a)
- return -ENOMEM;
-
- act8945a->regmap = dev_get_regmap(pdev->dev.parent, NULL);
- if (!act8945a->regmap) {
+ regmap = dev_get_regmap(pdev->dev.parent, NULL);
+ if (!regmap) {
dev_err(&pdev->dev,
"could not retrieve regmap from parent device\n");
return -EINVAL;
@@ -330,7 +322,6 @@ static int act8945a_pmic_probe(struct platform_device *pdev)

config.dev = &pdev->dev;
config.dev->of_node = pdev->dev.parent->of_node;
- config.driver_data = act8945a;
for (i = 0; i < num_regulators; i++) {
rdev = devm_regulator_register(&pdev->dev, &regulators[i],
&config);
@@ -342,33 +333,31 @@ static int act8945a_pmic_probe(struct platform_device *pdev)
}
}

- platform_set_drvdata(pdev, act8945a);
-
/* Unlock expert registers. */
- return regmap_write(act8945a->regmap, ACT8945A_SYS_UNLK_REGS, 0xef);
+ return regmap_write(regmap, ACT8945A_SYS_UNLK_REGS, 0xef);
}

-static int __maybe_unused act8945a_suspend(struct device *pdev)
+static int __maybe_unused act8945a_suspend(struct device *dev)
{
- struct act8945a_pmic *act8945a = dev_get_drvdata(pdev);
+ struct regmap *regmap = dev_get_regmap(dev->parent, NULL);

/*
* Ask the PMIC to enter the suspend mode on the next PWRHLD
* transition.
*/
- return regmap_write(act8945a->regmap, ACT8945A_SYS_CTRL, 0x42);
+ return regmap_write(regmap, ACT8945A_SYS_CTRL, 0x42);
}

static SIMPLE_DEV_PM_OPS(act8945a_pm, act8945a_suspend, NULL);

static void act8945a_pmic_shutdown(struct platform_device *pdev)
{
- struct act8945a_pmic *act8945a = platform_get_drvdata(pdev);
+ struct regmap *regmap = dev_get_regmap(pdev->dev.parent, NULL);

/*
* Ask the PMIC to shutdown everything on the next PWRHLD transition.
*/
- regmap_write(act8945a->regmap, ACT8945A_SYS_CTRL, 0x0);
+ regmap_write(regmap, ACT8945A_SYS_CTRL, 0x0);
}

static struct platform_driver act8945a_pmic_driver = {
--
2.25.1