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>
@@ -140,8 +141,13 @@ static void power_supply_deferred_register_work(struct work_struct *work)
140
141
struct power_supply * psy = container_of (work , struct power_supply ,
141
142
deferred_register_work .work );
142
143
143
- if (psy -> dev .parent )
144
- mutex_lock (& psy -> dev .parent -> mutex );
144
+ if (psy -> dev .parent ) {
145
+ while (!mutex_trylock (& psy -> dev .parent -> mutex )) {
146
+ if (psy -> removing )
147
+ return ;
148
+ msleep (10 );
149
+ }
150
+ }
145
151
146
152
power_supply_changed (psy );
147
153
@@ -1082,6 +1088,7 @@ EXPORT_SYMBOL_GPL(devm_power_supply_register_no_ws);
1082
1088
void power_supply_unregister (struct power_supply * psy )
1083
1089
{
1084
1090
WARN_ON (atomic_dec_return (& psy -> use_cnt ));
1091
+ psy -> removing = true;
1085
1092
cancel_work_sync (& psy -> changed_work );
1086
1093
cancel_delayed_work_sync (& psy -> deferred_register_work );
1087
1094
sysfs_remove_link (& psy -> dev .kobj , "powers" );
Original file line number Diff line number Diff line change @@ -269,6 +269,7 @@ struct power_supply {
269
269
spinlock_t changed_lock ;
270
270
bool changed ;
271
271
bool initialized ;
272
+ bool removing ;
272
273
atomic_t use_cnt ;
273
274
#ifdef CONFIG_THERMAL
274
275
struct thermal_zone_device * tzd ;
You can’t perform that action at this time.
0 commit comments