hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/net/nfc/nci/core.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * The NFC Controller Interface is the communication protocol between an
34 * NFC Controller (NFCC) and a Device Host (DH).
....@@ -10,19 +11,6 @@
1011 * Acknowledgements:
1112 * This file is based on hci_core.c, which was written
1213 * by Maxim Krasnyansky.
13
- *
14
- * This program is free software; you can redistribute it and/or modify
15
- * it under the terms of the GNU General Public License version 2
16
- * as published by the Free Software Foundation
17
- *
18
- * This program is distributed in the hope that it will be useful,
19
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
- * GNU General Public License for more details.
22
- *
23
- * You should have received a copy of the GNU General Public License
24
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
25
- *
2614 */
2715
2816 #define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__
....@@ -542,7 +530,7 @@
542530 skb_queue_purge(&ndev->tx_q);
543531
544532 ndev->ops->close(ndev);
545
- ndev->flags = 0;
533
+ ndev->flags &= BIT(NCI_UNREG);
546534 }
547535
548536 done:
....@@ -560,6 +548,10 @@
560548 mutex_lock(&ndev->req_lock);
561549
562550 if (!test_and_clear_bit(NCI_UP, &ndev->flags)) {
551
+ /* Need to flush the cmd wq in case
552
+ * there is a queued/running cmd_work
553
+ */
554
+ flush_workqueue(ndev->cmd_wq);
563555 del_timer_sync(&ndev->cmd_timer);
564556 del_timer_sync(&ndev->data_timer);
565557 mutex_unlock(&ndev->req_lock);
....@@ -589,10 +581,10 @@
589581
590582 clear_bit(NCI_INIT, &ndev->flags);
591583
592
- del_timer_sync(&ndev->cmd_timer);
593
-
594584 /* Flush cmd wq */
595585 flush_workqueue(ndev->cmd_wq);
586
+
587
+ del_timer_sync(&ndev->cmd_timer);
596588
597589 /* Clear flags except NCI_UNREG */
598590 ndev->flags &= BIT(NCI_UNREG);
....@@ -1207,7 +1199,7 @@
12071199 /**
12081200 * nci_register_device - register a nci device in the nfc subsystem
12091201 *
1210
- * @dev: The nci device to register
1202
+ * @ndev: The nci device to register
12111203 */
12121204 int nci_register_device(struct nci_dev *ndev)
12131205 {
....@@ -1253,9 +1245,12 @@
12531245
12541246 rc = nfc_register_device(ndev->nfc_dev);
12551247 if (rc)
1256
- goto destroy_rx_wq_exit;
1248
+ goto destroy_tx_wq_exit;
12571249
12581250 goto exit;
1251
+
1252
+destroy_tx_wq_exit:
1253
+ destroy_workqueue(ndev->tx_wq);
12591254
12601255 destroy_rx_wq_exit:
12611256 destroy_workqueue(ndev->rx_wq);
....@@ -1271,7 +1266,7 @@
12711266 /**
12721267 * nci_unregister_device - unregister a nci device in the nfc subsystem
12731268 *
1274
- * @dev: The nci device to unregister
1269
+ * @ndev: The nci device to unregister
12751270 */
12761271 void nci_unregister_device(struct nci_dev *ndev)
12771272 {