diff options
-rw-r--r-- | drivers/regulator/core.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 9a09f3cdbabb..d70f00f8fc66 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -844,13 +844,22 @@ static int machine_constraints_voltage(struct regulator_dev *rdev, | |||
844 | /* do we need to apply the constraint voltage */ | 844 | /* do we need to apply the constraint voltage */ |
845 | if (rdev->constraints->apply_uV && | 845 | if (rdev->constraints->apply_uV && |
846 | rdev->constraints->min_uV == rdev->constraints->max_uV) { | 846 | rdev->constraints->min_uV == rdev->constraints->max_uV) { |
847 | ret = _regulator_do_set_voltage(rdev, | 847 | int current_uV = _regulator_get_voltage(rdev); |
848 | rdev->constraints->min_uV, | 848 | if (current_uV < 0) { |
849 | rdev->constraints->max_uV); | 849 | rdev_err(rdev, "failed to get the current voltage\n"); |
850 | if (ret < 0) { | 850 | return current_uV; |
851 | rdev_err(rdev, "failed to apply %duV constraint\n", | 851 | } |
852 | rdev->constraints->min_uV); | 852 | if (current_uV < rdev->constraints->min_uV || |
853 | return ret; | 853 | current_uV > rdev->constraints->max_uV) { |
854 | ret = _regulator_do_set_voltage( | ||
855 | rdev, rdev->constraints->min_uV, | ||
856 | rdev->constraints->max_uV); | ||
857 | if (ret < 0) { | ||
858 | rdev_err(rdev, | ||
859 | "failed to apply %duV constraint\n", | ||
860 | rdev->constraints->min_uV); | ||
861 | return ret; | ||
862 | } | ||
854 | } | 863 | } |
855 | } | 864 | } |
856 | 865 | ||
@@ -3819,8 +3828,9 @@ static int __init regulator_init_complete(void) | |||
3819 | mutex_lock(®ulator_list_mutex); | 3828 | mutex_lock(®ulator_list_mutex); |
3820 | 3829 | ||
3821 | /* If we have a full configuration then disable any regulators | 3830 | /* If we have a full configuration then disable any regulators |
3822 | * which are not in use or always_on. This will become the | 3831 | * we have permission to change the status for and which are |
3823 | * default behaviour in the future. | 3832 | * not in use or always_on. This is effectively the default |
3833 | * for DT and ACPI as they have full constraints. | ||
3824 | */ | 3834 | */ |
3825 | list_for_each_entry(rdev, ®ulator_list, list) { | 3835 | list_for_each_entry(rdev, ®ulator_list, list) { |
3826 | ops = rdev->desc->ops; | 3836 | ops = rdev->desc->ops; |
@@ -3829,6 +3839,9 @@ static int __init regulator_init_complete(void) | |||
3829 | if (c && c->always_on) | 3839 | if (c && c->always_on) |
3830 | continue; | 3840 | continue; |
3831 | 3841 | ||
3842 | if (c && !(c->valid_ops_mask & REGULATOR_CHANGE_STATUS)) | ||
3843 | continue; | ||
3844 | |||
3832 | mutex_lock(&rdev->mutex); | 3845 | mutex_lock(&rdev->mutex); |
3833 | 3846 | ||
3834 | if (rdev->use_count) | 3847 | if (rdev->use_count) |
@@ -3867,4 +3880,4 @@ unlock: | |||
3867 | 3880 | ||
3868 | return 0; | 3881 | return 0; |
3869 | } | 3882 | } |
3870 | late_initcall(regulator_init_complete); | 3883 | late_initcall_sync(regulator_init_complete); |