Skip to content

Commit 50a4606

Browse files
committed
PM: runtime: Simplify locking in pm_runtime_put_suppliers()
Notice that pm_runtime_put_suppliers() cannot be called with disabled interrupts, because it may sleep (due to the device links read locking in the non-SRCU case), and so it can use spin_lock_irq() and spin_unlock_irq() for the locking. Update the function accordingly and while at it move the "put" local variable in it into the inner block where it is used. This change is not expected to have any visible functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent e4719b5 commit 50a4606

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/base/power/runtime.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,20 +1748,24 @@ void pm_runtime_get_suppliers(struct device *dev)
17481748
void pm_runtime_put_suppliers(struct device *dev)
17491749
{
17501750
struct device_link *link;
1751-
unsigned long flags;
1752-
bool put;
17531751
int idx;
17541752

17551753
idx = device_links_read_lock();
17561754

17571755
list_for_each_entry_rcu(link, &dev->links.suppliers, c_node,
17581756
device_links_read_lock_held())
17591757
if (link->supplier_preactivated) {
1758+
bool put;
1759+
17601760
link->supplier_preactivated = false;
1761-
spin_lock_irqsave(&dev->power.lock, flags);
1761+
1762+
spin_lock_irq(&dev->power.lock);
1763+
17621764
put = pm_runtime_status_suspended(dev) &&
17631765
refcount_dec_not_one(&link->rpm_active);
1764-
spin_unlock_irqrestore(&dev->power.lock, flags);
1766+
1767+
spin_unlock_irq(&dev->power.lock);
1768+
17651769
if (put)
17661770
pm_runtime_put(link->supplier);
17671771
}

0 commit comments

Comments
 (0)