mirror of https://gitee.com/openkylin/linux.git
regulator: Add lockdep asserts to help detecting locking misuse
Add lockdep_assert_held_once() to functions explicitly mentioning that rdev or regulator_list mutex must be held. Using WARN_ONCE shouldn't pollute the dmesg to much. The patch (if CONFIG_LOCKDEP enabled) will show warnings in certain regulators calling regulator_notifier_call_chain() without rdev->mutex held. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
d770e558e2
commit
70cfef2626
|
@ -640,6 +640,8 @@ static int drms_uA_update(struct regulator_dev *rdev)
|
||||||
int current_uA = 0, output_uV, input_uV, err;
|
int current_uA = 0, output_uV, input_uV, err;
|
||||||
unsigned int mode;
|
unsigned int mode;
|
||||||
|
|
||||||
|
lockdep_assert_held_once(&rdev->mutex);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* first check to see if we can set modes at all, otherwise just
|
* first check to see if we can set modes at all, otherwise just
|
||||||
* tell the consumer everything is OK.
|
* tell the consumer everything is OK.
|
||||||
|
@ -760,6 +762,8 @@ static int suspend_set_state(struct regulator_dev *rdev,
|
||||||
/* locks held by caller */
|
/* locks held by caller */
|
||||||
static int suspend_prepare(struct regulator_dev *rdev, suspend_state_t state)
|
static int suspend_prepare(struct regulator_dev *rdev, suspend_state_t state)
|
||||||
{
|
{
|
||||||
|
lockdep_assert_held_once(&rdev->mutex);
|
||||||
|
|
||||||
if (!rdev->constraints)
|
if (!rdev->constraints)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
@ -1587,6 +1591,8 @@ static void _regulator_put(struct regulator *regulator)
|
||||||
if (regulator == NULL || IS_ERR(regulator))
|
if (regulator == NULL || IS_ERR(regulator))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
lockdep_assert_held_once(®ulator_list_mutex);
|
||||||
|
|
||||||
rdev = regulator->rdev;
|
rdev = regulator->rdev;
|
||||||
|
|
||||||
debugfs_remove_recursive(regulator->debugfs);
|
debugfs_remove_recursive(regulator->debugfs);
|
||||||
|
@ -1965,6 +1971,8 @@ static int _regulator_enable(struct regulator_dev *rdev)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
lockdep_assert_held_once(&rdev->mutex);
|
||||||
|
|
||||||
/* check voltage and requested load before enabling */
|
/* check voltage and requested load before enabling */
|
||||||
if (rdev->constraints &&
|
if (rdev->constraints &&
|
||||||
(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_DRMS))
|
(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_DRMS))
|
||||||
|
@ -2065,6 +2073,8 @@ static int _regulator_disable(struct regulator_dev *rdev)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
lockdep_assert_held_once(&rdev->mutex);
|
||||||
|
|
||||||
if (WARN(rdev->use_count <= 0,
|
if (WARN(rdev->use_count <= 0,
|
||||||
"unbalanced disables for %s\n", rdev_get_name(rdev)))
|
"unbalanced disables for %s\n", rdev_get_name(rdev)))
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
@ -2143,6 +2153,8 @@ static int _regulator_force_disable(struct regulator_dev *rdev)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
lockdep_assert_held_once(&rdev->mutex);
|
||||||
|
|
||||||
ret = _notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE |
|
ret = _notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE |
|
||||||
REGULATOR_EVENT_PRE_DISABLE, NULL);
|
REGULATOR_EVENT_PRE_DISABLE, NULL);
|
||||||
if (ret & NOTIFY_STOP_MASK)
|
if (ret & NOTIFY_STOP_MASK)
|
||||||
|
@ -3439,6 +3451,8 @@ EXPORT_SYMBOL_GPL(regulator_bulk_free);
|
||||||
int regulator_notifier_call_chain(struct regulator_dev *rdev,
|
int regulator_notifier_call_chain(struct regulator_dev *rdev,
|
||||||
unsigned long event, void *data)
|
unsigned long event, void *data)
|
||||||
{
|
{
|
||||||
|
lockdep_assert_held_once(&rdev->mutex);
|
||||||
|
|
||||||
_notifier_call_chain(rdev, event, data);
|
_notifier_call_chain(rdev, event, data);
|
||||||
return NOTIFY_DONE;
|
return NOTIFY_DONE;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue