Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

regulator: leave one item to record whether regulator is enabled

The items "disabled" and "enabled" are a little redundant, since only one
of them would be set to record if the regulator device should keep on
or be switched to off in suspend states.

So in this patch, the "disabled" was removed, only leave the "enabled":
- enabled == 1 for regulator-on-in-suspend
- enabled == 0 for regulator-off-in-suspend
- enabled == -1 means do nothing when entering suspend mode.

Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Chunyan Zhang and committed by
Mark Brown
72069f99 c360a6df

+25 -14
+6 -8
drivers/regulator/core.c
··· 742 742 * only warn if the driver implements set_suspend_voltage or 743 743 * set_suspend_mode callback. 744 744 */ 745 - if (!rstate->enabled && !rstate->disabled) { 745 + if (rstate->enabled != ENABLE_IN_SUSPEND && 746 + rstate->enabled != DISABLE_IN_SUSPEND) { 746 747 if (rdev->desc->ops->set_suspend_voltage || 747 748 rdev->desc->ops->set_suspend_mode) 748 749 rdev_warn(rdev, "No configuration\n"); 749 750 return 0; 750 751 } 751 752 752 - if (rstate->enabled && rstate->disabled) { 753 - rdev_err(rdev, "invalid configuration\n"); 754 - return -EINVAL; 755 - } 756 - 757 - if (rstate->enabled && rdev->desc->ops->set_suspend_enable) 753 + if (rstate->enabled == ENABLE_IN_SUSPEND && 754 + rdev->desc->ops->set_suspend_enable) 758 755 ret = rdev->desc->ops->set_suspend_enable(rdev); 759 - else if (rstate->disabled && rdev->desc->ops->set_suspend_disable) 756 + else if (rstate->enabled == DISABLE_IN_SUSPEND && 757 + rdev->desc->ops->set_suspend_disable) 760 758 ret = rdev->desc->ops->set_suspend_disable(rdev); 761 759 else /* OK if set_suspend_enable or set_suspend_disable is NULL */ 762 760 ret = 0;
+4 -2
drivers/regulator/of_regulator.c
··· 177 177 178 178 if (of_property_read_bool(suspend_np, 179 179 "regulator-on-in-suspend")) 180 - suspend_state->enabled = true; 180 + suspend_state->enabled = ENABLE_IN_SUSPEND; 181 181 else if (of_property_read_bool(suspend_np, 182 182 "regulator-off-in-suspend")) 183 - suspend_state->disabled = true; 183 + suspend_state->enabled = DISABLE_IN_SUSPEND; 184 + else 185 + suspend_state->enabled = DO_NOTHING_IN_SUSPEND; 184 186 185 187 if (!of_property_read_u32(suspend_np, 186 188 "regulator-suspend-microvolt", &pval))
+15 -4
include/linux/regulator/machine.h
··· 42 42 #define REGULATOR_CHANGE_DRMS 0x10 43 43 #define REGULATOR_CHANGE_BYPASS 0x20 44 44 45 + /* 46 + * operations in suspend mode 47 + * DO_NOTHING_IN_SUSPEND - the default value 48 + * DISABLE_IN_SUSPEND - turn off regulator in suspend states 49 + * ENABLE_IN_SUSPEND - keep regulator on in suspend states 50 + */ 51 + #define DO_NOTHING_IN_SUSPEND (-1) 52 + #define DISABLE_IN_SUSPEND 0 53 + #define ENABLE_IN_SUSPEND 1 54 + 45 55 /* Regulator active discharge flags */ 46 56 enum regulator_active_discharge { 47 57 REGULATOR_ACTIVE_DISCHARGE_DEFAULT, ··· 68 58 * 69 59 * @uV: Operating voltage during suspend. 70 60 * @mode: Operating mode during suspend. 71 - * @enabled: Enabled during suspend. 72 - * @disabled: Disabled during suspend. 61 + * @enabled: operations during suspend. 62 + * - DO_NOTHING_IN_SUSPEND 63 + * - DISABLE_IN_SUSPEND 64 + * - ENABLE_IN_SUSPEND 73 65 */ 74 66 struct regulator_state { 75 67 int uV; /* suspend voltage */ 76 68 unsigned int mode; /* suspend regulator operating mode */ 77 - int enabled; /* is regulator enabled in this suspend state */ 78 - int disabled; /* is the regulator disabled in this suspend state */ 69 + int enabled; 79 70 }; 80 71 81 72 /**