hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/net/nfc/core.c
....@@ -1,22 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (C) 2011 Instituto Nokia de Tecnologia
34 *
45 * Authors:
56 * Lauro Ramos Venancio <lauro.venancio@openbossa.org>
67 * Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License
19
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
208 */
219
2210 #define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__
....@@ -50,7 +38,7 @@
5038
5139 device_lock(&dev->dev);
5240
53
- if (!device_is_registered(&dev->dev)) {
41
+ if (dev->shutting_down) {
5442 rc = -ENODEV;
5543 goto error;
5644 }
....@@ -106,7 +94,7 @@
10694
10795 device_lock(&dev->dev);
10896
109
- if (!device_is_registered(&dev->dev)) {
97
+ if (dev->shutting_down) {
11098 rc = -ENODEV;
11199 goto error;
112100 }
....@@ -154,7 +142,7 @@
154142
155143 device_lock(&dev->dev);
156144
157
- if (!device_is_registered(&dev->dev)) {
145
+ if (dev->shutting_down) {
158146 rc = -ENODEV;
159147 goto error;
160148 }
....@@ -218,7 +206,7 @@
218206
219207 device_lock(&dev->dev);
220208
221
- if (!device_is_registered(&dev->dev)) {
209
+ if (dev->shutting_down) {
222210 rc = -ENODEV;
223211 goto error;
224212 }
....@@ -257,7 +245,7 @@
257245
258246 device_lock(&dev->dev);
259247
260
- if (!device_is_registered(&dev->dev)) {
248
+ if (dev->shutting_down) {
261249 rc = -ENODEV;
262250 goto error;
263251 }
....@@ -302,7 +290,7 @@
302290
303291 device_lock(&dev->dev);
304292
305
- if (!device_is_registered(&dev->dev)) {
293
+ if (dev->shutting_down) {
306294 rc = -ENODEV;
307295 goto error;
308296 }
....@@ -346,7 +334,7 @@
346334
347335 device_lock(&dev->dev);
348336
349
- if (!device_is_registered(&dev->dev)) {
337
+ if (dev->shutting_down) {
350338 rc = -ENODEV;
351339 goto error;
352340 }
....@@ -412,7 +400,7 @@
412400
413401 device_lock(&dev->dev);
414402
415
- if (!device_is_registered(&dev->dev)) {
403
+ if (dev->shutting_down) {
416404 rc = -ENODEV;
417405 goto error;
418406 }
....@@ -458,7 +446,7 @@
458446
459447 device_lock(&dev->dev);
460448
461
- if (!device_is_registered(&dev->dev)) {
449
+ if (dev->shutting_down) {
462450 rc = -ENODEV;
463451 goto error;
464452 }
....@@ -505,7 +493,7 @@
505493
506494 device_lock(&dev->dev);
507495
508
- if (!device_is_registered(&dev->dev)) {
496
+ if (dev->shutting_down) {
509497 rc = -ENODEV;
510498 kfree_skb(skb);
511499 goto error;
....@@ -562,7 +550,7 @@
562550
563551 device_lock(&dev->dev);
564552
565
- if (!device_is_registered(&dev->dev)) {
553
+ if (dev->shutting_down) {
566554 rc = -ENODEV;
567555 goto error;
568556 }
....@@ -611,7 +599,7 @@
611599
612600 device_lock(&dev->dev);
613601
614
- if (!device_is_registered(&dev->dev)) {
602
+ if (dev->shutting_down) {
615603 rc = -ENODEV;
616604 goto error;
617605 }
....@@ -646,7 +634,7 @@
646634 return rc;
647635 }
648636
649
-int nfc_set_remote_general_bytes(struct nfc_dev *dev, u8 *gb, u8 gb_len)
637
+int nfc_set_remote_general_bytes(struct nfc_dev *dev, const u8 *gb, u8 gb_len)
650638 {
651639 pr_debug("dev_name=%s gb_len=%d\n", dev_name(&dev->dev), gb_len);
652640
....@@ -675,7 +663,7 @@
675663 EXPORT_SYMBOL(nfc_tm_data_received);
676664
677665 int nfc_tm_activated(struct nfc_dev *dev, u32 protocol, u8 comm_mode,
678
- u8 *gb, size_t gb_len)
666
+ const u8 *gb, size_t gb_len)
679667 {
680668 int rc;
681669
....@@ -716,7 +704,6 @@
716704 * nfc_alloc_send_skb - allocate a skb for data exchange responses
717705 *
718706 * @size: size to allocate
719
- * @gfp: gfp flags
720707 */
721708 struct sk_buff *nfc_alloc_send_skb(struct nfc_dev *dev, struct sock *sk,
722709 unsigned int flags, unsigned int size,
....@@ -761,7 +748,7 @@
761748 *
762749 * @dev: The nfc device that found the targets
763750 * @targets: array of nfc targets found
764
- * @ntargets: targets array size
751
+ * @n_targets: targets array size
765752 *
766753 * The device driver must call this function when one or many nfc targets
767754 * are found. After calling this function, the device driver must stop
....@@ -1139,6 +1126,7 @@
11391126 dev->rfkill = NULL;
11401127 }
11411128 }
1129
+ dev->shutting_down = false;
11421130 device_unlock(&dev->dev);
11431131
11441132 rc = nfc_genl_device_added(dev);
....@@ -1170,13 +1158,12 @@
11701158 if (dev->rfkill) {
11711159 rfkill_unregister(dev->rfkill);
11721160 rfkill_destroy(dev->rfkill);
1161
+ dev->rfkill = NULL;
11731162 }
1163
+ dev->shutting_down = true;
11741164 device_unlock(&dev->dev);
11751165
11761166 if (dev->ops->check_presence) {
1177
- device_lock(&dev->dev);
1178
- dev->shutting_down = true;
1179
- device_unlock(&dev->dev);
11801167 del_timer_sync(&dev->check_pres_timer);
11811168 cancel_work_sync(&dev->check_pres_work);
11821169 }