summaryrefslogtreecommitdiffstats
path: root/drivers/regulator/hi6421v600-regulator.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2021-06-19 14:34:23 +0200
committerMark Brown <broonie@kernel.org>2021-06-21 14:07:46 +0200
commit57c045bc727001c43b6a65adb0418aa7b3e6dbd0 (patch)
treed77c4c8f43a7e630b6310891739f0fa9a47109a8 /drivers/regulator/hi6421v600-regulator.c
parentregulator: Add MAX8893 bindings (diff)
downloadlinux-57c045bc727001c43b6a65adb0418aa7b3e6dbd0.tar.xz
linux-57c045bc727001c43b6a65adb0418aa7b3e6dbd0.zip
regulator: hi6421v600: Fix setting idle mode
commit db27f8294cd7 changed eco_mode << (ffs(sreg->eco_mode_mask) - 1) to sreg->eco_mode_mask << (ffs(sreg->eco_mode_mask) - 1) which is wrong. Fix it by simply set val = sreg->eco_mode_mask. In additional, sreg->eco_mode_mask can be 0 (LDO3, LDO33, LDO34). Return -EINVAL if idle mode is not supported when sreg->eco_mode_mask is 0. While at it, also use unsigned int for reg_val/val which is the expected type for regmap_read and regmap_update_bits. Fixes: db27f8294cd7 ("staging: regulator: hi6421v600-regulator: use shorter names for OF properties") Signed-off-by: Axel Lin <axel.lin@ingics.com> Link: https://lore.kernel.org/r/20210619123423.4091429-1-axel.lin@ingics.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator/hi6421v600-regulator.c')
-rw-r--r--drivers/regulator/hi6421v600-regulator.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/regulator/hi6421v600-regulator.c b/drivers/regulator/hi6421v600-regulator.c
index 417cf5b4a1c3..cf14109d486f 100644
--- a/drivers/regulator/hi6421v600-regulator.c
+++ b/drivers/regulator/hi6421v600-regulator.c
@@ -117,7 +117,7 @@ static int hi6421_spmi_regulator_enable(struct regulator_dev *rdev)
static unsigned int hi6421_spmi_regulator_get_mode(struct regulator_dev *rdev)
{
struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev);
- u32 reg_val;
+ unsigned int reg_val;
regmap_read(rdev->regmap, rdev->desc->enable_reg, &reg_val);
@@ -131,14 +131,17 @@ static int hi6421_spmi_regulator_set_mode(struct regulator_dev *rdev,
unsigned int mode)
{
struct hi6421_spmi_reg_info *sreg = rdev_get_drvdata(rdev);
- u32 val;
+ unsigned int val;
switch (mode) {
case REGULATOR_MODE_NORMAL:
val = 0;
break;
case REGULATOR_MODE_IDLE:
- val = sreg->eco_mode_mask << (ffs(sreg->eco_mode_mask) - 1);
+ if (!sreg->eco_mode_mask)
+ return -EINVAL;
+
+ val = sreg->eco_mode_mask;
break;
default:
return -EINVAL;