mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux-stable.git
synced 2025-11-08 15:13:19 +10:00
PM: runtime: Take active children into account in pm_runtime_get_if_in_use()
[ Upstream commit51888393cc] For all practical purposes, there is no difference between the situation in which a given device is not ignoring children and its active child count is nonzero and the situation in which its runtime PM usage counter is nonzero. However, pm_runtime_get_if_in_use() will only increment the device's usage counter and return 1 in the latter case. For consistency, make it do so in the former case either by adjusting pm_runtime_get_conditional() and update the related kerneldoc comments accordingly. Fixes:c111566bea("PM: runtime: Add pm_runtime_get_if_active()") Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com> Cc: 5.10+ <stable@vger.kernel.org> # 5.10+:c0ef3df8db: PM: runtime: Simplify pm_runtime_get_if_active() usage Cc: 5.10+ <stable@vger.kernel.org> # 5.10+ Link: https://patch.msgid.link/12700973.O9o76ZdvQC@rjwysocki.net Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
ac2e62cab0
commit
9e9b1fa7ec
@ -1181,10 +1181,12 @@ EXPORT_SYMBOL_GPL(__pm_runtime_resume);
|
||||
*
|
||||
* Return -EINVAL if runtime PM is disabled for @dev.
|
||||
*
|
||||
* Otherwise, if the runtime PM status of @dev is %RPM_ACTIVE and either
|
||||
* @ign_usage_count is %true or the runtime PM usage counter of @dev is not
|
||||
* zero, increment the usage counter of @dev and return 1. Otherwise, return 0
|
||||
* without changing the usage counter.
|
||||
* Otherwise, if its runtime PM status is %RPM_ACTIVE and (1) @ign_usage_count
|
||||
* is set, or (2) @dev is not ignoring children and its active child count is
|
||||
* nonero, or (3) the runtime PM usage counter of @dev is not zero, increment
|
||||
* the usage counter of @dev and return 1.
|
||||
*
|
||||
* Otherwise, return 0 without changing the usage counter.
|
||||
*
|
||||
* If @ign_usage_count is %true, this function can be used to prevent suspending
|
||||
* the device when its runtime PM status is %RPM_ACTIVE.
|
||||
@ -1206,7 +1208,8 @@ static int pm_runtime_get_conditional(struct device *dev, bool ign_usage_count)
|
||||
retval = -EINVAL;
|
||||
} else if (dev->power.runtime_status != RPM_ACTIVE) {
|
||||
retval = 0;
|
||||
} else if (ign_usage_count) {
|
||||
} else if (ign_usage_count || (!dev->power.ignore_children &&
|
||||
atomic_read(&dev->power.child_count) > 0)) {
|
||||
retval = 1;
|
||||
atomic_inc(&dev->power.usage_count);
|
||||
} else {
|
||||
@ -1239,10 +1242,16 @@ EXPORT_SYMBOL_GPL(pm_runtime_get_if_active);
|
||||
* @dev: Target device.
|
||||
*
|
||||
* Increment the runtime PM usage counter of @dev if its runtime PM status is
|
||||
* %RPM_ACTIVE and its runtime PM usage counter is greater than 0, in which case
|
||||
* it returns 1. If the device is in a different state or its usage_count is 0,
|
||||
* 0 is returned. -EINVAL is returned if runtime PM is disabled for the device,
|
||||
* in which case also the usage_count will remain unmodified.
|
||||
* %RPM_ACTIVE and its runtime PM usage counter is greater than 0 or it is not
|
||||
* ignoring children and its active child count is nonzero. 1 is returned in
|
||||
* this case.
|
||||
*
|
||||
* If @dev is in a different state or it is not in use (that is, its usage
|
||||
* counter is 0, or it is ignoring children, or its active child count is 0),
|
||||
* 0 is returned.
|
||||
*
|
||||
* -EINVAL is returned if runtime PM is disabled for the device, in which case
|
||||
* also the usage counter of @dev is not updated.
|
||||
*/
|
||||
int pm_runtime_get_if_in_use(struct device *dev)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user