aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Pargmann <mpa@pengutronix.de>2014-02-20 11:36:04 -0500
committerMark Brown <broonie@linaro.org>2014-02-24 20:31:45 -0500
commit66fda75f47dc583f1c187556e9a2c082dd64f8c6 (patch)
tree58fc2ec4e98cd7e80d30637d53844a86cf703073
parent30c219710358c5cca2f8bd2e9e547c6aadf7cf8b (diff)
regulator: core: Replace direct ops->disable usage
There are many places where ops->disable is called directly. Instead we should use _regulator_do_disable() which also handles gpio regulators. To be able to use the wrapper function from _regulator_force_disable(), I moved the _notifier_call_chain() call from _regulator_do_disable() to _regulator_disable(). This way, _regulator_force_disable() can use different flags for _notifier_call_chain() without calling it twice. Cc: <stable@vger.kernel.org> # 3.10+ Signed-off-by: Markus Pargmann <mpa@pengutronix.de> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--drivers/regulator/core.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 00feec321e3c..6f7198516fef 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1901,8 +1901,6 @@ static int _regulator_do_disable(struct regulator_dev *rdev)
1901 1901
1902 trace_regulator_disable_complete(rdev_get_name(rdev)); 1902 trace_regulator_disable_complete(rdev_get_name(rdev));
1903 1903
1904 _notifier_call_chain(rdev, REGULATOR_EVENT_DISABLE,
1905 NULL);
1906 return 0; 1904 return 0;
1907} 1905}
1908 1906
@@ -1926,6 +1924,8 @@ static int _regulator_disable(struct regulator_dev *rdev)
1926 rdev_err(rdev, "failed to disable\n"); 1924 rdev_err(rdev, "failed to disable\n");
1927 return ret; 1925 return ret;
1928 } 1926 }
1927 _notifier_call_chain(rdev, REGULATOR_EVENT_DISABLE,
1928 NULL);
1929 } 1929 }
1930 1930
1931 rdev->use_count = 0; 1931 rdev->use_count = 0;
@@ -1978,20 +1978,16 @@ static int _regulator_force_disable(struct regulator_dev *rdev)
1978{ 1978{
1979 int ret = 0; 1979 int ret = 0;
1980 1980
1981 /* force disable */ 1981 ret = _regulator_do_disable(rdev);
1982 if (rdev->desc->ops->disable) { 1982 if (ret < 0) {
1983 /* ah well, who wants to live forever... */ 1983 rdev_err(rdev, "failed to force disable\n");
1984 ret = rdev->desc->ops->disable(rdev); 1984 return ret;
1985 if (ret < 0) {
1986 rdev_err(rdev, "failed to force disable\n");
1987 return ret;
1988 }
1989 /* notify other consumers that power has been forced off */
1990 _notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE |
1991 REGULATOR_EVENT_DISABLE, NULL);
1992 } 1985 }
1993 1986
1994 return ret; 1987 _notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE |
1988 REGULATOR_EVENT_DISABLE, NULL);
1989
1990 return 0;
1995} 1991}
1996 1992
1997/** 1993/**
@@ -3624,8 +3620,6 @@ int regulator_suspend_finish(void)
3624 3620
3625 mutex_lock(&regulator_list_mutex); 3621 mutex_lock(&regulator_list_mutex);
3626 list_for_each_entry(rdev, &regulator_list, list) { 3622 list_for_each_entry(rdev, &regulator_list, list) {
3627 struct regulator_ops *ops = rdev->desc->ops;
3628
3629 mutex_lock(&rdev->mutex); 3623 mutex_lock(&rdev->mutex);
3630 if (rdev->use_count > 0 || rdev->constraints->always_on) { 3624 if (rdev->use_count > 0 || rdev->constraints->always_on) {
3631 error = _regulator_do_enable(rdev); 3625 error = _regulator_do_enable(rdev);
@@ -3634,12 +3628,10 @@ int regulator_suspend_finish(void)
3634 } else { 3628 } else {
3635 if (!have_full_constraints()) 3629 if (!have_full_constraints())
3636 goto unlock; 3630 goto unlock;
3637 if (!ops->disable)
3638 goto unlock;
3639 if (!_regulator_is_enabled(rdev)) 3631 if (!_regulator_is_enabled(rdev))
3640 goto unlock; 3632 goto unlock;
3641 3633
3642 error = ops->disable(rdev); 3634 error = _regulator_do_disable(rdev);
3643 if (error) 3635 if (error)
3644 ret = error; 3636 ret = error;
3645 } 3637 }
@@ -3813,7 +3805,7 @@ static int __init regulator_init_complete(void)
3813 ops = rdev->desc->ops; 3805 ops = rdev->desc->ops;
3814 c = rdev->constraints; 3806 c = rdev->constraints;
3815 3807
3816 if (!ops->disable || (c && c->always_on)) 3808 if (c && c->always_on)
3817 continue; 3809 continue;
3818 3810
3819 mutex_lock(&rdev->mutex); 3811 mutex_lock(&rdev->mutex);
@@ -3834,7 +3826,7 @@ static int __init regulator_init_complete(void)
3834 /* We log since this may kill the system if it 3826 /* We log since this may kill the system if it
3835 * goes wrong. */ 3827 * goes wrong. */
3836 rdev_info(rdev, "disabling\n"); 3828 rdev_info(rdev, "disabling\n");
3837 ret = ops->disable(rdev); 3829 ret = _regulator_do_disable(rdev);
3838 if (ret != 0) 3830 if (ret != 0)
3839 rdev_err(rdev, "couldn't disable: %d\n", ret); 3831 rdev_err(rdev, "couldn't disable: %d\n", ret);
3840 } else { 3832 } else {