power: supply: Init device wakeup after device_add()
PATCH 1/1 power: supply: Init device wakeup after device_add()
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.
---
See this thread[1] for more information on how this will be necessary.
[1] https://lkml.kernel.org/r/[email protected]
drivers/power/supply/power_supply_core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/power/supply/power_supply_core.c +5 -5
@@ -1051,14 +1051,14 @@ __power_supply_register(struct device *parent, }spin_lock_init (&psy->changed_lock); - 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;
@@ -1101,8 +1101,8 @@ __power_supply_register(struct device *parent,psy_unregister_thermal (psy); register_thermal_failed:device_del (dev); -device_add_failed: wakeup_init_failed: +device_add_failed: check_supplies_failed: dev_set_name_failed:put_device (dev);
Signature · 1 line
Sent by a computer through tubes
Quoted 53 lines · CEST Stephen Boyd
We may want to use the device pointer in
device_init_wakeup()with functions that expect the device to already be added withdevice_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 inpower_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 <[email protected]>Cc Tri Vo <[email protected]>Cc Kalesh Singh <[email protected]>Cc Ravi Chandra Sadineni <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Viresh Kumar <[email protected]>Signed-off-by Stephen Boyd <[email protected]>---
See this thread[1] for more information on how this will be necessary.
[1] https://lkml.kernel.org/r/[email protected]
drivers/power/supply/power_supply_core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/power/supply/power_supply_core.c +4
-4@@ -1051,14 +1051,14 @@ __power_supply_register(struct device *parent, }spin_lock_init (&psy->changed_lock); - 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;
drivers/power/supply/power_supply_core.c __power_supply_register(struct device *parent, · line 1108
Quoted 9 lines
drivers/power/supply/power_supply_core.c +1
-1@@ -1101,8 +1101,8 @@ __power_supply_register(struct device *parent,psy_unregister_thermal (psy); register_thermal_failed:device_del (dev); -device_add_failed: wakeup_init_failed: +device_add_failed: check_supplies_failed: dev_set_name_failed:put_device (dev);
Sebastian Reichel
maintainerHi,
Quoted 18 lines · Stephen Boyd
We may want to use the device pointer in
device_init_wakeup()with functions that expect the device to already be added withdevice_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 inpower_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 <[email protected]>Cc Tri Vo <[email protected]>Cc Kalesh Singh <[email protected]>Cc Ravi Chandra Sadineni <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Viresh Kumar <[email protected]>Signed-off-by Stephen Boyd <[email protected]>
Quoted 1 line
---
Thanks, queued.
-- Sebastian
Quoted 45 lines
See this thread[1] for more information on how this will be necessary.
[1] https://lkml.kernel.org/r/[email protected]
drivers/power/supply/power_supply_core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/power/supply/power_supply_core.c +5
-5@@ -1051,14 +1051,14 @@ __power_supply_register(struct device *parent, }spin_lock_init (&psy->changed_lock); - 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;@@ -1101,8 +1101,8 @@ __power_supply_register(struct device *parent,psy_unregister_thermal (psy); register_thermal_failed:device_del (dev); -device_add_failed: wakeup_init_failed: +device_add_failed: check_supplies_failed: dev_set_name_failed:put_device (dev);Signature · 1 line
Sent by a computer through tubes