diff options
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r-- | drivers/regulator/core.c | 50 |
1 files changed, 21 insertions, 29 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 16a309e5c024..afca1bc24f26 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -953,6 +953,8 @@ static int machine_constraints_current(struct regulator_dev *rdev, | |||
953 | return 0; | 953 | return 0; |
954 | } | 954 | } |
955 | 955 | ||
956 | static int _regulator_do_enable(struct regulator_dev *rdev); | ||
957 | |||
956 | /** | 958 | /** |
957 | * set_machine_constraints - sets regulator constraints | 959 | * set_machine_constraints - sets regulator constraints |
958 | * @rdev: regulator source | 960 | * @rdev: regulator source |
@@ -1013,10 +1015,9 @@ static int set_machine_constraints(struct regulator_dev *rdev, | |||
1013 | /* If the constraints say the regulator should be on at this point | 1015 | /* If the constraints say the regulator should be on at this point |
1014 | * and we have control then make sure it is enabled. | 1016 | * and we have control then make sure it is enabled. |
1015 | */ | 1017 | */ |
1016 | if ((rdev->constraints->always_on || rdev->constraints->boot_on) && | 1018 | if (rdev->constraints->always_on || rdev->constraints->boot_on) { |
1017 | ops->enable) { | 1019 | ret = _regulator_do_enable(rdev); |
1018 | ret = ops->enable(rdev); | 1020 | if (ret < 0 && ret != -EINVAL) { |
1019 | if (ret < 0) { | ||
1020 | rdev_err(rdev, "failed to enable\n"); | 1021 | rdev_err(rdev, "failed to enable\n"); |
1021 | goto out; | 1022 | goto out; |
1022 | } | 1023 | } |
@@ -1359,7 +1360,7 @@ static struct regulator *_regulator_get(struct device *dev, const char *id, | |||
1359 | goto found; | 1360 | goto found; |
1360 | /* Don't log an error when called from regulator_get_optional() */ | 1361 | /* Don't log an error when called from regulator_get_optional() */ |
1361 | } else if (!have_full_constraints() || exclusive) { | 1362 | } else if (!have_full_constraints() || exclusive) { |
1362 | dev_err(dev, "dummy supplies not allowed\n"); | 1363 | dev_warn(dev, "dummy supplies not allowed\n"); |
1363 | } | 1364 | } |
1364 | 1365 | ||
1365 | mutex_unlock(®ulator_list_mutex); | 1366 | mutex_unlock(®ulator_list_mutex); |
@@ -1907,8 +1908,6 @@ static int _regulator_do_disable(struct regulator_dev *rdev) | |||
1907 | 1908 | ||
1908 | trace_regulator_disable_complete(rdev_get_name(rdev)); | 1909 | trace_regulator_disable_complete(rdev_get_name(rdev)); |
1909 | 1910 | ||
1910 | _notifier_call_chain(rdev, REGULATOR_EVENT_DISABLE, | ||
1911 | NULL); | ||
1912 | return 0; | 1911 | return 0; |
1913 | } | 1912 | } |
1914 | 1913 | ||
@@ -1932,6 +1931,8 @@ static int _regulator_disable(struct regulator_dev *rdev) | |||
1932 | rdev_err(rdev, "failed to disable\n"); | 1931 | rdev_err(rdev, "failed to disable\n"); |
1933 | return ret; | 1932 | return ret; |
1934 | } | 1933 | } |
1934 | _notifier_call_chain(rdev, REGULATOR_EVENT_DISABLE, | ||
1935 | NULL); | ||
1935 | } | 1936 | } |
1936 | 1937 | ||
1937 | rdev->use_count = 0; | 1938 | rdev->use_count = 0; |
@@ -1984,20 +1985,16 @@ static int _regulator_force_disable(struct regulator_dev *rdev) | |||
1984 | { | 1985 | { |
1985 | int ret = 0; | 1986 | int ret = 0; |
1986 | 1987 | ||
1987 | /* force disable */ | 1988 | ret = _regulator_do_disable(rdev); |
1988 | if (rdev->desc->ops->disable) { | 1989 | if (ret < 0) { |
1989 | /* ah well, who wants to live forever... */ | 1990 | rdev_err(rdev, "failed to force disable\n"); |
1990 | ret = rdev->desc->ops->disable(rdev); | 1991 | return ret; |
1991 | if (ret < 0) { | ||
1992 | rdev_err(rdev, "failed to force disable\n"); | ||
1993 | return ret; | ||
1994 | } | ||
1995 | /* notify other consumers that power has been forced off */ | ||
1996 | _notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE | | ||
1997 | REGULATOR_EVENT_DISABLE, NULL); | ||
1998 | } | 1992 | } |
1999 | 1993 | ||
2000 | return ret; | 1994 | _notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE | |
1995 | REGULATOR_EVENT_DISABLE, NULL); | ||
1996 | |||
1997 | return 0; | ||
2001 | } | 1998 | } |
2002 | 1999 | ||
2003 | /** | 2000 | /** |
@@ -3630,23 +3627,18 @@ int regulator_suspend_finish(void) | |||
3630 | 3627 | ||
3631 | mutex_lock(®ulator_list_mutex); | 3628 | mutex_lock(®ulator_list_mutex); |
3632 | list_for_each_entry(rdev, ®ulator_list, list) { | 3629 | list_for_each_entry(rdev, ®ulator_list, list) { |
3633 | struct regulator_ops *ops = rdev->desc->ops; | ||
3634 | |||
3635 | mutex_lock(&rdev->mutex); | 3630 | mutex_lock(&rdev->mutex); |
3636 | if ((rdev->use_count > 0 || rdev->constraints->always_on) && | 3631 | if (rdev->use_count > 0 || rdev->constraints->always_on) { |
3637 | ops->enable) { | 3632 | error = _regulator_do_enable(rdev); |
3638 | error = ops->enable(rdev); | ||
3639 | if (error) | 3633 | if (error) |
3640 | ret = error; | 3634 | ret = error; |
3641 | } else { | 3635 | } else { |
3642 | if (!have_full_constraints()) | 3636 | if (!have_full_constraints()) |
3643 | goto unlock; | 3637 | goto unlock; |
3644 | if (!ops->disable) | ||
3645 | goto unlock; | ||
3646 | if (!_regulator_is_enabled(rdev)) | 3638 | if (!_regulator_is_enabled(rdev)) |
3647 | goto unlock; | 3639 | goto unlock; |
3648 | 3640 | ||
3649 | error = ops->disable(rdev); | 3641 | error = _regulator_do_disable(rdev); |
3650 | if (error) | 3642 | if (error) |
3651 | ret = error; | 3643 | ret = error; |
3652 | } | 3644 | } |
@@ -3820,7 +3812,7 @@ static int __init regulator_init_complete(void) | |||
3820 | ops = rdev->desc->ops; | 3812 | ops = rdev->desc->ops; |
3821 | c = rdev->constraints; | 3813 | c = rdev->constraints; |
3822 | 3814 | ||
3823 | if (!ops->disable || (c && c->always_on)) | 3815 | if (c && c->always_on) |
3824 | continue; | 3816 | continue; |
3825 | 3817 | ||
3826 | mutex_lock(&rdev->mutex); | 3818 | mutex_lock(&rdev->mutex); |
@@ -3841,7 +3833,7 @@ static int __init regulator_init_complete(void) | |||
3841 | /* We log since this may kill the system if it | 3833 | /* We log since this may kill the system if it |
3842 | * goes wrong. */ | 3834 | * goes wrong. */ |
3843 | rdev_info(rdev, "disabling\n"); | 3835 | rdev_info(rdev, "disabling\n"); |
3844 | ret = ops->disable(rdev); | 3836 | ret = _regulator_do_disable(rdev); |
3845 | if (ret != 0) | 3837 | if (ret != 0) |
3846 | rdev_err(rdev, "couldn't disable: %d\n", ret); | 3838 | rdev_err(rdev, "couldn't disable: %d\n", ret); |
3847 | } else { | 3839 | } else { |