| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2011 Instituto Nokia de Tecnologia |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Authors: |
|---|
| 5 | 6 | * Lauro Ramos Venancio <lauro.venancio@openbossa.org> |
|---|
| 6 | 7 | * 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/>. |
|---|
| 20 | 8 | */ |
|---|
| 21 | 9 | |
|---|
| 22 | 10 | #define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__ |
|---|
| .. | .. |
|---|
| 50 | 38 | |
|---|
| 51 | 39 | device_lock(&dev->dev); |
|---|
| 52 | 40 | |
|---|
| 53 | | - if (!device_is_registered(&dev->dev)) { |
|---|
| 41 | + if (dev->shutting_down) { |
|---|
| 54 | 42 | rc = -ENODEV; |
|---|
| 55 | 43 | goto error; |
|---|
| 56 | 44 | } |
|---|
| .. | .. |
|---|
| 106 | 94 | |
|---|
| 107 | 95 | device_lock(&dev->dev); |
|---|
| 108 | 96 | |
|---|
| 109 | | - if (!device_is_registered(&dev->dev)) { |
|---|
| 97 | + if (dev->shutting_down) { |
|---|
| 110 | 98 | rc = -ENODEV; |
|---|
| 111 | 99 | goto error; |
|---|
| 112 | 100 | } |
|---|
| .. | .. |
|---|
| 154 | 142 | |
|---|
| 155 | 143 | device_lock(&dev->dev); |
|---|
| 156 | 144 | |
|---|
| 157 | | - if (!device_is_registered(&dev->dev)) { |
|---|
| 145 | + if (dev->shutting_down) { |
|---|
| 158 | 146 | rc = -ENODEV; |
|---|
| 159 | 147 | goto error; |
|---|
| 160 | 148 | } |
|---|
| .. | .. |
|---|
| 218 | 206 | |
|---|
| 219 | 207 | device_lock(&dev->dev); |
|---|
| 220 | 208 | |
|---|
| 221 | | - if (!device_is_registered(&dev->dev)) { |
|---|
| 209 | + if (dev->shutting_down) { |
|---|
| 222 | 210 | rc = -ENODEV; |
|---|
| 223 | 211 | goto error; |
|---|
| 224 | 212 | } |
|---|
| .. | .. |
|---|
| 257 | 245 | |
|---|
| 258 | 246 | device_lock(&dev->dev); |
|---|
| 259 | 247 | |
|---|
| 260 | | - if (!device_is_registered(&dev->dev)) { |
|---|
| 248 | + if (dev->shutting_down) { |
|---|
| 261 | 249 | rc = -ENODEV; |
|---|
| 262 | 250 | goto error; |
|---|
| 263 | 251 | } |
|---|
| .. | .. |
|---|
| 302 | 290 | |
|---|
| 303 | 291 | device_lock(&dev->dev); |
|---|
| 304 | 292 | |
|---|
| 305 | | - if (!device_is_registered(&dev->dev)) { |
|---|
| 293 | + if (dev->shutting_down) { |
|---|
| 306 | 294 | rc = -ENODEV; |
|---|
| 307 | 295 | goto error; |
|---|
| 308 | 296 | } |
|---|
| .. | .. |
|---|
| 346 | 334 | |
|---|
| 347 | 335 | device_lock(&dev->dev); |
|---|
| 348 | 336 | |
|---|
| 349 | | - if (!device_is_registered(&dev->dev)) { |
|---|
| 337 | + if (dev->shutting_down) { |
|---|
| 350 | 338 | rc = -ENODEV; |
|---|
| 351 | 339 | goto error; |
|---|
| 352 | 340 | } |
|---|
| .. | .. |
|---|
| 412 | 400 | |
|---|
| 413 | 401 | device_lock(&dev->dev); |
|---|
| 414 | 402 | |
|---|
| 415 | | - if (!device_is_registered(&dev->dev)) { |
|---|
| 403 | + if (dev->shutting_down) { |
|---|
| 416 | 404 | rc = -ENODEV; |
|---|
| 417 | 405 | goto error; |
|---|
| 418 | 406 | } |
|---|
| .. | .. |
|---|
| 458 | 446 | |
|---|
| 459 | 447 | device_lock(&dev->dev); |
|---|
| 460 | 448 | |
|---|
| 461 | | - if (!device_is_registered(&dev->dev)) { |
|---|
| 449 | + if (dev->shutting_down) { |
|---|
| 462 | 450 | rc = -ENODEV; |
|---|
| 463 | 451 | goto error; |
|---|
| 464 | 452 | } |
|---|
| .. | .. |
|---|
| 505 | 493 | |
|---|
| 506 | 494 | device_lock(&dev->dev); |
|---|
| 507 | 495 | |
|---|
| 508 | | - if (!device_is_registered(&dev->dev)) { |
|---|
| 496 | + if (dev->shutting_down) { |
|---|
| 509 | 497 | rc = -ENODEV; |
|---|
| 510 | 498 | kfree_skb(skb); |
|---|
| 511 | 499 | goto error; |
|---|
| .. | .. |
|---|
| 562 | 550 | |
|---|
| 563 | 551 | device_lock(&dev->dev); |
|---|
| 564 | 552 | |
|---|
| 565 | | - if (!device_is_registered(&dev->dev)) { |
|---|
| 553 | + if (dev->shutting_down) { |
|---|
| 566 | 554 | rc = -ENODEV; |
|---|
| 567 | 555 | goto error; |
|---|
| 568 | 556 | } |
|---|
| .. | .. |
|---|
| 611 | 599 | |
|---|
| 612 | 600 | device_lock(&dev->dev); |
|---|
| 613 | 601 | |
|---|
| 614 | | - if (!device_is_registered(&dev->dev)) { |
|---|
| 602 | + if (dev->shutting_down) { |
|---|
| 615 | 603 | rc = -ENODEV; |
|---|
| 616 | 604 | goto error; |
|---|
| 617 | 605 | } |
|---|
| .. | .. |
|---|
| 716 | 704 | * nfc_alloc_send_skb - allocate a skb for data exchange responses |
|---|
| 717 | 705 | * |
|---|
| 718 | 706 | * @size: size to allocate |
|---|
| 719 | | - * @gfp: gfp flags |
|---|
| 720 | 707 | */ |
|---|
| 721 | 708 | struct sk_buff *nfc_alloc_send_skb(struct nfc_dev *dev, struct sock *sk, |
|---|
| 722 | 709 | unsigned int flags, unsigned int size, |
|---|
| .. | .. |
|---|
| 761 | 748 | * |
|---|
| 762 | 749 | * @dev: The nfc device that found the targets |
|---|
| 763 | 750 | * @targets: array of nfc targets found |
|---|
| 764 | | - * @ntargets: targets array size |
|---|
| 751 | + * @n_targets: targets array size |
|---|
| 765 | 752 | * |
|---|
| 766 | 753 | * The device driver must call this function when one or many nfc targets |
|---|
| 767 | 754 | * are found. After calling this function, the device driver must stop |
|---|
| .. | .. |
|---|
| 1139 | 1126 | dev->rfkill = NULL; |
|---|
| 1140 | 1127 | } |
|---|
| 1141 | 1128 | } |
|---|
| 1129 | + dev->shutting_down = false; |
|---|
| 1142 | 1130 | device_unlock(&dev->dev); |
|---|
| 1143 | 1131 | |
|---|
| 1144 | 1132 | rc = nfc_genl_device_added(dev); |
|---|
| .. | .. |
|---|
| 1170 | 1158 | if (dev->rfkill) { |
|---|
| 1171 | 1159 | rfkill_unregister(dev->rfkill); |
|---|
| 1172 | 1160 | rfkill_destroy(dev->rfkill); |
|---|
| 1161 | + dev->rfkill = NULL; |
|---|
| 1173 | 1162 | } |
|---|
| 1163 | + dev->shutting_down = true; |
|---|
| 1174 | 1164 | device_unlock(&dev->dev); |
|---|
| 1175 | 1165 | |
|---|
| 1176 | 1166 | if (dev->ops->check_presence) { |
|---|
| 1177 | | - device_lock(&dev->dev); |
|---|
| 1178 | | - dev->shutting_down = true; |
|---|
| 1179 | | - device_unlock(&dev->dev); |
|---|
| 1180 | 1167 | del_timer_sync(&dev->check_pres_timer); |
|---|
| 1181 | 1168 | cancel_work_sync(&dev->check_pres_work); |
|---|
| 1182 | 1169 | } |
|---|