Skip to content

Commit fc69bab

Browse files
Adam Thomsonbroonie
authored andcommitted
regulator: da9063: Fix get_mode() functions to read sleep field
get_mode() is used to retrieve the active mode state. Settings-A config is used during active state, whilst Settings-B is for suspend. This means we only need to check the sleep field of each buck and LDO as that field solely relates to Settings-A config. This change is a clone of the get_mode() update which was committed as part of: - regulator: da9062: fix suspend_enable/disable preparation [a72865f] Signed-off-by: Adam Thomson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 99f75ce commit fc69bab

File tree

1 file changed

+2
-26
lines changed

1 file changed

+2
-26
lines changed

drivers/regulator/da9063-regulator.c

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ static int da9063_buck_set_mode(struct regulator_dev *rdev, unsigned mode)
226226
static unsigned da9063_buck_get_mode(struct regulator_dev *rdev)
227227
{
228228
struct da9063_regulator *regl = rdev_get_drvdata(rdev);
229-
struct regmap_field *field;
230229
unsigned int val;
231230
int ret;
232231

@@ -247,18 +246,7 @@ static unsigned da9063_buck_get_mode(struct regulator_dev *rdev)
247246
return REGULATOR_MODE_NORMAL;
248247
}
249248

250-
/* Detect current regulator state */
251-
ret = regmap_field_read(regl->suspend, &val);
252-
if (ret < 0)
253-
return 0;
254-
255-
/* Read regulator mode from proper register, depending on state */
256-
if (val)
257-
field = regl->suspend_sleep;
258-
else
259-
field = regl->sleep;
260-
261-
ret = regmap_field_read(field, &val);
249+
ret = regmap_field_read(regl->sleep, &val);
262250
if (ret < 0)
263251
return 0;
264252

@@ -295,21 +283,9 @@ static int da9063_ldo_set_mode(struct regulator_dev *rdev, unsigned mode)
295283
static unsigned da9063_ldo_get_mode(struct regulator_dev *rdev)
296284
{
297285
struct da9063_regulator *regl = rdev_get_drvdata(rdev);
298-
struct regmap_field *field;
299286
int ret, val;
300287

301-
/* Detect current regulator state */
302-
ret = regmap_field_read(regl->suspend, &val);
303-
if (ret < 0)
304-
return 0;
305-
306-
/* Read regulator mode from proper register, depending on state */
307-
if (val)
308-
field = regl->suspend_sleep;
309-
else
310-
field = regl->sleep;
311-
312-
ret = regmap_field_read(field, &val);
288+
ret = regmap_field_read(regl->sleep, &val);
313289
if (ret < 0)
314290
return 0;
315291

0 commit comments

Comments
 (0)