diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2015-10-04 17:34:02 -0400 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2015-10-05 03:30:25 -0400 |
commit | e9ca8bf157f2b45f8f670517c96da313083ee9b2 (patch) | |
tree | 7aaa31766e0af85588a84f0d06d65d5b77375f7b | |
parent | 73d0d3c8671190ea982a8e79a7c79fbfe88f8f47 (diff) |
Bluetooth: Move handling of HCI_RUNNING flag into core
Setting and clearing of HCI_RUNNING flag in each and every driver is
just duplicating the same code all over the place. So instead of having
the driver do it in their hdev->open and hdev->close callbacks, set it
globally in the core transport handling.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
-rw-r--r-- | drivers/bluetooth/bfusb.c | 8 | ||||
-rw-r--r-- | drivers/bluetooth/bluecard_cs.c | 6 | ||||
-rw-r--r-- | drivers/bluetooth/bpa10x.c | 8 | ||||
-rw-r--r-- | drivers/bluetooth/bt3c_cs.c | 6 | ||||
-rw-r--r-- | drivers/bluetooth/btmrvl_main.c | 5 | ||||
-rw-r--r-- | drivers/bluetooth/btsdio.c | 11 | ||||
-rw-r--r-- | drivers/bluetooth/btuart_cs.c | 6 | ||||
-rw-r--r-- | drivers/bluetooth/btusb.c | 7 | ||||
-rw-r--r-- | drivers/bluetooth/btwilink.c | 10 | ||||
-rw-r--r-- | drivers/bluetooth/dtl1_cs.c | 5 | ||||
-rw-r--r-- | drivers/bluetooth/hci_ldisc.c | 6 | ||||
-rw-r--r-- | drivers/bluetooth/hci_vhci.c | 5 | ||||
-rw-r--r-- | net/bluetooth/hci_core.c | 3 |
13 files changed, 4 insertions, 82 deletions
diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c index 3ba8170d08d3..616ec2ac1b22 100644 --- a/drivers/bluetooth/bfusb.c +++ b/drivers/bluetooth/bfusb.c | |||
@@ -422,17 +422,12 @@ static int bfusb_open(struct hci_dev *hdev) | |||
422 | 422 | ||
423 | BT_DBG("hdev %p bfusb %p", hdev, data); | 423 | BT_DBG("hdev %p bfusb %p", hdev, data); |
424 | 424 | ||
425 | if (test_and_set_bit(HCI_RUNNING, &hdev->flags)) | ||
426 | return 0; | ||
427 | |||
428 | write_lock_irqsave(&data->lock, flags); | 425 | write_lock_irqsave(&data->lock, flags); |
429 | 426 | ||
430 | err = bfusb_rx_submit(data, NULL); | 427 | err = bfusb_rx_submit(data, NULL); |
431 | if (!err) { | 428 | if (!err) { |
432 | for (i = 1; i < BFUSB_MAX_BULK_RX; i++) | 429 | for (i = 1; i < BFUSB_MAX_BULK_RX; i++) |
433 | bfusb_rx_submit(data, NULL); | 430 | bfusb_rx_submit(data, NULL); |
434 | } else { | ||
435 | clear_bit(HCI_RUNNING, &hdev->flags); | ||
436 | } | 431 | } |
437 | 432 | ||
438 | write_unlock_irqrestore(&data->lock, flags); | 433 | write_unlock_irqrestore(&data->lock, flags); |
@@ -458,9 +453,6 @@ static int bfusb_close(struct hci_dev *hdev) | |||
458 | 453 | ||
459 | BT_DBG("hdev %p bfusb %p", hdev, data); | 454 | BT_DBG("hdev %p bfusb %p", hdev, data); |
460 | 455 | ||
461 | if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) | ||
462 | return 0; | ||
463 | |||
464 | write_lock_irqsave(&data->lock, flags); | 456 | write_lock_irqsave(&data->lock, flags); |
465 | write_unlock_irqrestore(&data->lock, flags); | 457 | write_unlock_irqrestore(&data->lock, flags); |
466 | 458 | ||
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c index 25b71664cdc3..36fa1c958c74 100644 --- a/drivers/bluetooth/bluecard_cs.c +++ b/drivers/bluetooth/bluecard_cs.c | |||
@@ -628,9 +628,6 @@ static int bluecard_hci_open(struct hci_dev *hdev) | |||
628 | if (test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) | 628 | if (test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) |
629 | bluecard_hci_set_baud_rate(hdev, DEFAULT_BAUD_RATE); | 629 | bluecard_hci_set_baud_rate(hdev, DEFAULT_BAUD_RATE); |
630 | 630 | ||
631 | if (test_and_set_bit(HCI_RUNNING, &(hdev->flags))) | ||
632 | return 0; | ||
633 | |||
634 | if (test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) { | 631 | if (test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) { |
635 | unsigned int iobase = info->p_dev->resource[0]->start; | 632 | unsigned int iobase = info->p_dev->resource[0]->start; |
636 | 633 | ||
@@ -646,9 +643,6 @@ static int bluecard_hci_close(struct hci_dev *hdev) | |||
646 | { | 643 | { |
647 | struct bluecard_info *info = hci_get_drvdata(hdev); | 644 | struct bluecard_info *info = hci_get_drvdata(hdev); |
648 | 645 | ||
649 | if (!test_and_clear_bit(HCI_RUNNING, &(hdev->flags))) | ||
650 | return 0; | ||
651 | |||
652 | bluecard_hci_flush(hdev); | 646 | bluecard_hci_flush(hdev); |
653 | 647 | ||
654 | if (test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) { | 648 | if (test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) { |
diff --git a/drivers/bluetooth/bpa10x.c b/drivers/bluetooth/bpa10x.c index 59b892464be5..88e004ee137e 100644 --- a/drivers/bluetooth/bpa10x.c +++ b/drivers/bluetooth/bpa10x.c | |||
@@ -304,9 +304,6 @@ static int bpa10x_open(struct hci_dev *hdev) | |||
304 | 304 | ||
305 | BT_DBG("%s", hdev->name); | 305 | BT_DBG("%s", hdev->name); |
306 | 306 | ||
307 | if (test_and_set_bit(HCI_RUNNING, &hdev->flags)) | ||
308 | return 0; | ||
309 | |||
310 | err = bpa10x_submit_intr_urb(hdev); | 307 | err = bpa10x_submit_intr_urb(hdev); |
311 | if (err < 0) | 308 | if (err < 0) |
312 | goto error; | 309 | goto error; |
@@ -320,8 +317,6 @@ static int bpa10x_open(struct hci_dev *hdev) | |||
320 | error: | 317 | error: |
321 | usb_kill_anchored_urbs(&data->rx_anchor); | 318 | usb_kill_anchored_urbs(&data->rx_anchor); |
322 | 319 | ||
323 | clear_bit(HCI_RUNNING, &hdev->flags); | ||
324 | |||
325 | return err; | 320 | return err; |
326 | } | 321 | } |
327 | 322 | ||
@@ -331,9 +326,6 @@ static int bpa10x_close(struct hci_dev *hdev) | |||
331 | 326 | ||
332 | BT_DBG("%s", hdev->name); | 327 | BT_DBG("%s", hdev->name); |
333 | 328 | ||
334 | if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) | ||
335 | return 0; | ||
336 | |||
337 | usb_kill_anchored_urbs(&data->rx_anchor); | 329 | usb_kill_anchored_urbs(&data->rx_anchor); |
338 | 330 | ||
339 | return 0; | 331 | return 0; |
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c index b8f4b63175e7..5803aaed958f 100644 --- a/drivers/bluetooth/bt3c_cs.c +++ b/drivers/bluetooth/bt3c_cs.c | |||
@@ -270,7 +270,6 @@ static void bt3c_receive(struct bt3c_info *info) | |||
270 | /* Unknown packet */ | 270 | /* Unknown packet */ |
271 | BT_ERR("Unknown HCI packet with type 0x%02x received", bt_cb(info->rx_skb)->pkt_type); | 271 | BT_ERR("Unknown HCI packet with type 0x%02x received", bt_cb(info->rx_skb)->pkt_type); |
272 | info->hdev->stat.err_rx++; | 272 | info->hdev->stat.err_rx++; |
273 | clear_bit(HCI_RUNNING, &(info->hdev->flags)); | ||
274 | 273 | ||
275 | kfree_skb(info->rx_skb); | 274 | kfree_skb(info->rx_skb); |
276 | info->rx_skb = NULL; | 275 | info->rx_skb = NULL; |
@@ -395,17 +394,12 @@ static int bt3c_hci_flush(struct hci_dev *hdev) | |||
395 | 394 | ||
396 | static int bt3c_hci_open(struct hci_dev *hdev) | 395 | static int bt3c_hci_open(struct hci_dev *hdev) |
397 | { | 396 | { |
398 | set_bit(HCI_RUNNING, &(hdev->flags)); | ||
399 | |||
400 | return 0; | 397 | return 0; |
401 | } | 398 | } |
402 | 399 | ||
403 | 400 | ||
404 | static int bt3c_hci_close(struct hci_dev *hdev) | 401 | static int bt3c_hci_close(struct hci_dev *hdev) |
405 | { | 402 | { |
406 | if (!test_and_clear_bit(HCI_RUNNING, &(hdev->flags))) | ||
407 | return 0; | ||
408 | |||
409 | bt3c_hci_flush(hdev); | 403 | bt3c_hci_flush(hdev); |
410 | 404 | ||
411 | return 0; | 405 | return 0; |
diff --git a/drivers/bluetooth/btmrvl_main.c b/drivers/bluetooth/btmrvl_main.c index 39552a8e9cc7..6ba22862d788 100644 --- a/drivers/bluetooth/btmrvl_main.c +++ b/drivers/bluetooth/btmrvl_main.c | |||
@@ -470,9 +470,6 @@ static int btmrvl_close(struct hci_dev *hdev) | |||
470 | { | 470 | { |
471 | struct btmrvl_private *priv = hci_get_drvdata(hdev); | 471 | struct btmrvl_private *priv = hci_get_drvdata(hdev); |
472 | 472 | ||
473 | if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) | ||
474 | return 0; | ||
475 | |||
476 | skb_queue_purge(&priv->adapter->tx_queue); | 473 | skb_queue_purge(&priv->adapter->tx_queue); |
477 | 474 | ||
478 | return 0; | 475 | return 0; |
@@ -480,8 +477,6 @@ static int btmrvl_close(struct hci_dev *hdev) | |||
480 | 477 | ||
481 | static int btmrvl_open(struct hci_dev *hdev) | 478 | static int btmrvl_open(struct hci_dev *hdev) |
482 | { | 479 | { |
483 | set_bit(HCI_RUNNING, &hdev->flags); | ||
484 | |||
485 | return 0; | 480 | return 0; |
486 | } | 481 | } |
487 | 482 | ||
diff --git a/drivers/bluetooth/btsdio.c b/drivers/bluetooth/btsdio.c index 21f99cc8c669..7b624423a7e8 100644 --- a/drivers/bluetooth/btsdio.c +++ b/drivers/bluetooth/btsdio.c | |||
@@ -194,21 +194,15 @@ static int btsdio_open(struct hci_dev *hdev) | |||
194 | 194 | ||
195 | BT_DBG("%s", hdev->name); | 195 | BT_DBG("%s", hdev->name); |
196 | 196 | ||
197 | if (test_and_set_bit(HCI_RUNNING, &hdev->flags)) | ||
198 | return 0; | ||
199 | |||
200 | sdio_claim_host(data->func); | 197 | sdio_claim_host(data->func); |
201 | 198 | ||
202 | err = sdio_enable_func(data->func); | 199 | err = sdio_enable_func(data->func); |
203 | if (err < 0) { | 200 | if (err < 0) |
204 | clear_bit(HCI_RUNNING, &hdev->flags); | ||
205 | goto release; | 201 | goto release; |
206 | } | ||
207 | 202 | ||
208 | err = sdio_claim_irq(data->func, btsdio_interrupt); | 203 | err = sdio_claim_irq(data->func, btsdio_interrupt); |
209 | if (err < 0) { | 204 | if (err < 0) { |
210 | sdio_disable_func(data->func); | 205 | sdio_disable_func(data->func); |
211 | clear_bit(HCI_RUNNING, &hdev->flags); | ||
212 | goto release; | 206 | goto release; |
213 | } | 207 | } |
214 | 208 | ||
@@ -229,9 +223,6 @@ static int btsdio_close(struct hci_dev *hdev) | |||
229 | 223 | ||
230 | BT_DBG("%s", hdev->name); | 224 | BT_DBG("%s", hdev->name); |
231 | 225 | ||
232 | if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) | ||
233 | return 0; | ||
234 | |||
235 | sdio_claim_host(data->func); | 226 | sdio_claim_host(data->func); |
236 | 227 | ||
237 | sdio_writeb(data->func, 0x00, REG_EN_INTRD, NULL); | 228 | sdio_writeb(data->func, 0x00, REG_EN_INTRD, NULL); |
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c index 4c001a8f7fbd..bb8e4025fb9e 100644 --- a/drivers/bluetooth/btuart_cs.c +++ b/drivers/bluetooth/btuart_cs.c | |||
@@ -223,7 +223,6 @@ static void btuart_receive(struct btuart_info *info) | |||
223 | /* Unknown packet */ | 223 | /* Unknown packet */ |
224 | BT_ERR("Unknown HCI packet with type 0x%02x received", bt_cb(info->rx_skb)->pkt_type); | 224 | BT_ERR("Unknown HCI packet with type 0x%02x received", bt_cb(info->rx_skb)->pkt_type); |
225 | info->hdev->stat.err_rx++; | 225 | info->hdev->stat.err_rx++; |
226 | clear_bit(HCI_RUNNING, &(info->hdev->flags)); | ||
227 | 226 | ||
228 | kfree_skb(info->rx_skb); | 227 | kfree_skb(info->rx_skb); |
229 | info->rx_skb = NULL; | 228 | info->rx_skb = NULL; |
@@ -409,17 +408,12 @@ static int btuart_hci_flush(struct hci_dev *hdev) | |||
409 | 408 | ||
410 | static int btuart_hci_open(struct hci_dev *hdev) | 409 | static int btuart_hci_open(struct hci_dev *hdev) |
411 | { | 410 | { |
412 | set_bit(HCI_RUNNING, &(hdev->flags)); | ||
413 | |||
414 | return 0; | 411 | return 0; |
415 | } | 412 | } |
416 | 413 | ||
417 | 414 | ||
418 | static int btuart_hci_close(struct hci_dev *hdev) | 415 | static int btuart_hci_close(struct hci_dev *hdev) |
419 | { | 416 | { |
420 | if (!test_and_clear_bit(HCI_RUNNING, &(hdev->flags))) | ||
421 | return 0; | ||
422 | |||
423 | btuart_hci_flush(hdev); | 417 | btuart_hci_flush(hdev); |
424 | 418 | ||
425 | return 0; | 419 | return 0; |
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 9cf3796f92aa..247b1062cb9a 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c | |||
@@ -940,9 +940,6 @@ static int btusb_open(struct hci_dev *hdev) | |||
940 | 940 | ||
941 | data->intf->needs_remote_wakeup = 1; | 941 | data->intf->needs_remote_wakeup = 1; |
942 | 942 | ||
943 | if (test_and_set_bit(HCI_RUNNING, &hdev->flags)) | ||
944 | goto done; | ||
945 | |||
946 | if (test_and_set_bit(BTUSB_INTR_RUNNING, &data->flags)) | 943 | if (test_and_set_bit(BTUSB_INTR_RUNNING, &data->flags)) |
947 | goto done; | 944 | goto done; |
948 | 945 | ||
@@ -965,7 +962,6 @@ done: | |||
965 | 962 | ||
966 | failed: | 963 | failed: |
967 | clear_bit(BTUSB_INTR_RUNNING, &data->flags); | 964 | clear_bit(BTUSB_INTR_RUNNING, &data->flags); |
968 | clear_bit(HCI_RUNNING, &hdev->flags); | ||
969 | usb_autopm_put_interface(data->intf); | 965 | usb_autopm_put_interface(data->intf); |
970 | return err; | 966 | return err; |
971 | } | 967 | } |
@@ -984,9 +980,6 @@ static int btusb_close(struct hci_dev *hdev) | |||
984 | 980 | ||
985 | BT_DBG("%s", hdev->name); | 981 | BT_DBG("%s", hdev->name); |
986 | 982 | ||
987 | if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) | ||
988 | return 0; | ||
989 | |||
990 | cancel_work_sync(&data->work); | 983 | cancel_work_sync(&data->work); |
991 | cancel_work_sync(&data->waker); | 984 | cancel_work_sync(&data->waker); |
992 | 985 | ||
diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c index 4db99a44f671..57eb935aedc7 100644 --- a/drivers/bluetooth/btwilink.c +++ b/drivers/bluetooth/btwilink.c | |||
@@ -155,9 +155,6 @@ static int ti_st_open(struct hci_dev *hdev) | |||
155 | 155 | ||
156 | BT_DBG("%s %p", hdev->name, hdev); | 156 | BT_DBG("%s %p", hdev->name, hdev); |
157 | 157 | ||
158 | if (test_and_set_bit(HCI_RUNNING, &hdev->flags)) | ||
159 | return -EBUSY; | ||
160 | |||
161 | /* provide contexts for callbacks from ST */ | 158 | /* provide contexts for callbacks from ST */ |
162 | hst = hci_get_drvdata(hdev); | 159 | hst = hci_get_drvdata(hdev); |
163 | 160 | ||
@@ -181,7 +178,6 @@ static int ti_st_open(struct hci_dev *hdev) | |||
181 | goto done; | 178 | goto done; |
182 | 179 | ||
183 | if (err != -EINPROGRESS) { | 180 | if (err != -EINPROGRESS) { |
184 | clear_bit(HCI_RUNNING, &hdev->flags); | ||
185 | BT_ERR("st_register failed %d", err); | 181 | BT_ERR("st_register failed %d", err); |
186 | return err; | 182 | return err; |
187 | } | 183 | } |
@@ -195,7 +191,6 @@ static int ti_st_open(struct hci_dev *hdev) | |||
195 | (&hst->wait_reg_completion, | 191 | (&hst->wait_reg_completion, |
196 | msecs_to_jiffies(BT_REGISTER_TIMEOUT)); | 192 | msecs_to_jiffies(BT_REGISTER_TIMEOUT)); |
197 | if (!timeleft) { | 193 | if (!timeleft) { |
198 | clear_bit(HCI_RUNNING, &hdev->flags); | ||
199 | BT_ERR("Timeout(%d sec),didn't get reg " | 194 | BT_ERR("Timeout(%d sec),didn't get reg " |
200 | "completion signal from ST", | 195 | "completion signal from ST", |
201 | BT_REGISTER_TIMEOUT / 1000); | 196 | BT_REGISTER_TIMEOUT / 1000); |
@@ -205,7 +200,6 @@ static int ti_st_open(struct hci_dev *hdev) | |||
205 | /* Is ST registration callback | 200 | /* Is ST registration callback |
206 | * called with ERROR status? */ | 201 | * called with ERROR status? */ |
207 | if (hst->reg_status != 0) { | 202 | if (hst->reg_status != 0) { |
208 | clear_bit(HCI_RUNNING, &hdev->flags); | ||
209 | BT_ERR("ST registration completed with invalid " | 203 | BT_ERR("ST registration completed with invalid " |
210 | "status %d", hst->reg_status); | 204 | "status %d", hst->reg_status); |
211 | return -EAGAIN; | 205 | return -EAGAIN; |
@@ -215,7 +209,6 @@ done: | |||
215 | hst->st_write = ti_st_proto[i].write; | 209 | hst->st_write = ti_st_proto[i].write; |
216 | if (!hst->st_write) { | 210 | if (!hst->st_write) { |
217 | BT_ERR("undefined ST write function"); | 211 | BT_ERR("undefined ST write function"); |
218 | clear_bit(HCI_RUNNING, &hdev->flags); | ||
219 | for (i = 0; i < MAX_BT_CHNL_IDS; i++) { | 212 | for (i = 0; i < MAX_BT_CHNL_IDS; i++) { |
220 | /* Undo registration with ST */ | 213 | /* Undo registration with ST */ |
221 | err = st_unregister(&ti_st_proto[i]); | 214 | err = st_unregister(&ti_st_proto[i]); |
@@ -236,9 +229,6 @@ static int ti_st_close(struct hci_dev *hdev) | |||
236 | int err, i; | 229 | int err, i; |
237 | struct ti_st *hst = hci_get_drvdata(hdev); | 230 | struct ti_st *hst = hci_get_drvdata(hdev); |
238 | 231 | ||
239 | if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) | ||
240 | return 0; | ||
241 | |||
242 | for (i = MAX_BT_CHNL_IDS-1; i >= 0; i--) { | 232 | for (i = MAX_BT_CHNL_IDS-1; i >= 0; i--) { |
243 | err = st_unregister(&ti_st_proto[i]); | 233 | err = st_unregister(&ti_st_proto[i]); |
244 | if (err) | 234 | if (err) |
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c index 84135c54ed2e..5026f66fac88 100644 --- a/drivers/bluetooth/dtl1_cs.c +++ b/drivers/bluetooth/dtl1_cs.c | |||
@@ -357,8 +357,6 @@ static irqreturn_t dtl1_interrupt(int irq, void *dev_inst) | |||
357 | 357 | ||
358 | static int dtl1_hci_open(struct hci_dev *hdev) | 358 | static int dtl1_hci_open(struct hci_dev *hdev) |
359 | { | 359 | { |
360 | set_bit(HCI_RUNNING, &(hdev->flags)); | ||
361 | |||
362 | return 0; | 360 | return 0; |
363 | } | 361 | } |
364 | 362 | ||
@@ -376,9 +374,6 @@ static int dtl1_hci_flush(struct hci_dev *hdev) | |||
376 | 374 | ||
377 | static int dtl1_hci_close(struct hci_dev *hdev) | 375 | static int dtl1_hci_close(struct hci_dev *hdev) |
378 | { | 376 | { |
379 | if (!test_and_clear_bit(HCI_RUNNING, &(hdev->flags))) | ||
380 | return 0; | ||
381 | |||
382 | dtl1_hci_flush(hdev); | 377 | dtl1_hci_flush(hdev); |
383 | 378 | ||
384 | return 0; | 379 | return 0; |
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index 443feaebe275..01a83a3f8a1d 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c | |||
@@ -208,9 +208,6 @@ static int hci_uart_open(struct hci_dev *hdev) | |||
208 | BT_DBG("%s %p", hdev->name, hdev); | 208 | BT_DBG("%s %p", hdev->name, hdev); |
209 | 209 | ||
210 | /* Nothing to do for UART driver */ | 210 | /* Nothing to do for UART driver */ |
211 | |||
212 | set_bit(HCI_RUNNING, &hdev->flags); | ||
213 | |||
214 | return 0; | 211 | return 0; |
215 | } | 212 | } |
216 | 213 | ||
@@ -241,9 +238,6 @@ static int hci_uart_close(struct hci_dev *hdev) | |||
241 | { | 238 | { |
242 | BT_DBG("hdev %p", hdev); | 239 | BT_DBG("hdev %p", hdev); |
243 | 240 | ||
244 | if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) | ||
245 | return 0; | ||
246 | |||
247 | hci_uart_flush(hdev); | 241 | hci_uart_flush(hdev); |
248 | hdev->flush = NULL; | 242 | hdev->flush = NULL; |
249 | return 0; | 243 | return 0; |
diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c index 15c344c9a00d..ed888e302bc3 100644 --- a/drivers/bluetooth/hci_vhci.c +++ b/drivers/bluetooth/hci_vhci.c | |||
@@ -55,8 +55,6 @@ struct vhci_data { | |||
55 | 55 | ||
56 | static int vhci_open_dev(struct hci_dev *hdev) | 56 | static int vhci_open_dev(struct hci_dev *hdev) |
57 | { | 57 | { |
58 | set_bit(HCI_RUNNING, &hdev->flags); | ||
59 | |||
60 | return 0; | 58 | return 0; |
61 | } | 59 | } |
62 | 60 | ||
@@ -64,9 +62,6 @@ static int vhci_close_dev(struct hci_dev *hdev) | |||
64 | { | 62 | { |
65 | struct vhci_data *data = hci_get_drvdata(hdev); | 63 | struct vhci_data *data = hci_get_drvdata(hdev); |
66 | 64 | ||
67 | if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) | ||
68 | return 0; | ||
69 | |||
70 | skb_queue_purge(&data->readq); | 65 | skb_queue_purge(&data->readq); |
71 | 66 | ||
72 | return 0; | 67 | return 0; |
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index b955f7192651..40a67017bd32 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -1385,6 +1385,7 @@ static int hci_dev_do_open(struct hci_dev *hdev) | |||
1385 | goto done; | 1385 | goto done; |
1386 | } | 1386 | } |
1387 | 1387 | ||
1388 | set_bit(HCI_RUNNING, &hdev->flags); | ||
1388 | hci_notify(hdev, HCI_DEV_OPEN); | 1389 | hci_notify(hdev, HCI_DEV_OPEN); |
1389 | 1390 | ||
1390 | atomic_set(&hdev->cmd_cnt, 1); | 1391 | atomic_set(&hdev->cmd_cnt, 1); |
@@ -1468,6 +1469,7 @@ static int hci_dev_do_open(struct hci_dev *hdev) | |||
1468 | hdev->sent_cmd = NULL; | 1469 | hdev->sent_cmd = NULL; |
1469 | } | 1470 | } |
1470 | 1471 | ||
1472 | clear_bit(HCI_RUNNING, &hdev->flags); | ||
1471 | hci_notify(hdev, HCI_DEV_CLOSE); | 1473 | hci_notify(hdev, HCI_DEV_CLOSE); |
1472 | 1474 | ||
1473 | hdev->close(hdev); | 1475 | hdev->close(hdev); |
@@ -1653,6 +1655,7 @@ int hci_dev_do_close(struct hci_dev *hdev) | |||
1653 | hdev->sent_cmd = NULL; | 1655 | hdev->sent_cmd = NULL; |
1654 | } | 1656 | } |
1655 | 1657 | ||
1658 | clear_bit(HCI_RUNNING, &hdev->flags); | ||
1656 | hci_notify(hdev, HCI_DEV_CLOSE); | 1659 | hci_notify(hdev, HCI_DEV_CLOSE); |
1657 | 1660 | ||
1658 | /* After this point our queues are empty | 1661 | /* After this point our queues are empty |