diff options
author | Axel Lin <axel.lin@ingics.com> | 2021-06-07 22:30:02 +0800 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2021-06-08 13:37:46 +0100 |
commit | 0ea461b4f229739345870a086aa4647a16ff42ff (patch) | |
tree | 0738a786190a9dcd35b1c72d47140a9ef27d0faa | |
parent | ba6622c43381e7045f8bc5438089ae53054fdf83 (diff) |
regulator: bd71815: Get rid of struct bd71815_pmic
The content of bd71815_regulators is never changed, no need to duplicate
it, thus remove descs[BD71815_REGULATOR_CNT].
The *regmap, *dev and *rdev[BD71815_REGULATOR_CNT] are not really needed.
The *gps is unused.
Thus the struct bd71815_pmic can be removed.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Reviewed-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Link: https://lore.kernel.org/r/20210607143002.1600017-1-axel.lin@ingics.com
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/regulator/bd71815-regulator.c | 57 |
1 files changed, 19 insertions, 38 deletions
diff --git a/drivers/regulator/bd71815-regulator.c b/drivers/regulator/bd71815-regulator.c index 4dd21ac24ddf..16edd9062ca9 100644 --- a/drivers/regulator/bd71815-regulator.c +++ b/drivers/regulator/bd71815-regulator.c @@ -28,14 +28,6 @@ struct bd71815_regulator { const struct rohm_dvs_config *dvs; }; -struct bd71815_pmic { - struct bd71815_regulator descs[BD71815_REGULATOR_CNT]; - struct regmap *regmap; - struct device *dev; - struct gpio_descs *gps; - struct regulator_dev *rdev[BD71815_REGULATOR_CNT]; -}; - static const int bd7181x_wled_currents[] = { 10, 20, 30, 50, 70, 100, 200, 300, 500, 700, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, @@ -302,14 +294,13 @@ static int bd7181x_led_set_current_limit(struct regulator_dev *rdev, static int bd7181x_buck12_get_voltage_sel(struct regulator_dev *rdev) { - struct bd71815_pmic *pmic = rdev_get_drvdata(rdev); int rid = rdev_get_id(rdev); int ret, regh, regl, val; regh = BD71815_REG_BUCK1_VOLT_H + rid * 0x2; regl = BD71815_REG_BUCK1_VOLT_L + rid * 0x2; - ret = regmap_read(pmic->regmap, regh, &val); + ret = regmap_read(rdev->regmap, regh, &val); if (ret) return ret; @@ -321,7 +312,7 @@ static int bd7181x_buck12_get_voltage_sel(struct regulator_dev *rdev) * by BD71815_BUCK_DVSSEL bit */ if ((!(val & BD71815_BUCK_STBY_DVS)) && (!(val & BD71815_BUCK_DVSSEL))) - ret = regmap_read(pmic->regmap, regl, &val); + ret = regmap_read(rdev->regmap, regl, &val); if (ret) return ret; @@ -335,14 +326,13 @@ static int bd7181x_buck12_get_voltage_sel(struct regulator_dev *rdev) static int bd7181x_buck12_set_voltage_sel(struct regulator_dev *rdev, unsigned int sel) { - struct bd71815_pmic *pmic = rdev_get_drvdata(rdev); int rid = rdev_get_id(rdev); int ret, val, reg, regh, regl; regh = BD71815_REG_BUCK1_VOLT_H + rid*0x2; regl = BD71815_REG_BUCK1_VOLT_L + rid*0x2; - ret = regmap_read(pmic->regmap, regh, &val); + ret = regmap_read(rdev->regmap, regh, &val); if (ret) return ret; @@ -352,7 +342,7 @@ static int bd7181x_buck12_set_voltage_sel(struct regulator_dev *rdev, * voltages at runtime is not supported by this driver. */ if (((val & BD71815_BUCK_STBY_DVS))) { - return regmap_update_bits(pmic->regmap, regh, BD71815_VOLT_MASK, + return regmap_update_bits(rdev->regmap, regh, BD71815_VOLT_MASK, sel); } /* Update new voltage to the register which is not selected now */ @@ -361,12 +351,13 @@ static int bd7181x_buck12_set_voltage_sel(struct regulator_dev *rdev, else reg = regh; - ret = regmap_update_bits(pmic->regmap, reg, BD71815_VOLT_MASK, sel); + ret = regmap_update_bits(rdev->regmap, reg, BD71815_VOLT_MASK, sel); if (ret) return ret; /* Select the other DVS register to be used */ - return regmap_update_bits(pmic->regmap, regh, BD71815_BUCK_DVSSEL, ~val); + return regmap_update_bits(rdev->regmap, regh, BD71815_BUCK_DVSSEL, + ~val); } static const struct regulator_ops bd7181x_ldo_regulator_ops = { @@ -524,7 +515,7 @@ static const struct regulator_ops bd7181x_led_regulator_ops = { .dvs = (_dvs), \ } -static struct bd71815_regulator bd71815_regulators[] = { +static const struct bd71815_regulator bd71815_regulators[] = { BD71815_BUCK12_REG(buck1, BD71815_BUCK1, BD71815_REG_BUCK1_VOLT_H, BD71815_REG_BUCK1_MODE, 800000, 2000000, 25000, &buck1_dvs), @@ -570,24 +561,16 @@ static struct bd71815_regulator bd71815_regulators[] = { static int bd7181x_probe(struct platform_device *pdev) { - struct bd71815_pmic *pmic; struct regulator_config config = {}; int i, ret; struct gpio_desc *ldo4_en; + struct regmap *regmap; - pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL); - if (!pmic) - return -ENOMEM; - - memcpy(pmic->descs, bd71815_regulators, sizeof(pmic->descs)); - - pmic->dev = &pdev->dev; - pmic->regmap = dev_get_regmap(pdev->dev.parent, NULL); - if (!pmic->regmap) { - dev_err(pmic->dev, "No parent regmap\n"); + regmap = dev_get_regmap(pdev->dev.parent, NULL); + if (!regmap) { + dev_err(&pdev->dev, "No parent regmap\n"); return -ENODEV; } - platform_set_drvdata(pdev, pmic); ldo4_en = devm_gpiod_get_from_of_node(&pdev->dev, pdev->dev.parent->of_node, "rohm,vsel-gpios", 0, @@ -601,23 +584,23 @@ static int bd7181x_probe(struct platform_device *pdev) } /* Disable to go to ship-mode */ - ret = regmap_update_bits(pmic->regmap, BD71815_REG_PWRCTRL, - RESTARTEN, 0); + ret = regmap_update_bits(regmap, BD71815_REG_PWRCTRL, RESTARTEN, 0); if (ret) return ret; config.dev = pdev->dev.parent; - config.regmap = pmic->regmap; + config.regmap = regmap; for (i = 0; i < BD71815_REGULATOR_CNT; i++) { - struct regulator_desc *desc; + const struct regulator_desc *desc; struct regulator_dev *rdev; - desc = &pmic->descs[i].desc; + desc = &bd71815_regulators[i].desc; + if (i == BD71815_LDO4) config.ena_gpiod = ldo4_en; - - config.driver_data = pmic; + else + config.ena_gpiod = NULL; rdev = devm_regulator_register(&pdev->dev, desc, &config); if (IS_ERR(rdev)) { @@ -626,8 +609,6 @@ static int bd7181x_probe(struct platform_device *pdev) desc->name); return PTR_ERR(rdev); } - config.ena_gpiod = NULL; - pmic->rdev[i] = rdev; } return 0; } |