diff options
| -rw-r--r-- | drivers/regulator/core.c | 41 | ||||
| -rw-r--r-- | include/linux/regulator/machine.h | 1 |
2 files changed, 42 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a2dc6223e8d..e611f6797e6 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
| @@ -2656,6 +2656,47 @@ out: | |||
| 2656 | EXPORT_SYMBOL_GPL(regulator_suspend_prepare); | 2656 | EXPORT_SYMBOL_GPL(regulator_suspend_prepare); |
| 2657 | 2657 | ||
| 2658 | /** | 2658 | /** |
| 2659 | * regulator_suspend_finish - resume regulators from system wide suspend | ||
| 2660 | * | ||
| 2661 | * Turn on regulators that might be turned off by regulator_suspend_prepare | ||
| 2662 | * and that should be turned on according to the regulators properties. | ||
| 2663 | */ | ||
| 2664 | int regulator_suspend_finish(void) | ||
| 2665 | { | ||
| 2666 | struct regulator_dev *rdev; | ||
| 2667 | int ret = 0, error; | ||
| 2668 | |||
| 2669 | mutex_lock(®ulator_list_mutex); | ||
| 2670 | list_for_each_entry(rdev, ®ulator_list, list) { | ||
| 2671 | struct regulator_ops *ops = rdev->desc->ops; | ||
| 2672 | |||
| 2673 | mutex_lock(&rdev->mutex); | ||
| 2674 | if ((rdev->use_count > 0 || rdev->constraints->always_on) && | ||
| 2675 | ops->enable) { | ||
| 2676 | error = ops->enable(rdev); | ||
| 2677 | if (error) | ||
| 2678 | ret = error; | ||
| 2679 | } else { | ||
| 2680 | if (!has_full_constraints) | ||
| 2681 | goto unlock; | ||
| 2682 | if (!ops->disable) | ||
| 2683 | goto unlock; | ||
| 2684 | if (ops->is_enabled && !ops->is_enabled(rdev)) | ||
| 2685 | goto unlock; | ||
| 2686 | |||
| 2687 | error = ops->disable(rdev); | ||
| 2688 | if (error) | ||
| 2689 | ret = error; | ||
| 2690 | } | ||
| 2691 | unlock: | ||
| 2692 | mutex_unlock(&rdev->mutex); | ||
| 2693 | } | ||
| 2694 | mutex_unlock(®ulator_list_mutex); | ||
| 2695 | return ret; | ||
| 2696 | } | ||
| 2697 | EXPORT_SYMBOL_GPL(regulator_suspend_finish); | ||
| 2698 | |||
| 2699 | /** | ||
| 2659 | * regulator_has_full_constraints - the system has fully specified constraints | 2700 | * regulator_has_full_constraints - the system has fully specified constraints |
| 2660 | * | 2701 | * |
| 2661 | * Calling this function will cause the regulator API to disable all | 2702 | * Calling this function will cause the regulator API to disable all |
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h index 761c745b9c2..c4c4fc45f85 100644 --- a/include/linux/regulator/machine.h +++ b/include/linux/regulator/machine.h | |||
| @@ -186,6 +186,7 @@ struct regulator_init_data { | |||
| 186 | }; | 186 | }; |
| 187 | 187 | ||
| 188 | int regulator_suspend_prepare(suspend_state_t state); | 188 | int regulator_suspend_prepare(suspend_state_t state); |
| 189 | int regulator_suspend_finish(void); | ||
| 189 | 190 | ||
| 190 | #ifdef CONFIG_REGULATOR | 191 | #ifdef CONFIG_REGULATOR |
| 191 | void regulator_has_full_constraints(void); | 192 | void regulator_has_full_constraints(void); |
