[lkml]   [2020]   [Jan]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 4.9 191/271] power: supply: Init device wakeup after device_add()
From: Stephen Boyd <>

[ Upstream commit 8288022284859acbcc3cf1a073a1e2692d6c2543 ]

We may want to use the device pointer in device_init_wakeup() with
functions that expect the device to already be added with device_add().
For example, if we were to link the device initializing wakeup to
something in sysfs such as a class for wakeups we'll run into an error.
It looks like this code was written with the assumption that the device
would be added before initializing wakeup due to the order of operations
in power_supply_unregister().

Let's change the order of operations so we don't run into problems here.

Fixes: 948dcf966228 ("power_supply: Prevent suspend until power supply events are processed")
Cc: Greg Kroah-Hartman <>
Cc: Tri Vo <>
Cc: Kalesh Singh <>
Cc: Ravi Chandra Sadineni <>
Cc: Viresh Kumar <>
Signed-off-by: Stephen Boyd <>
Acked-by: Rafael J. Wysocki <>
Signed-off-by: Sebastian Reichel <>
Signed-off-by: Sasha Levin <>
drivers/power/supply/power_supply_core.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index 9e05ae0430a99..cb0b3d3d132fc 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -764,14 +764,14 @@ __power_supply_register(struct device *parent,

- rc = device_init_wakeup(dev, ws);
- if (rc)
- goto wakeup_init_failed;
rc = device_add(dev);
if (rc)
goto device_add_failed;

+ rc = device_init_wakeup(dev, ws);
+ if (rc)
+ goto wakeup_init_failed;
rc = psy_register_thermal(psy);
if (rc)
goto register_thermal_failed;
@@ -808,8 +808,8 @@ register_cooler_failed:

 \ /
  Last update: 2020-01-28 15:24    [W:0.903 / U:6.104 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site