diff options
author | Sebastian Reichel <sre@kernel.org> | 2018-08-16 22:19:22 +0200 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2018-08-16 22:19:22 +0200 |
commit | 5198a48381455969aa1053a0ca2e4ce409be2fc2 (patch) | |
tree | 881914c4a5349e45285d686b1a513c678fcd6894 /drivers/power/supply/power_supply_core.c | |
parent | 3d779180c69261f5c713832e46763e38589c18d3 (diff) | |
parent | cc44ba91166beb78f9cb29d5e3d41c0a2d0a7329 (diff) | |
download | lwn-5198a48381455969aa1053a0ca2e4ce409be2fc2.tar.gz lwn-5198a48381455969aa1053a0ca2e4ce409be2fc2.zip |
Merge branch 'psy-fixes' into psy-next
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/power/supply/power_supply_core.c')
-rw-r--r-- | drivers/power/supply/power_supply_core.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index d21f478741c1..e85361878450 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -14,6 +14,7 @@ #include <linux/types.h> #include <linux/init.h> #include <linux/slab.h> +#include <linux/delay.h> #include <linux/device.h> #include <linux/notifier.h> #include <linux/err.h> @@ -140,8 +141,13 @@ static void power_supply_deferred_register_work(struct work_struct *work) struct power_supply *psy = container_of(work, struct power_supply, deferred_register_work.work); - if (psy->dev.parent) - mutex_lock(&psy->dev.parent->mutex); + if (psy->dev.parent) { + while (!mutex_trylock(&psy->dev.parent->mutex)) { + if (psy->removing) + return; + msleep(10); + } + } power_supply_changed(psy); @@ -1082,6 +1088,7 @@ EXPORT_SYMBOL_GPL(devm_power_supply_register_no_ws); void power_supply_unregister(struct power_supply *psy) { WARN_ON(atomic_dec_return(&psy->use_cnt)); + psy->removing = true; cancel_work_sync(&psy->changed_work); cancel_delayed_work_sync(&psy->deferred_register_work); sysfs_remove_link(&psy->dev.kobj, "powers"); |