aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmitkumar Karwar <akarwar@marvell.com>2015-01-01 03:13:41 -0500
committerMarcel Holtmann <marcel@holtmann.org>2015-01-06 10:19:35 -0500
commit7b4b8740c6fc153fbb24b3c1ac391cf8908ad113 (patch)
tree8eef99bf9f66208596533e6849851b992e98e159
parent9b89fdfee47de2d5d904a36cb85304e1ba80934d (diff)
Bluetooth: btmrvl: add surprise_removed flag
This flag will be set in unload path to make sure that we skip sending further commands, ignore interrupts and stop main thread when unload starts. Signed-off-by: Amitkumar Karwar <akarwar@marvell.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r--drivers/bluetooth/btmrvl_drv.h1
-rw-r--r--drivers/bluetooth/btmrvl_main.c9
-rw-r--r--drivers/bluetooth/btmrvl_sdio.c4
3 files changed, 12 insertions, 2 deletions
diff --git a/drivers/bluetooth/btmrvl_drv.h b/drivers/bluetooth/btmrvl_drv.h
index 330f8f84928d..5513204c8bb2 100644
--- a/drivers/bluetooth/btmrvl_drv.h
+++ b/drivers/bluetooth/btmrvl_drv.h
@@ -104,6 +104,7 @@ struct btmrvl_private {
104#ifdef CONFIG_DEBUG_FS 104#ifdef CONFIG_DEBUG_FS
105 void *debugfs_data; 105 void *debugfs_data;
106#endif 106#endif
107 bool surprise_removed;
107}; 108};
108 109
109#define MRVL_VENDOR_PKT 0xFE 110#define MRVL_VENDOR_PKT 0xFE
diff --git a/drivers/bluetooth/btmrvl_main.c b/drivers/bluetooth/btmrvl_main.c
index c435b58db597..c4a542cc3214 100644
--- a/drivers/bluetooth/btmrvl_main.c
+++ b/drivers/bluetooth/btmrvl_main.c
@@ -178,6 +178,11 @@ static int btmrvl_send_sync_cmd(struct btmrvl_private *priv, u16 opcode,
178 struct sk_buff *skb; 178 struct sk_buff *skb;
179 struct hci_command_hdr *hdr; 179 struct hci_command_hdr *hdr;
180 180
181 if (priv->surprise_removed) {
182 BT_ERR("Card is removed");
183 return -EFAULT;
184 }
185
181 skb = bt_skb_alloc(HCI_COMMAND_HDR_SIZE + len, GFP_ATOMIC); 186 skb = bt_skb_alloc(HCI_COMMAND_HDR_SIZE + len, GFP_ATOMIC);
182 if (skb == NULL) { 187 if (skb == NULL) {
183 BT_ERR("No free skb"); 188 BT_ERR("No free skb");
@@ -600,7 +605,7 @@ static int btmrvl_service_main_thread(void *data)
600 add_wait_queue(&thread->wait_q, &wait); 605 add_wait_queue(&thread->wait_q, &wait);
601 606
602 set_current_state(TASK_INTERRUPTIBLE); 607 set_current_state(TASK_INTERRUPTIBLE);
603 if (kthread_should_stop()) { 608 if (kthread_should_stop() || priv->surprise_removed) {
604 BT_DBG("main_thread: break from main thread"); 609 BT_DBG("main_thread: break from main thread");
605 break; 610 break;
606 } 611 }
@@ -619,7 +624,7 @@ static int btmrvl_service_main_thread(void *data)
619 624
620 BT_DBG("main_thread woke up"); 625 BT_DBG("main_thread woke up");
621 626
622 if (kthread_should_stop()) { 627 if (kthread_should_stop() || priv->surprise_removed) {
623 BT_DBG("main_thread: break from main thread"); 628 BT_DBG("main_thread: break from main thread");
624 break; 629 break;
625 } 630 }
diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c
index 0057c0b7a776..80ec2008bd7c 100644
--- a/drivers/bluetooth/btmrvl_sdio.c
+++ b/drivers/bluetooth/btmrvl_sdio.c
@@ -798,6 +798,9 @@ static void btmrvl_sdio_interrupt(struct sdio_func *func)
798 798
799 priv = card->priv; 799 priv = card->priv;
800 800
801 if (priv->surprise_removed)
802 return;
803
801 if (card->reg->int_read_to_clear) 804 if (card->reg->int_read_to_clear)
802 ret = btmrvl_sdio_read_to_clear(card, &ireg); 805 ret = btmrvl_sdio_read_to_clear(card, &ireg);
803 else 806 else
@@ -1466,6 +1469,7 @@ static void btmrvl_sdio_remove(struct sdio_func *func)
1466 btmrvl_sdio_disable_host_int(card); 1469 btmrvl_sdio_disable_host_int(card);
1467 } 1470 }
1468 BT_DBG("unregester dev"); 1471 BT_DBG("unregester dev");
1472 card->priv->surprise_removed = true;
1469 btmrvl_sdio_unregister_dev(card); 1473 btmrvl_sdio_unregister_dev(card);
1470 btmrvl_remove_card(card->priv); 1474 btmrvl_remove_card(card->priv);
1471 } 1475 }