File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change 1414#include <linux/types.h>
1515#include <linux/init.h>
1616#include <linux/slab.h>
17+ #include <linux/delay.h>
1718#include <linux/device.h>
1819#include <linux/notifier.h>
1920#include <linux/err.h>
@@ -138,8 +139,13 @@ static void power_supply_deferred_register_work(struct work_struct *work)
138139 struct power_supply * psy = container_of (work , struct power_supply ,
139140 deferred_register_work .work );
140141
141- if (psy -> dev .parent )
142- mutex_lock (& psy -> dev .parent -> mutex );
142+ if (psy -> dev .parent ) {
143+ while (!mutex_trylock (& psy -> dev .parent -> mutex )) {
144+ if (psy -> removing )
145+ return ;
146+ msleep (10 );
147+ }
148+ }
143149
144150 power_supply_changed (psy );
145151
@@ -944,6 +950,7 @@ EXPORT_SYMBOL_GPL(devm_power_supply_register_no_ws);
944950void power_supply_unregister (struct power_supply * psy )
945951{
946952 WARN_ON (atomic_dec_return (& psy -> use_cnt ));
953+ psy -> removing = true;
947954 cancel_work_sync (& psy -> changed_work );
948955 cancel_delayed_work_sync (& psy -> deferred_register_work );
949956 sysfs_remove_link (& psy -> dev .kobj , "powers" );
Original file line number Diff line number Diff line change @@ -249,6 +249,7 @@ struct power_supply {
249249 spinlock_t changed_lock ;
250250 bool changed ;
251251 bool initialized ;
252+ bool removing ;
252253 atomic_t use_cnt ;
253254#ifdef CONFIG_THERMAL
254255 struct thermal_zone_device * tzd ;
You can’t perform that action at this time.
0 commit comments