aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2009-08-03 13:49:56 -0400
committerLiam Girdwood <lrg@slimlogic.co.uk>2009-09-22 08:32:40 -0400
commit9332546fe88fa88bf6a7d9b1dce53ff5d314934e (patch)
tree494440be4b76ad3dadd71fd426fd2a58d59c8726 /drivers/regulator
parentf25e0b4fcc38d120e704c377791158c4b2a54daa (diff)
regulator: Push locking for regulator_is_enabled() out
Allows use by more of the internal regulator API code. Signed-off-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.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index dfbf4312ec34..60fcd986ff3f 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -280,8 +280,13 @@ static ssize_t regulator_state_show(struct device *dev,
280 struct device_attribute *attr, char *buf) 280 struct device_attribute *attr, char *buf)
281{ 281{
282 struct regulator_dev *rdev = dev_get_drvdata(dev); 282 struct regulator_dev *rdev = dev_get_drvdata(dev);
283 ssize_t ret;
284
285 mutex_lock(&rdev->mutex);
286 ret = regulator_print_state(buf, _regulator_is_enabled(rdev));
287 mutex_unlock(&rdev->mutex);
283 288
284 return regulator_print_state(buf, _regulator_is_enabled(rdev)); 289 return ret;
285} 290}
286static DEVICE_ATTR(state, 0444, regulator_state_show, NULL); 291static DEVICE_ATTR(state, 0444, regulator_state_show, NULL);
287 292
@@ -1365,20 +1370,11 @@ EXPORT_SYMBOL_GPL(regulator_force_disable);
1365 1370
1366static int _regulator_is_enabled(struct regulator_dev *rdev) 1371static int _regulator_is_enabled(struct regulator_dev *rdev)
1367{ 1372{
1368 int ret;
1369
1370 mutex_lock(&rdev->mutex);
1371
1372 /* sanity check */ 1373 /* sanity check */
1373 if (!rdev->desc->ops->is_enabled) { 1374 if (!rdev->desc->ops->is_enabled)
1374 ret = -EINVAL; 1375 return -EINVAL;
1375 goto out;
1376 }
1377 1376
1378 ret = rdev->desc->ops->is_enabled(rdev); 1377 return rdev->desc->ops->is_enabled(rdev);
1379out:
1380 mutex_unlock(&rdev->mutex);
1381 return ret;
1382} 1378}
1383 1379
1384/** 1380/**
@@ -1395,7 +1391,13 @@ out:
1395 */ 1391 */
1396int regulator_is_enabled(struct regulator *regulator) 1392int regulator_is_enabled(struct regulator *regulator)
1397{ 1393{
1398 return _regulator_is_enabled(regulator->rdev); 1394 int ret;
1395
1396 mutex_lock(&regulator->rdev->mutex);
1397 ret = _regulator_is_enabled(regulator->rdev);
1398 mutex_unlock(&regulator->rdev->mutex);
1399
1400 return ret;
1399} 1401}
1400EXPORT_SYMBOL_GPL(regulator_is_enabled); 1402EXPORT_SYMBOL_GPL(regulator_is_enabled);
1401 1403