Skip to content

Commit 8e6e44f

Browse files
committed
Merge tag 'regulator-fix-v4.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
Pull regulator fixes from Mark Brown: "The two main fixes here from Javier and Doug both fix issues seen on the Exynos-based ARM Chromebooks with reference counting of GPIO regulators over system suspend. The GPIO enable code didn't properly take account of this case (a full analysis is in Doug's commit log). This is fixed by both fixing the reference counting directly and by making the resume code skip enables it doesn't need to do. We could skip the change in the resume code but it's a very simple change and adds extra robustness against problems in other drivers" * tag 'regulator-fix-v4.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: regulator: tps65910: Add missing #include <linux/of.h> regulator: core: Fix enable GPIO reference counting regulator: Only enable disabled regulators on resume
2 parents 529d2eb + 8ca8f32 commit 8e6e44f

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

drivers/regulator/core.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,10 +1839,12 @@ static int _regulator_do_enable(struct regulator_dev *rdev)
18391839
}
18401840

18411841
if (rdev->ena_pin) {
1842-
ret = regulator_ena_gpio_ctrl(rdev, true);
1843-
if (ret < 0)
1844-
return ret;
1845-
rdev->ena_gpio_state = 1;
1842+
if (!rdev->ena_gpio_state) {
1843+
ret = regulator_ena_gpio_ctrl(rdev, true);
1844+
if (ret < 0)
1845+
return ret;
1846+
rdev->ena_gpio_state = 1;
1847+
}
18461848
} else if (rdev->desc->ops->enable) {
18471849
ret = rdev->desc->ops->enable(rdev);
18481850
if (ret < 0)
@@ -1939,10 +1941,12 @@ static int _regulator_do_disable(struct regulator_dev *rdev)
19391941
trace_regulator_disable(rdev_get_name(rdev));
19401942

19411943
if (rdev->ena_pin) {
1942-
ret = regulator_ena_gpio_ctrl(rdev, false);
1943-
if (ret < 0)
1944-
return ret;
1945-
rdev->ena_gpio_state = 0;
1944+
if (rdev->ena_gpio_state) {
1945+
ret = regulator_ena_gpio_ctrl(rdev, false);
1946+
if (ret < 0)
1947+
return ret;
1948+
rdev->ena_gpio_state = 0;
1949+
}
19461950

19471951
} else if (rdev->desc->ops->disable) {
19481952
ret = rdev->desc->ops->disable(rdev);
@@ -3626,12 +3630,6 @@ regulator_register(const struct regulator_desc *regulator_desc,
36263630
config->ena_gpio, ret);
36273631
goto wash;
36283632
}
3629-
3630-
if (config->ena_gpio_flags & GPIOF_OUT_INIT_HIGH)
3631-
rdev->ena_gpio_state = 1;
3632-
3633-
if (config->ena_gpio_invert)
3634-
rdev->ena_gpio_state = !rdev->ena_gpio_state;
36353633
}
36363634

36373635
/* set regulator constraints */
@@ -3800,9 +3798,11 @@ int regulator_suspend_finish(void)
38003798
list_for_each_entry(rdev, &regulator_list, list) {
38013799
mutex_lock(&rdev->mutex);
38023800
if (rdev->use_count > 0 || rdev->constraints->always_on) {
3803-
error = _regulator_do_enable(rdev);
3804-
if (error)
3805-
ret = error;
3801+
if (!_regulator_is_enabled(rdev)) {
3802+
error = _regulator_do_enable(rdev);
3803+
if (error)
3804+
ret = error;
3805+
}
38063806
} else {
38073807
if (!have_full_constraints())
38083808
goto unlock;

drivers/regulator/tps65910-regulator.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/module.h>
1818
#include <linux/init.h>
1919
#include <linux/err.h>
20+
#include <linux/of.h>
2021
#include <linux/platform_device.h>
2122
#include <linux/regulator/driver.h>
2223
#include <linux/regulator/machine.h>

0 commit comments

Comments
 (0)