@@ -38,7 +38,7 @@ int nfc_fw_download(struct nfc_dev *dev, const char *firmware_name)
3838
3939 device_lock (& dev -> dev );
4040
41- if (! device_is_registered ( & dev -> dev ) ) {
41+ if (dev -> shutting_down ) {
4242 rc = - ENODEV ;
4343 goto error ;
4444 }
@@ -94,7 +94,7 @@ int nfc_dev_up(struct nfc_dev *dev)
9494
9595 device_lock (& dev -> dev );
9696
97- if (! device_is_registered ( & dev -> dev ) ) {
97+ if (dev -> shutting_down ) {
9898 rc = - ENODEV ;
9999 goto error ;
100100 }
@@ -142,7 +142,7 @@ int nfc_dev_down(struct nfc_dev *dev)
142142
143143 device_lock (& dev -> dev );
144144
145- if (! device_is_registered ( & dev -> dev ) ) {
145+ if (dev -> shutting_down ) {
146146 rc = - ENODEV ;
147147 goto error ;
148148 }
@@ -207,7 +207,7 @@ int nfc_start_poll(struct nfc_dev *dev, u32 im_protocols, u32 tm_protocols)
207207
208208 device_lock (& dev -> dev );
209209
210- if (! device_is_registered ( & dev -> dev ) ) {
210+ if (dev -> shutting_down ) {
211211 rc = - ENODEV ;
212212 goto error ;
213213 }
@@ -246,7 +246,7 @@ int nfc_stop_poll(struct nfc_dev *dev)
246246
247247 device_lock (& dev -> dev );
248248
249- if (! device_is_registered ( & dev -> dev ) ) {
249+ if (dev -> shutting_down ) {
250250 rc = - ENODEV ;
251251 goto error ;
252252 }
@@ -291,7 +291,7 @@ int nfc_dep_link_up(struct nfc_dev *dev, int target_index, u8 comm_mode)
291291
292292 device_lock (& dev -> dev );
293293
294- if (! device_is_registered ( & dev -> dev ) ) {
294+ if (dev -> shutting_down ) {
295295 rc = - ENODEV ;
296296 goto error ;
297297 }
@@ -335,7 +335,7 @@ int nfc_dep_link_down(struct nfc_dev *dev)
335335
336336 device_lock (& dev -> dev );
337337
338- if (! device_is_registered ( & dev -> dev ) ) {
338+ if (dev -> shutting_down ) {
339339 rc = - ENODEV ;
340340 goto error ;
341341 }
@@ -401,7 +401,7 @@ int nfc_activate_target(struct nfc_dev *dev, u32 target_idx, u32 protocol)
401401
402402 device_lock (& dev -> dev );
403403
404- if (! device_is_registered ( & dev -> dev ) ) {
404+ if (dev -> shutting_down ) {
405405 rc = - ENODEV ;
406406 goto error ;
407407 }
@@ -448,7 +448,7 @@ int nfc_deactivate_target(struct nfc_dev *dev, u32 target_idx, u8 mode)
448448
449449 device_lock (& dev -> dev );
450450
451- if (! device_is_registered ( & dev -> dev ) ) {
451+ if (dev -> shutting_down ) {
452452 rc = - ENODEV ;
453453 goto error ;
454454 }
@@ -495,7 +495,7 @@ int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, struct sk_buff *skb,
495495
496496 device_lock (& dev -> dev );
497497
498- if (! device_is_registered ( & dev -> dev ) ) {
498+ if (dev -> shutting_down ) {
499499 rc = - ENODEV ;
500500 kfree_skb (skb );
501501 goto error ;
@@ -552,7 +552,7 @@ int nfc_enable_se(struct nfc_dev *dev, u32 se_idx)
552552
553553 device_lock (& dev -> dev );
554554
555- if (! device_is_registered ( & dev -> dev ) ) {
555+ if (dev -> shutting_down ) {
556556 rc = - ENODEV ;
557557 goto error ;
558558 }
@@ -601,7 +601,7 @@ int nfc_disable_se(struct nfc_dev *dev, u32 se_idx)
601601
602602 device_lock (& dev -> dev );
603603
604- if (! device_is_registered ( & dev -> dev ) ) {
604+ if (dev -> shutting_down ) {
605605 rc = - ENODEV ;
606606 goto error ;
607607 }
@@ -1134,6 +1134,7 @@ int nfc_register_device(struct nfc_dev *dev)
11341134 dev -> rfkill = NULL ;
11351135 }
11361136 }
1137+ dev -> shutting_down = false;
11371138 device_unlock (& dev -> dev );
11381139
11391140 rc = nfc_genl_device_added (dev );
@@ -1166,12 +1167,10 @@ void nfc_unregister_device(struct nfc_dev *dev)
11661167 rfkill_unregister (dev -> rfkill );
11671168 rfkill_destroy (dev -> rfkill );
11681169 }
1170+ dev -> shutting_down = true;
11691171 device_unlock (& dev -> dev );
11701172
11711173 if (dev -> ops -> check_presence ) {
1172- device_lock (& dev -> dev );
1173- dev -> shutting_down = true;
1174- device_unlock (& dev -> dev );
11751174 del_timer_sync (& dev -> check_pres_timer );
11761175 cancel_work_sync (& dev -> check_pres_work );
11771176 }
0 commit comments