aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power/supply
diff options
context:
space:
mode:
authorStephen Boyd <swboyd@chromium.org>2019-08-01 17:33:30 -0400
committerSebastian Reichel <sre@kernel.org>2019-09-02 04:06:31 -0400
commit8288022284859acbcc3cf1a073a1e2692d6c2543 (patch)
tree637eb98a0d0bec79bd7d92a240b46fe87aeccaf0 /drivers/power/supply
parent10948061162a4bd9c54086e04dc8cd11faaf5bb5 (diff)
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. Fixes: 948dcf966228 ("power_supply: Prevent suspend until power supply events are processed") Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Tri Vo <trong@android.com> Cc: Kalesh Singh <kaleshsingh@google.com> Cc: Ravi Chandra Sadineni <ravisadineni@chromium.org> Cc: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Stephen Boyd <swboyd@chromium.org> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power/supply')
-rw-r--r--drivers/power/supply/power_supply_core.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index 82e84801264c..5c36c430ce8b 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -1051,14 +1051,14 @@ __power_supply_register(struct device *parent,
1051 } 1051 }
1052 1052
1053 spin_lock_init(&psy->changed_lock); 1053 spin_lock_init(&psy->changed_lock);
1054 rc = device_init_wakeup(dev, ws);
1055 if (rc)
1056 goto wakeup_init_failed;
1057
1058 rc = device_add(dev); 1054 rc = device_add(dev);
1059 if (rc) 1055 if (rc)
1060 goto device_add_failed; 1056 goto device_add_failed;
1061 1057
1058 rc = device_init_wakeup(dev, ws);
1059 if (rc)
1060 goto wakeup_init_failed;
1061
1062 rc = psy_register_thermal(psy); 1062 rc = psy_register_thermal(psy);
1063 if (rc) 1063 if (rc)
1064 goto register_thermal_failed; 1064 goto register_thermal_failed;
@@ -1101,8 +1101,8 @@ register_cooler_failed:
1101 psy_unregister_thermal(psy); 1101 psy_unregister_thermal(psy);
1102register_thermal_failed: 1102register_thermal_failed:
1103 device_del(dev); 1103 device_del(dev);
1104device_add_failed:
1105wakeup_init_failed: 1104wakeup_init_failed:
1105device_add_failed:
1106check_supplies_failed: 1106check_supplies_failed:
1107dev_set_name_failed: 1107dev_set_name_failed:
1108 put_device(dev); 1108 put_device(dev);