@@ -38,7 +38,7 @@ int nfc_fw_download(struct nfc_dev *dev, const char *firmware_name)
38
38
39
39
device_lock (& dev -> dev );
40
40
41
- if (! device_is_registered ( & dev -> dev ) ) {
41
+ if (dev -> shutting_down ) {
42
42
rc = - ENODEV ;
43
43
goto error ;
44
44
}
@@ -94,7 +94,7 @@ int nfc_dev_up(struct nfc_dev *dev)
94
94
95
95
device_lock (& dev -> dev );
96
96
97
- if (! device_is_registered ( & dev -> dev ) ) {
97
+ if (dev -> shutting_down ) {
98
98
rc = - ENODEV ;
99
99
goto error ;
100
100
}
@@ -142,7 +142,7 @@ int nfc_dev_down(struct nfc_dev *dev)
142
142
143
143
device_lock (& dev -> dev );
144
144
145
- if (! device_is_registered ( & dev -> dev ) ) {
145
+ if (dev -> shutting_down ) {
146
146
rc = - ENODEV ;
147
147
goto error ;
148
148
}
@@ -207,7 +207,7 @@ int nfc_start_poll(struct nfc_dev *dev, u32 im_protocols, u32 tm_protocols)
207
207
208
208
device_lock (& dev -> dev );
209
209
210
- if (! device_is_registered ( & dev -> dev ) ) {
210
+ if (dev -> shutting_down ) {
211
211
rc = - ENODEV ;
212
212
goto error ;
213
213
}
@@ -246,7 +246,7 @@ int nfc_stop_poll(struct nfc_dev *dev)
246
246
247
247
device_lock (& dev -> dev );
248
248
249
- if (! device_is_registered ( & dev -> dev ) ) {
249
+ if (dev -> shutting_down ) {
250
250
rc = - ENODEV ;
251
251
goto error ;
252
252
}
@@ -291,7 +291,7 @@ int nfc_dep_link_up(struct nfc_dev *dev, int target_index, u8 comm_mode)
291
291
292
292
device_lock (& dev -> dev );
293
293
294
- if (! device_is_registered ( & dev -> dev ) ) {
294
+ if (dev -> shutting_down ) {
295
295
rc = - ENODEV ;
296
296
goto error ;
297
297
}
@@ -335,7 +335,7 @@ int nfc_dep_link_down(struct nfc_dev *dev)
335
335
336
336
device_lock (& dev -> dev );
337
337
338
- if (! device_is_registered ( & dev -> dev ) ) {
338
+ if (dev -> shutting_down ) {
339
339
rc = - ENODEV ;
340
340
goto error ;
341
341
}
@@ -401,7 +401,7 @@ int nfc_activate_target(struct nfc_dev *dev, u32 target_idx, u32 protocol)
401
401
402
402
device_lock (& dev -> dev );
403
403
404
- if (! device_is_registered ( & dev -> dev ) ) {
404
+ if (dev -> shutting_down ) {
405
405
rc = - ENODEV ;
406
406
goto error ;
407
407
}
@@ -448,7 +448,7 @@ int nfc_deactivate_target(struct nfc_dev *dev, u32 target_idx, u8 mode)
448
448
449
449
device_lock (& dev -> dev );
450
450
451
- if (! device_is_registered ( & dev -> dev ) ) {
451
+ if (dev -> shutting_down ) {
452
452
rc = - ENODEV ;
453
453
goto error ;
454
454
}
@@ -495,7 +495,7 @@ int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, struct sk_buff *skb,
495
495
496
496
device_lock (& dev -> dev );
497
497
498
- if (! device_is_registered ( & dev -> dev ) ) {
498
+ if (dev -> shutting_down ) {
499
499
rc = - ENODEV ;
500
500
kfree_skb (skb );
501
501
goto error ;
@@ -552,7 +552,7 @@ int nfc_enable_se(struct nfc_dev *dev, u32 se_idx)
552
552
553
553
device_lock (& dev -> dev );
554
554
555
- if (! device_is_registered ( & dev -> dev ) ) {
555
+ if (dev -> shutting_down ) {
556
556
rc = - ENODEV ;
557
557
goto error ;
558
558
}
@@ -601,7 +601,7 @@ int nfc_disable_se(struct nfc_dev *dev, u32 se_idx)
601
601
602
602
device_lock (& dev -> dev );
603
603
604
- if (! device_is_registered ( & dev -> dev ) ) {
604
+ if (dev -> shutting_down ) {
605
605
rc = - ENODEV ;
606
606
goto error ;
607
607
}
@@ -1134,6 +1134,7 @@ int nfc_register_device(struct nfc_dev *dev)
1134
1134
dev -> rfkill = NULL ;
1135
1135
}
1136
1136
}
1137
+ dev -> shutting_down = false;
1137
1138
device_unlock (& dev -> dev );
1138
1139
1139
1140
rc = nfc_genl_device_added (dev );
@@ -1166,12 +1167,10 @@ void nfc_unregister_device(struct nfc_dev *dev)
1166
1167
rfkill_unregister (dev -> rfkill );
1167
1168
rfkill_destroy (dev -> rfkill );
1168
1169
}
1170
+ dev -> shutting_down = true;
1169
1171
device_unlock (& dev -> dev );
1170
1172
1171
1173
if (dev -> ops -> check_presence ) {
1172
- device_lock (& dev -> dev );
1173
- dev -> shutting_down = true;
1174
- device_unlock (& dev -> dev );
1175
1174
del_timer_sync (& dev -> check_pres_timer );
1176
1175
cancel_work_sync (& dev -> check_pres_work );
1177
1176
}
0 commit comments