diff options
author | Bengt Jonsson <bengt.g.jonsson@stericsson.com> | 2010-11-10 05:06:22 -0500 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2010-11-30 10:13:25 -0500 |
commit | f3c18a87f3ddcfd31b16f689d01eb6adcc99de74 (patch) | |
tree | 225436c35fef30ec02bbc7ec37777232fadc96b0 /drivers/regulator | |
parent | b9e26bc804e611d879353cd953cb17db1c52d307 (diff) |
regulator: enable supply regulator only when use count is zero
Supply regulators are disabled only when the last
reference count is removed on the child regulator
(the use count goes from 1 to 0). This patch changes
the behaviour of enable so the supply regulator is
enabled only when the use count of the child
regulator goes from 0 to 1.
Signed-off-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/core.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 27d062e1395c..c577c6d344ac 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -1267,15 +1267,17 @@ static int _regulator_enable(struct regulator_dev *rdev) | |||
1267 | { | 1267 | { |
1268 | int ret, delay; | 1268 | int ret, delay; |
1269 | 1269 | ||
1270 | /* do we need to enable the supply regulator first */ | 1270 | if (rdev->use_count == 0) { |
1271 | if (rdev->supply) { | 1271 | /* do we need to enable the supply regulator first */ |
1272 | mutex_lock(&rdev->supply->mutex); | 1272 | if (rdev->supply) { |
1273 | ret = _regulator_enable(rdev->supply); | 1273 | mutex_lock(&rdev->supply->mutex); |
1274 | mutex_unlock(&rdev->supply->mutex); | 1274 | ret = _regulator_enable(rdev->supply); |
1275 | if (ret < 0) { | 1275 | mutex_unlock(&rdev->supply->mutex); |
1276 | printk(KERN_ERR "%s: failed to enable %s: %d\n", | 1276 | if (ret < 0) { |
1277 | __func__, rdev_get_name(rdev), ret); | 1277 | printk(KERN_ERR "%s: failed to enable %s: %d\n", |
1278 | return ret; | 1278 | __func__, rdev_get_name(rdev), ret); |
1279 | return ret; | ||
1280 | } | ||
1279 | } | 1281 | } |
1280 | } | 1282 | } |
1281 | 1283 | ||