mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 13:11:40 +00:00
regulator: max77686: Don't update max77686->opmode if update register fails
Ensure max77686->opmode always has correct status. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@sirena.org.uk>
This commit is contained in:
parent
60d509fa6a
commit
3ecf198eab
@ -75,17 +75,20 @@ static int max77686_buck_set_suspend_disable(struct regulator_dev *rdev)
|
||||
{
|
||||
unsigned int val;
|
||||
struct max77686_data *max77686 = rdev_get_drvdata(rdev);
|
||||
int id = rdev_get_id(rdev);
|
||||
int ret, id = rdev_get_id(rdev);
|
||||
|
||||
if (id == MAX77686_BUCK1)
|
||||
val = 0x1;
|
||||
else
|
||||
val = 0x1 << MAX77686_OPMODE_BUCK234_SHIFT;
|
||||
|
||||
ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
|
||||
rdev->desc->enable_mask, val);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
max77686->opmode[id] = val;
|
||||
return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
|
||||
rdev->desc->enable_mask,
|
||||
val);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Some LDOs supports [LPM/Normal]ON mode during suspend state */
|
||||
@ -94,7 +97,7 @@ static int max77686_set_suspend_mode(struct regulator_dev *rdev,
|
||||
{
|
||||
struct max77686_data *max77686 = rdev_get_drvdata(rdev);
|
||||
unsigned int val;
|
||||
int id = rdev_get_id(rdev);
|
||||
int ret, id = rdev_get_id(rdev);
|
||||
|
||||
/* BUCK[5-9] doesn't support this feature */
|
||||
if (id >= MAX77686_BUCK5)
|
||||
@ -113,10 +116,13 @@ static int max77686_set_suspend_mode(struct regulator_dev *rdev,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
|
||||
rdev->desc->enable_mask, val);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
max77686->opmode[id] = val;
|
||||
return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
|
||||
rdev->desc->enable_mask,
|
||||
val);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Some LDOs supports LPM-ON/OFF/Normal-ON mode during suspend state */
|
||||
@ -125,6 +131,7 @@ static int max77686_ldo_set_suspend_mode(struct regulator_dev *rdev,
|
||||
{
|
||||
unsigned int val;
|
||||
struct max77686_data *max77686 = rdev_get_drvdata(rdev);
|
||||
int ret;
|
||||
|
||||
switch (mode) {
|
||||
case REGULATOR_MODE_STANDBY: /* switch off */
|
||||
@ -142,10 +149,13 @@ static int max77686_ldo_set_suspend_mode(struct regulator_dev *rdev,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
|
||||
rdev->desc->enable_mask, val);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
max77686->opmode[rdev_get_id(rdev)] = val;
|
||||
return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
|
||||
rdev->desc->enable_mask,
|
||||
val);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int max77686_enable(struct regulator_dev *rdev)
|
||||
|
Loading…
Reference in New Issue
Block a user