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>
This commit is contained in:
Mark Brown 2009-08-03 18:49:56 +01:00 коммит произвёл Liam Girdwood
Родитель f25e0b4fcc
Коммит 9332546fe8
1 изменённых файлов: 16 добавлений и 14 удалений

Просмотреть файл

@ -280,8 +280,13 @@ static ssize_t regulator_state_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct regulator_dev *rdev = dev_get_drvdata(dev); struct regulator_dev *rdev = dev_get_drvdata(dev);
ssize_t ret;
return regulator_print_state(buf, _regulator_is_enabled(rdev)); mutex_lock(&rdev->mutex);
ret = regulator_print_state(buf, _regulator_is_enabled(rdev));
mutex_unlock(&rdev->mutex);
return ret;
} }
static DEVICE_ATTR(state, 0444, regulator_state_show, NULL); static DEVICE_ATTR(state, 0444, regulator_state_show, NULL);
@ -1365,20 +1370,11 @@ EXPORT_SYMBOL_GPL(regulator_force_disable);
static int _regulator_is_enabled(struct regulator_dev *rdev) static int _regulator_is_enabled(struct regulator_dev *rdev)
{ {
int ret;
mutex_lock(&rdev->mutex);
/* sanity check */ /* sanity check */
if (!rdev->desc->ops->is_enabled) { if (!rdev->desc->ops->is_enabled)
ret = -EINVAL; return -EINVAL;
goto out;
}
ret = rdev->desc->ops->is_enabled(rdev); return rdev->desc->ops->is_enabled(rdev);
out:
mutex_unlock(&rdev->mutex);
return ret;
} }
/** /**
@ -1395,7 +1391,13 @@ out:
*/ */
int regulator_is_enabled(struct regulator *regulator) int regulator_is_enabled(struct regulator *regulator)
{ {
return _regulator_is_enabled(regulator->rdev); int ret;
mutex_lock(&regulator->rdev->mutex);
ret = _regulator_is_enabled(regulator->rdev);
mutex_unlock(&regulator->rdev->mutex);
return ret;
} }
EXPORT_SYMBOL_GPL(regulator_is_enabled); EXPORT_SYMBOL_GPL(regulator_is_enabled);