diff options
author | Markus Pargmann <mpa@pengutronix.de> | 2014-02-20 11:36:04 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-03-31 12:58:13 -0400 |
commit | 0f79475d04f898d21397eb787a2cdf3aefffbbd6 (patch) | |
tree | 8d3d78747827aa9a533007e8b2a66b6469836fb1 | |
parent | d30a14a3f02d6d3aa51f429305c53905317bb4a7 (diff) |
regulator: core: Replace direct ops->disable usage
commit 66fda75f47dc583f1c187556e9a2c082dd64f8c6 upstream.
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.
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/regulator/core.c | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index c59cc6ed7adb..a86d12326137 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -1712,8 +1712,6 @@ static int _regulator_do_disable(struct regulator_dev *rdev) | |||
1712 | 1712 | ||
1713 | trace_regulator_disable_complete(rdev_get_name(rdev)); | 1713 | trace_regulator_disable_complete(rdev_get_name(rdev)); |
1714 | 1714 | ||
1715 | _notifier_call_chain(rdev, REGULATOR_EVENT_DISABLE, | ||
1716 | NULL); | ||
1717 | return 0; | 1715 | return 0; |
1718 | } | 1716 | } |
1719 | 1717 | ||
@@ -1737,6 +1735,8 @@ static int _regulator_disable(struct regulator_dev *rdev) | |||
1737 | rdev_err(rdev, "failed to disable\n"); | 1735 | rdev_err(rdev, "failed to disable\n"); |
1738 | return ret; | 1736 | return ret; |
1739 | } | 1737 | } |
1738 | _notifier_call_chain(rdev, REGULATOR_EVENT_DISABLE, | ||
1739 | NULL); | ||
1740 | } | 1740 | } |
1741 | 1741 | ||
1742 | rdev->use_count = 0; | 1742 | rdev->use_count = 0; |
@@ -1789,20 +1789,16 @@ static int _regulator_force_disable(struct regulator_dev *rdev) | |||
1789 | { | 1789 | { |
1790 | int ret = 0; | 1790 | int ret = 0; |
1791 | 1791 | ||
1792 | /* force disable */ | 1792 | ret = _regulator_do_disable(rdev); |
1793 | if (rdev->desc->ops->disable) { | 1793 | if (ret < 0) { |
1794 | /* ah well, who wants to live forever... */ | 1794 | rdev_err(rdev, "failed to force disable\n"); |
1795 | ret = rdev->desc->ops->disable(rdev); | 1795 | return ret; |
1796 | if (ret < 0) { | ||
1797 | rdev_err(rdev, "failed to force disable\n"); | ||
1798 | return ret; | ||
1799 | } | ||
1800 | /* notify other consumers that power has been forced off */ | ||
1801 | _notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE | | ||
1802 | REGULATOR_EVENT_DISABLE, NULL); | ||
1803 | } | 1796 | } |
1804 | 1797 | ||
1805 | return ret; | 1798 | _notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE | |
1799 | REGULATOR_EVENT_DISABLE, NULL); | ||
1800 | |||
1801 | return 0; | ||
1806 | } | 1802 | } |
1807 | 1803 | ||
1808 | /** | 1804 | /** |
@@ -3788,8 +3784,6 @@ int regulator_suspend_finish(void) | |||
3788 | 3784 | ||
3789 | mutex_lock(®ulator_list_mutex); | 3785 | mutex_lock(®ulator_list_mutex); |
3790 | list_for_each_entry(rdev, ®ulator_list, list) { | 3786 | list_for_each_entry(rdev, ®ulator_list, list) { |
3791 | struct regulator_ops *ops = rdev->desc->ops; | ||
3792 | |||
3793 | mutex_lock(&rdev->mutex); | 3787 | mutex_lock(&rdev->mutex); |
3794 | if (rdev->use_count > 0 || rdev->constraints->always_on) { | 3788 | if (rdev->use_count > 0 || rdev->constraints->always_on) { |
3795 | error = _regulator_do_enable(rdev); | 3789 | error = _regulator_do_enable(rdev); |
@@ -3798,12 +3792,10 @@ int regulator_suspend_finish(void) | |||
3798 | } else { | 3792 | } else { |
3799 | if (!has_full_constraints) | 3793 | if (!has_full_constraints) |
3800 | goto unlock; | 3794 | goto unlock; |
3801 | if (!ops->disable) | ||
3802 | goto unlock; | ||
3803 | if (!_regulator_is_enabled(rdev)) | 3795 | if (!_regulator_is_enabled(rdev)) |
3804 | goto unlock; | 3796 | goto unlock; |
3805 | 3797 | ||
3806 | error = ops->disable(rdev); | 3798 | error = _regulator_do_disable(rdev); |
3807 | if (error) | 3799 | if (error) |
3808 | ret = error; | 3800 | ret = error; |
3809 | } | 3801 | } |
@@ -3993,7 +3985,7 @@ static int __init regulator_init_complete(void) | |||
3993 | ops = rdev->desc->ops; | 3985 | ops = rdev->desc->ops; |
3994 | c = rdev->constraints; | 3986 | c = rdev->constraints; |
3995 | 3987 | ||
3996 | if (!ops->disable || (c && c->always_on)) | 3988 | if (c && c->always_on) |
3997 | continue; | 3989 | continue; |
3998 | 3990 | ||
3999 | mutex_lock(&rdev->mutex); | 3991 | mutex_lock(&rdev->mutex); |
@@ -4014,7 +4006,7 @@ static int __init regulator_init_complete(void) | |||
4014 | /* We log since this may kill the system if it | 4006 | /* We log since this may kill the system if it |
4015 | * goes wrong. */ | 4007 | * goes wrong. */ |
4016 | rdev_info(rdev, "disabling\n"); | 4008 | rdev_info(rdev, "disabling\n"); |
4017 | ret = ops->disable(rdev); | 4009 | ret = _regulator_do_disable(rdev); |
4018 | if (ret != 0) { | 4010 | if (ret != 0) { |
4019 | rdev_err(rdev, "couldn't disable: %d\n", ret); | 4011 | rdev_err(rdev, "couldn't disable: %d\n", ret); |
4020 | } | 4012 | } |