NVIDIA: SAUCE: Revert "NVIDIA: SAUCE: WAR: regulator: core: Revert "Only increment use_count when enable_count changes""
This reverts commit e3c56dbeba7a40d5526d0e3db1150579bf652b31. This issue has been fixed by and so we can remove this revert. http://nvbugs/4616839 http://nvbugs/4327795 Signed-off-by: Jon Hunter <jonathanh@nvidia.com> Reviewed-by: Wayne Chang <waynec@nvidia.com> Signed-off-by: Kartik Rajput <kkartik@nvidia.com> Acked-by: Noah Wager <noah.wager@canonical.com> Acked-by: Jacob Martin <jacob.martin@canonical.com> Signed-off-by: Noah Wager <noah.wager@canonical.com>
This commit is contained in:
+28
-24
@@ -2925,7 +2925,8 @@ static int _regulator_enable(struct regulator *regulator)
|
||||
/* Fallthrough on positive return values - already enabled */
|
||||
}
|
||||
|
||||
rdev->use_count++;
|
||||
if (regulator->enable_count == 1)
|
||||
rdev->use_count++;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -3000,37 +3001,40 @@ static int _regulator_disable(struct regulator *regulator)
|
||||
|
||||
lockdep_assert_held_once(&rdev->mutex.base);
|
||||
|
||||
if (WARN(rdev->use_count <= 0,
|
||||
if (WARN(regulator->enable_count == 0,
|
||||
"unbalanced disables for %s\n", rdev_get_name(rdev)))
|
||||
return -EIO;
|
||||
|
||||
/* are we the last user and permitted to disable ? */
|
||||
if (rdev->use_count == 1 &&
|
||||
(rdev->constraints && !rdev->constraints->always_on)) {
|
||||
if (regulator->enable_count == 1) {
|
||||
/* disabling last enable_count from this regulator */
|
||||
/* are we the last user and permitted to disable ? */
|
||||
if (rdev->use_count == 1 &&
|
||||
(rdev->constraints && !rdev->constraints->always_on)) {
|
||||
|
||||
/* we are last user */
|
||||
if (regulator_ops_is_valid(rdev, REGULATOR_CHANGE_STATUS)) {
|
||||
ret = _notifier_call_chain(rdev,
|
||||
REGULATOR_EVENT_PRE_DISABLE,
|
||||
NULL);
|
||||
if (ret & NOTIFY_STOP_MASK)
|
||||
return -EINVAL;
|
||||
/* we are last user */
|
||||
if (regulator_ops_is_valid(rdev, REGULATOR_CHANGE_STATUS)) {
|
||||
ret = _notifier_call_chain(rdev,
|
||||
REGULATOR_EVENT_PRE_DISABLE,
|
||||
NULL);
|
||||
if (ret & NOTIFY_STOP_MASK)
|
||||
return -EINVAL;
|
||||
|
||||
ret = _regulator_do_disable(rdev);
|
||||
if (ret < 0) {
|
||||
rdev_err(rdev, "failed to disable: %pe\n", ERR_PTR(ret));
|
||||
_notifier_call_chain(rdev,
|
||||
REGULATOR_EVENT_ABORT_DISABLE,
|
||||
ret = _regulator_do_disable(rdev);
|
||||
if (ret < 0) {
|
||||
rdev_err(rdev, "failed to disable: %pe\n", ERR_PTR(ret));
|
||||
_notifier_call_chain(rdev,
|
||||
REGULATOR_EVENT_ABORT_DISABLE,
|
||||
NULL);
|
||||
return ret;
|
||||
}
|
||||
_notifier_call_chain(rdev, REGULATOR_EVENT_DISABLE,
|
||||
NULL);
|
||||
return ret;
|
||||
}
|
||||
_notifier_call_chain(rdev, REGULATOR_EVENT_DISABLE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
rdev->use_count = 0;
|
||||
} else if (rdev->use_count > 1) {
|
||||
rdev->use_count--;
|
||||
rdev->use_count = 0;
|
||||
} else if (rdev->use_count > 1) {
|
||||
rdev->use_count--;
|
||||
}
|
||||
}
|
||||
|
||||
if (ret == 0)
|
||||
|
||||
Reference in New Issue
Block a user