Skip to content

Commit 3edd79c

Browse files
mszyprowbroonie
authored andcommitted
regulator: Fix 'do-nothing' value for regulators without suspend state
Some regulators don't have all states defined and in such cases regulator core should not assume anything. However in current implementation of of_get_regulation_constraints() DO_NOTHING_IN_SUSPEND enable value was set only for regulators which had suspend node defined, otherwise the default 0 value was used, what means DISABLE_IN_SUSPEND. This lead to broken system suspend/resume on boards, which had simple regulator constraints definition (without suspend state nodes). To avoid further mismatches between the default and uninitialized values of the suspend enabled/disabled states, change the values of the them, so default '0' means DO_NOTHING_IN_SUSPEND. Fixes: 72069f9: regulator: leave one item to record whether regulator is enabled Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org
1 parent ef394f3 commit 3edd79c

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

drivers/regulator/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3161,7 +3161,7 @@ static inline int regulator_suspend_toggle(struct regulator_dev *rdev,
31613161
if (!rstate->changeable)
31623162
return -EPERM;
31633163

3164-
rstate->enabled = en;
3164+
rstate->enabled = (en) ? ENABLE_IN_SUSPEND : DISABLE_IN_SUSPEND;
31653165

31663166
return 0;
31673167
}

drivers/regulator/of_regulator.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,6 @@ static void of_get_regulation_constraints(struct device_node *np,
213213
else if (of_property_read_bool(suspend_np,
214214
"regulator-off-in-suspend"))
215215
suspend_state->enabled = DISABLE_IN_SUSPEND;
216-
else
217-
suspend_state->enabled = DO_NOTHING_IN_SUSPEND;
218216

219217
if (!of_property_read_u32(np, "regulator-suspend-min-microvolt",
220218
&pval))

include/linux/regulator/machine.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ struct regulator;
4848
* DISABLE_IN_SUSPEND - turn off regulator in suspend states
4949
* ENABLE_IN_SUSPEND - keep regulator on in suspend states
5050
*/
51-
#define DO_NOTHING_IN_SUSPEND (-1)
52-
#define DISABLE_IN_SUSPEND 0
53-
#define ENABLE_IN_SUSPEND 1
51+
#define DO_NOTHING_IN_SUSPEND 0
52+
#define DISABLE_IN_SUSPEND 1
53+
#define ENABLE_IN_SUSPEND 2
5454

5555
/* Regulator active discharge flags */
5656
enum regulator_active_discharge {

0 commit comments

Comments
 (0)