Commit 7dd36b32 authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Mark Brown

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: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240909-regulator-const-v1-16-8934704a5787@linaro.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent e9c7ff34
...@@ -91,7 +91,7 @@ static const struct regulator_ops hi6421v530_ldo_ops; ...@@ -91,7 +91,7 @@ static const struct regulator_ops hi6421v530_ldo_ops;
/* HI6421V530 regulator information */ /* 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, HI6421V530_LDO(LDO3, ldo_3_voltages, 0x061, 0xf, 0x060, 0x2,
20000, 0x6), 20000, 0x6),
HI6421V530_LDO(LDO9, ldo_9_11_voltages, 0x06b, 0x7, 0x06a, 0x2, HI6421V530_LDO(LDO9, ldo_9_11_voltages, 0x06b, 0x7, 0x06a, 0x2,
...@@ -107,10 +107,10 @@ static struct hi6421v530_regulator_info hi6421v530_regulator_info[] = { ...@@ -107,10 +107,10 @@ static struct hi6421v530_regulator_info hi6421v530_regulator_info[] = {
static unsigned int hi6421v530_regulator_ldo_get_mode( static unsigned int hi6421v530_regulator_ldo_get_mode(
struct regulator_dev *rdev) struct regulator_dev *rdev)
{ {
struct hi6421v530_regulator_info *info; const struct hi6421v530_regulator_info *info;
unsigned int reg_val; 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); regmap_read(rdev->regmap, rdev->desc->enable_reg, &reg_val);
if (reg_val & (info->mode_mask)) if (reg_val & (info->mode_mask))
...@@ -122,10 +122,10 @@ static unsigned int hi6421v530_regulator_ldo_get_mode( ...@@ -122,10 +122,10 @@ static unsigned int hi6421v530_regulator_ldo_get_mode(
static int hi6421v530_regulator_ldo_set_mode(struct regulator_dev *rdev, static int hi6421v530_regulator_ldo_set_mode(struct regulator_dev *rdev,
unsigned int mode) unsigned int mode)
{ {
struct hi6421v530_regulator_info *info; const struct hi6421v530_regulator_info *info;
unsigned int new_mode; unsigned int new_mode;
info = rdev_get_drvdata(rdev); info = container_of(rdev->desc, struct hi6421v530_regulator_info, rdesc);
switch (mode) { switch (mode) {
case REGULATOR_MODE_NORMAL: case REGULATOR_MODE_NORMAL:
new_mode = 0; new_mode = 0;
...@@ -172,7 +172,6 @@ static int hi6421v530_regulator_probe(struct platform_device *pdev) ...@@ -172,7 +172,6 @@ static int hi6421v530_regulator_probe(struct platform_device *pdev)
for (i = 0; i < ARRAY_SIZE(hi6421v530_regulator_info); i++) { for (i = 0; i < ARRAY_SIZE(hi6421v530_regulator_info); i++) {
config.dev = pdev->dev.parent; config.dev = pdev->dev.parent;
config.regmap = pmic->regmap; config.regmap = pmic->regmap;
config.driver_data = &hi6421v530_regulator_info[i];
rdev = devm_regulator_register(&pdev->dev, rdev = devm_regulator_register(&pdev->dev,
&hi6421v530_regulator_info[i].rdesc, &hi6421v530_regulator_info[i].rdesc,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment