aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/regulator/core.c25
-rw-r--r--include/linux/regulator/machine.h6
2 files changed, 27 insertions, 4 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 7d0c0d7d90ca..2dab0d9e11f5 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -581,10 +581,29 @@ static int suspend_set_state(struct regulator_dev *rdev,
581 struct regulator_state *rstate) 581 struct regulator_state *rstate)
582{ 582{
583 int ret = 0; 583 int ret = 0;
584 bool can_set_state;
584 585
585 /* enable & disable are mandatory for suspend control */ 586 can_set_state = rdev->desc->ops->set_suspend_enable &&
586 if (!rdev->desc->ops->set_suspend_enable || 587 rdev->desc->ops->set_suspend_disable;
587 !rdev->desc->ops->set_suspend_disable) { 588
589 /* If we have no suspend mode configration don't set anything;
590 * only warn if the driver actually makes the suspend mode
591 * configurable.
592 */
593 if (!rstate->enabled && !rstate->disabled) {
594 if (can_set_state)
595 printk(KERN_WARNING "%s: No configuration for %s\n",
596 __func__, rdev_get_name(rdev));
597 return 0;
598 }
599
600 if (rstate->enabled && rstate->disabled) {
601 printk(KERN_ERR "%s: invalid configuration for %s\n",
602 __func__, rdev_get_name(rdev));
603 return -EINVAL;
604 }
605
606 if (!can_set_state) {
588 printk(KERN_ERR "%s: no way to set suspend state\n", 607 printk(KERN_ERR "%s: no way to set suspend state\n",
589 __func__); 608 __func__);
590 return -EINVAL; 609 return -EINVAL;
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h
index 87f5f176d4ef..234a8476cba8 100644
--- a/include/linux/regulator/machine.h
+++ b/include/linux/regulator/machine.h
@@ -43,16 +43,20 @@ struct regulator;
43/** 43/**
44 * struct regulator_state - regulator state during low power system states 44 * struct regulator_state - regulator state during low power system states
45 * 45 *
46 * This describes a regulators state during a system wide low power state. 46 * This describes a regulators state during a system wide low power
47 * state. One of enabled or disabled must be set for the
48 * configuration to be applied.
47 * 49 *
48 * @uV: Operating voltage during suspend. 50 * @uV: Operating voltage during suspend.
49 * @mode: Operating mode during suspend. 51 * @mode: Operating mode during suspend.
50 * @enabled: Enabled during suspend. 52 * @enabled: Enabled during suspend.
53 * @disabled: Disabled during suspend.
51 */ 54 */
52struct regulator_state { 55struct regulator_state {
53 int uV; /* suspend voltage */ 56 int uV; /* suspend voltage */
54 unsigned int mode; /* suspend regulator operating mode */ 57 unsigned int mode; /* suspend regulator operating mode */
55 int enabled; /* is regulator enabled in this suspend state */ 58 int enabled; /* is regulator enabled in this suspend state */
59 int disabled; /* is the regulator disbled in this suspend state */
56}; 60};
57 61
58/** 62/**