File tree 2 files changed +10
-2
lines changed 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change 14
14
#include <linux/types.h>
15
15
#include <linux/init.h>
16
16
#include <linux/slab.h>
17
+ #include <linux/delay.h>
17
18
#include <linux/device.h>
18
19
#include <linux/notifier.h>
19
20
#include <linux/err.h>
@@ -139,8 +140,13 @@ static void power_supply_deferred_register_work(struct work_struct *work)
139
140
struct power_supply * psy = container_of (work , struct power_supply ,
140
141
deferred_register_work .work );
141
142
142
- if (psy -> dev .parent )
143
- mutex_lock (& psy -> dev .parent -> mutex );
143
+ if (psy -> dev .parent ) {
144
+ while (!mutex_trylock (& psy -> dev .parent -> mutex )) {
145
+ if (psy -> removing )
146
+ return ;
147
+ msleep (10 );
148
+ }
149
+ }
144
150
145
151
power_supply_changed (psy );
146
152
@@ -1071,6 +1077,7 @@ EXPORT_SYMBOL_GPL(devm_power_supply_register_no_ws);
1071
1077
void power_supply_unregister (struct power_supply * psy )
1072
1078
{
1073
1079
WARN_ON (atomic_dec_return (& psy -> use_cnt ));
1080
+ psy -> removing = true;
1074
1081
cancel_work_sync (& psy -> changed_work );
1075
1082
cancel_delayed_work_sync (& psy -> deferred_register_work );
1076
1083
sysfs_remove_link (& psy -> dev .kobj , "powers" );
Original file line number Diff line number Diff line change @@ -251,6 +251,7 @@ struct power_supply {
251
251
spinlock_t changed_lock ;
252
252
bool changed ;
253
253
bool initialized ;
254
+ bool removing ;
254
255
atomic_t use_cnt ;
255
256
#ifdef CONFIG_THERMAL
256
257
struct thermal_zone_device * tzd ;
You can’t perform that action at this time.
0 commit comments