Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Markus Pargmann and committed by
Mark Brown
66fda75f 30c21971

+13 -21
+13 -21
drivers/regulator/core.c
··· 1901 1901 1902 1902 trace_regulator_disable_complete(rdev_get_name(rdev)); 1903 1903 1904 - _notifier_call_chain(rdev, REGULATOR_EVENT_DISABLE, 1905 - NULL); 1906 1904 return 0; 1907 1905 } 1908 1906 ··· 1924 1926 rdev_err(rdev, "failed to disable\n"); 1925 1927 return ret; 1926 1928 } 1929 + _notifier_call_chain(rdev, REGULATOR_EVENT_DISABLE, 1930 + NULL); 1927 1931 } 1928 1932 1929 1933 rdev->use_count = 0; ··· 1978 1978 { 1979 1979 int ret = 0; 1980 1980 1981 - /* force disable */ 1982 - if (rdev->desc->ops->disable) { 1983 - /* ah well, who wants to live forever... */ 1984 - ret = rdev->desc->ops->disable(rdev); 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); 1981 + ret = _regulator_do_disable(rdev); 1982 + if (ret < 0) { 1983 + rdev_err(rdev, "failed to force disable\n"); 1984 + return ret; 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 /** ··· 3620 3624 3621 3625 mutex_lock(&regulator_list_mutex); 3622 3626 list_for_each_entry(rdev, &regulator_list, list) { 3623 - struct regulator_ops *ops = rdev->desc->ops; 3624 - 3625 3627 mutex_lock(&rdev->mutex); 3626 3628 if (rdev->use_count > 0 || rdev->constraints->always_on) { 3627 3629 error = _regulator_do_enable(rdev); ··· 3628 3634 } else { 3629 3635 if (!have_full_constraints()) 3630 3636 goto unlock; 3631 - if (!ops->disable) 3632 - goto unlock; 3633 3637 if (!_regulator_is_enabled(rdev)) 3634 3638 goto unlock; 3635 3639 3636 - error = ops->disable(rdev); 3640 + error = _regulator_do_disable(rdev); 3637 3641 if (error) 3638 3642 ret = error; 3639 3643 } ··· 3805 3813 ops = rdev->desc->ops; 3806 3814 c = rdev->constraints; 3807 3815 3808 - if (!ops->disable || (c && c->always_on)) 3816 + if (c && c->always_on) 3809 3817 continue; 3810 3818 3811 3819 mutex_lock(&rdev->mutex); ··· 3826 3834 /* We log since this may kill the system if it 3827 3835 * goes wrong. */ 3828 3836 rdev_info(rdev, "disabling\n"); 3829 - ret = ops->disable(rdev); 3837 + ret = _regulator_do_disable(rdev); 3830 3838 if (ret != 0) 3831 3839 rdev_err(rdev, "couldn't disable: %d\n", ret); 3832 3840 } else {