Skip to contentSkip to conversation

power: supply: core: Remove might_sleep() from power_supply_put()

PATCH Applied Bart Van Assche 3 participants 3 messages Sep 17, 2024 – Oct 15, 2024 Power supply

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 power: supply: core: Remove might_sleep() from power_supply_put()

The put_device() call in power_supply_put() may call power_supply_dev_release(). The latter function does not sleep so power_supply_put() doesn't sleep either. Hence, remove the might_sleep() call from power_supply_put(). This patch suppresses false positive complaints about calling a sleeping function from atomic context if power_supply_put() is called from atomic context.

Cc Kyle Tso <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Fixes 1a352462b537 ("power_supply: Add power_supply_put for decrementing device reference counter")
---
 drivers/power/supply/power_supply_core.c | 2 --
 1 file changed, 2 deletions(-)
drivers/power/supply/power_supply_core.c +0 -2
index 8f6025acd10a..3c493555c5a4 100644
@@ -483,8 +483,6 @@ EXPORT_SYMBOL_GPL(power_supply_get_by_name);
  */
 void power_supply_put(struct power_supply *psy)
 {
-	might_sleep();
-
 	atomic_dec(&psy->use_cnt);
 	put_device(&psy->dev);
 }
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Bart Van Assche

The put_device() call in power_supply_put() may call power_supply_dev_release(). The latter function does not sleep so power_supply_put() doesn't sleep either. Hence, remove the might_sleep() call from power_supply_put(). This patch suppresses false positive complaints about calling a sleeping function from atomic context if power_supply_put() is called from atomic context.

Quoted 7 lines
Cc Kyle Tso <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Fixes 1a352462b537 ("power_supply: Add power_supply_put for decrementing device reference counter")
---
 drivers/power/supply/power_supply_core.c | 2 --
 1 file changed, 2 deletions(-)

Best regards,
Krzysztof

#2 lore raw
In reply to Bart Van Assche
Quoted 8 lines · Bart Van Assche

The put_device() call in power_supply_put() may call power_supply_dev_release(). The latter function does not sleep so power_supply_put() doesn't sleep either. Hence, remove the might_sleep() call from power_supply_put(). This patch suppresses false positive complaints about calling a sleeping function from atomic context if power_supply_put() is called from atomic context.

[...]

Applied, thanks!

[1/1] power: supply: core: Remove might_sleep() from power_supply_put()

      commit: f6da4553ff24a5d1c959c9627c965323adc3d307

Best regards,

Signature · 1 line
Sebastian Reichel <[email protected]>