summaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>2024-09-09 15:51:27 +0200
committerMark Brown <broonie@kernel.org>2024-09-10 13:44:17 +0200
commit7dd36b3287182bc889953f7741bdcef037109210 (patch)
tree9250037a8ab3b91e4b4562916d223e9d9cf37a71 /drivers/regulator
parentregulator: hi6421v530: Drop unused 'eco_microamp' (diff)
downloadlinux-7dd36b3287182bc889953f7741bdcef037109210.tar.xz
linux-7dd36b3287182bc889953f7741bdcef037109210.zip
regulator: hi6421v530: Use container_of and constify static data
Switch from rdev_get_drvdata() to container_of(), so the static 'struct hi6421v530_regulator_info' holding 'struct regulator_desc' can be made const for code safety. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://patch.msgid.link/20240909-regulator-const-v1-16-8934704a5787@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/hi6421v530-regulator.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/regulator/hi6421v530-regulator.c b/drivers/regulator/hi6421v530-regulator.c
index a9c6c077f50d..b3ebd1624814 100644
--- a/drivers/regulator/hi6421v530-regulator.c
+++ b/drivers/regulator/hi6421v530-regulator.c
@@ -91,7 +91,7 @@ static const struct regulator_ops hi6421v530_ldo_ops;
/* HI6421V530 regulator information */
-static struct hi6421v530_regulator_info hi6421v530_regulator_info[] = {
+static const struct hi6421v530_regulator_info hi6421v530_regulator_info[] = {
HI6421V530_LDO(LDO3, ldo_3_voltages, 0x061, 0xf, 0x060, 0x2,
20000, 0x6),
HI6421V530_LDO(LDO9, ldo_9_11_voltages, 0x06b, 0x7, 0x06a, 0x2,
@@ -107,10 +107,10 @@ static struct hi6421v530_regulator_info hi6421v530_regulator_info[] = {
static unsigned int hi6421v530_regulator_ldo_get_mode(
struct regulator_dev *rdev)
{
- struct hi6421v530_regulator_info *info;
+ const struct hi6421v530_regulator_info *info;
unsigned int reg_val;
- info = rdev_get_drvdata(rdev);
+ info = container_of(rdev->desc, struct hi6421v530_regulator_info, rdesc);
regmap_read(rdev->regmap, rdev->desc->enable_reg, &reg_val);
if (reg_val & (info->mode_mask))
@@ -122,10 +122,10 @@ static unsigned int hi6421v530_regulator_ldo_get_mode(
static int hi6421v530_regulator_ldo_set_mode(struct regulator_dev *rdev,
unsigned int mode)
{
- struct hi6421v530_regulator_info *info;
+ const struct hi6421v530_regulator_info *info;
unsigned int new_mode;
- info = rdev_get_drvdata(rdev);
+ info = container_of(rdev->desc, struct hi6421v530_regulator_info, rdesc);
switch (mode) {
case REGULATOR_MODE_NORMAL:
new_mode = 0;
@@ -172,7 +172,6 @@ static int hi6421v530_regulator_probe(struct platform_device *pdev)
for (i = 0; i < ARRAY_SIZE(hi6421v530_regulator_info); i++) {
config.dev = pdev->dev.parent;
config.regmap = pmic->regmap;
- config.driver_data = &hi6421v530_regulator_info[i];
rdev = devm_regulator_register(&pdev->dev,
&hi6421v530_regulator_info[i].rdesc,