diff options
Diffstat (limited to 'drivers/bluetooth/btmrvl_main.c')
-rw-r--r-- | drivers/bluetooth/btmrvl_main.c | 97 |
1 files changed, 45 insertions, 52 deletions
diff --git a/drivers/bluetooth/btmrvl_main.c b/drivers/bluetooth/btmrvl_main.c index b4f44454666f..db4fdb1538e9 100644 --- a/drivers/bluetooth/btmrvl_main.c +++ b/drivers/bluetooth/btmrvl_main.c | |||
@@ -48,19 +48,18 @@ EXPORT_SYMBOL_GPL(btmrvl_interrupt); | |||
48 | 48 | ||
49 | void btmrvl_check_evtpkt(struct btmrvl_private *priv, struct sk_buff *skb) | 49 | void btmrvl_check_evtpkt(struct btmrvl_private *priv, struct sk_buff *skb) |
50 | { | 50 | { |
51 | struct hci_event_hdr *hdr = (struct hci_event_hdr *)skb->data; | 51 | struct hci_event_hdr *hdr = (void *) skb->data; |
52 | struct hci_ev_cmd_complete *ec; | 52 | struct hci_ev_cmd_complete *ec; |
53 | u16 opcode, ocf; | 53 | u16 opcode, ocf; |
54 | 54 | ||
55 | BT_DBG("Enter"); | 55 | BT_DBG("Enter"); |
56 | 56 | ||
57 | if (hdr->evt == HCI_EV_CMD_COMPLETE) { | 57 | if (hdr->evt == HCI_EV_CMD_COMPLETE) { |
58 | ec = (struct hci_ev_cmd_complete *)(skb->data + | 58 | ec = (void *) (skb->data + HCI_EVENT_HDR_SIZE); |
59 | HCI_EVENT_HDR_SIZE); | ||
60 | opcode = __le16_to_cpu(ec->opcode); | 59 | opcode = __le16_to_cpu(ec->opcode); |
61 | ocf = hci_opcode_ocf(opcode); | 60 | ocf = hci_opcode_ocf(opcode); |
62 | if ((ocf == BT_CMD_MODULE_CFG_REQ) && | 61 | if (ocf == BT_CMD_MODULE_CFG_REQ && |
63 | (priv->btmrvl_dev.sendcmdflag)) { | 62 | priv->btmrvl_dev.sendcmdflag) { |
64 | priv->btmrvl_dev.sendcmdflag = false; | 63 | priv->btmrvl_dev.sendcmdflag = false; |
65 | priv->adapter->cmd_complete = true; | 64 | priv->adapter->cmd_complete = true; |
66 | wake_up_interruptible(&priv->adapter->cmd_wait_q); | 65 | wake_up_interruptible(&priv->adapter->cmd_wait_q); |
@@ -74,8 +73,8 @@ EXPORT_SYMBOL_GPL(btmrvl_check_evtpkt); | |||
74 | int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb) | 73 | int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb) |
75 | { | 74 | { |
76 | struct btmrvl_adapter *adapter = priv->adapter; | 75 | struct btmrvl_adapter *adapter = priv->adapter; |
77 | u8 ret = 0; | ||
78 | struct btmrvl_event *event; | 76 | struct btmrvl_event *event; |
77 | u8 ret = 0; | ||
79 | 78 | ||
80 | BT_DBG("Enter"); | 79 | BT_DBG("Enter"); |
81 | 80 | ||
@@ -103,7 +102,7 @@ int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb) | |||
103 | case BT_CMD_HOST_SLEEP_CONFIG: | 102 | case BT_CMD_HOST_SLEEP_CONFIG: |
104 | if (!event->data[3]) | 103 | if (!event->data[3]) |
105 | BT_DBG("gpio=%x, gap=%x", event->data[1], | 104 | BT_DBG("gpio=%x, gap=%x", event->data[1], |
106 | event->data[2]); | 105 | event->data[2]); |
107 | else | 106 | else |
108 | BT_DBG("HSCFG command failed"); | 107 | BT_DBG("HSCFG command failed"); |
109 | break; | 108 | break; |
@@ -121,12 +120,12 @@ int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb) | |||
121 | break; | 120 | break; |
122 | 121 | ||
123 | case BT_CMD_MODULE_CFG_REQ: | 122 | case BT_CMD_MODULE_CFG_REQ: |
124 | if ((priv->btmrvl_dev.sendcmdflag) && | 123 | if (priv->btmrvl_dev.sendcmdflag && |
125 | (event->data[1] == MODULE_BRINGUP_REQ)) { | 124 | event->data[1] == MODULE_BRINGUP_REQ) { |
126 | BT_DBG("EVENT:%s", (event->data[2]) ? | 125 | BT_DBG("EVENT:%s", (event->data[2]) ? |
127 | "Bring-up failed" : "Bring-up succeed"); | 126 | "Bring-up failed" : "Bring-up succeed"); |
128 | } else if ((priv->btmrvl_dev.sendcmdflag) && | 127 | } else if (priv->btmrvl_dev.sendcmdflag && |
129 | (event->data[1] == MODULE_SHUTDOWN_REQ)) { | 128 | event->data[1] == MODULE_SHUTDOWN_REQ) { |
130 | BT_DBG("EVENT:%s", (event->data[2]) ? | 129 | BT_DBG("EVENT:%s", (event->data[2]) ? |
131 | "Shutdown failed" : "Shutdown succeed"); | 130 | "Shutdown failed" : "Shutdown succeed"); |
132 | } else { | 131 | } else { |
@@ -160,9 +159,9 @@ EXPORT_SYMBOL_GPL(btmrvl_process_event); | |||
160 | 159 | ||
161 | int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd) | 160 | int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd) |
162 | { | 161 | { |
163 | struct sk_buff *skb = NULL; | 162 | struct sk_buff *skb; |
164 | u8 ret = 0; | ||
165 | struct btmrvl_cmd *cmd; | 163 | struct btmrvl_cmd *cmd; |
164 | u8 ret = 0; | ||
166 | 165 | ||
167 | BT_DBG("Enter"); | 166 | BT_DBG("Enter"); |
168 | 167 | ||
@@ -181,7 +180,7 @@ int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd) | |||
181 | bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; | 180 | bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; |
182 | 181 | ||
183 | skb_put(skb, sizeof(*cmd)); | 182 | skb_put(skb, sizeof(*cmd)); |
184 | skb->dev = (void *)priv->btmrvl_dev.hcidev; | 183 | skb->dev = (void *) priv->btmrvl_dev.hcidev; |
185 | skb_queue_head(&priv->adapter->tx_queue, skb); | 184 | skb_queue_head(&priv->adapter->tx_queue, skb); |
186 | 185 | ||
187 | priv->btmrvl_dev.sendcmdflag = true; | 186 | priv->btmrvl_dev.sendcmdflag = true; |
@@ -192,13 +191,12 @@ int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd) | |||
192 | 191 | ||
193 | wake_up_interruptible(&priv->main_thread.wait_q); | 192 | wake_up_interruptible(&priv->main_thread.wait_q); |
194 | 193 | ||
195 | if (!wait_event_interruptible_timeout( | 194 | if (!wait_event_interruptible_timeout(priv->adapter->cmd_wait_q, |
196 | priv->adapter->cmd_wait_q, | 195 | priv->adapter->cmd_complete, |
197 | priv->adapter->cmd_complete, | 196 | msecs_to_jiffies(WAIT_UNTIL_CMD_RESP))) { |
198 | msecs_to_jiffies(WAIT_UNTIL_CMD_RESP))) { | ||
199 | ret = -ETIMEDOUT; | 197 | ret = -ETIMEDOUT; |
200 | BT_ERR("module_cfg_cmd(%x): timeout: %d", | 198 | BT_ERR("module_cfg_cmd(%x): timeout: %d", |
201 | subcmd, priv->btmrvl_dev.sendcmdflag); | 199 | subcmd, priv->btmrvl_dev.sendcmdflag); |
202 | } | 200 | } |
203 | 201 | ||
204 | BT_DBG("module cfg Command done"); | 202 | BT_DBG("module cfg Command done"); |
@@ -212,9 +210,9 @@ EXPORT_SYMBOL_GPL(btmrvl_send_module_cfg_cmd); | |||
212 | 210 | ||
213 | static int btmrvl_enable_hs(struct btmrvl_private *priv) | 211 | static int btmrvl_enable_hs(struct btmrvl_private *priv) |
214 | { | 212 | { |
215 | struct sk_buff *skb = NULL; | 213 | struct sk_buff *skb; |
216 | u8 ret = 0; | ||
217 | struct btmrvl_cmd *cmd; | 214 | struct btmrvl_cmd *cmd; |
215 | u8 ret = 0; | ||
218 | 216 | ||
219 | BT_DBG("Enter"); | 217 | BT_DBG("Enter"); |
220 | 218 | ||
@@ -232,22 +230,20 @@ static int btmrvl_enable_hs(struct btmrvl_private *priv) | |||
232 | bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; | 230 | bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; |
233 | 231 | ||
234 | skb_put(skb, sizeof(*cmd)); | 232 | skb_put(skb, sizeof(*cmd)); |
235 | skb->dev = (void *)priv->btmrvl_dev.hcidev; | 233 | skb->dev = (void *) priv->btmrvl_dev.hcidev; |
236 | skb_queue_head(&priv->adapter->tx_queue, skb); | 234 | skb_queue_head(&priv->adapter->tx_queue, skb); |
237 | 235 | ||
238 | BT_DBG("Queue hs enable Command"); | 236 | BT_DBG("Queue hs enable Command"); |
239 | 237 | ||
240 | wake_up_interruptible(&priv->main_thread.wait_q); | 238 | wake_up_interruptible(&priv->main_thread.wait_q); |
241 | 239 | ||
242 | if (!wait_event_interruptible_timeout( | 240 | if (!wait_event_interruptible_timeout(priv->adapter->cmd_wait_q, |
243 | priv->adapter->cmd_wait_q, | ||
244 | priv->adapter->hs_state, | 241 | priv->adapter->hs_state, |
245 | msecs_to_jiffies(WAIT_UNTIL_HS_STATE_CHANGED))) { | 242 | msecs_to_jiffies(WAIT_UNTIL_HS_STATE_CHANGED))) { |
246 | ret = -ETIMEDOUT; | 243 | ret = -ETIMEDOUT; |
247 | BT_ERR("timeout: %d, %d,%d", | 244 | BT_ERR("timeout: %d, %d,%d", priv->adapter->hs_state, |
248 | priv->adapter->hs_state, | 245 | priv->adapter->ps_state, |
249 | priv->adapter->ps_state, | 246 | priv->adapter->wakeup_tries); |
250 | priv->adapter->wakeup_tries); | ||
251 | } | 247 | } |
252 | 248 | ||
253 | exit: | 249 | exit: |
@@ -259,8 +255,8 @@ exit: | |||
259 | int btmrvl_prepare_command(struct btmrvl_private *priv) | 255 | int btmrvl_prepare_command(struct btmrvl_private *priv) |
260 | { | 256 | { |
261 | struct sk_buff *skb = NULL; | 257 | struct sk_buff *skb = NULL; |
262 | u8 ret = 0; | ||
263 | struct btmrvl_cmd *cmd; | 258 | struct btmrvl_cmd *cmd; |
259 | u8 ret = 0; | ||
264 | 260 | ||
265 | BT_DBG("Enter"); | 261 | BT_DBG("Enter"); |
266 | 262 | ||
@@ -284,11 +280,11 @@ int btmrvl_prepare_command(struct btmrvl_private *priv) | |||
284 | bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; | 280 | bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; |
285 | 281 | ||
286 | skb_put(skb, sizeof(*cmd)); | 282 | skb_put(skb, sizeof(*cmd)); |
287 | skb->dev = (void *)priv->btmrvl_dev.hcidev; | 283 | skb->dev = (void *) priv->btmrvl_dev.hcidev; |
288 | skb_queue_head(&priv->adapter->tx_queue, skb); | 284 | skb_queue_head(&priv->adapter->tx_queue, skb); |
289 | 285 | ||
290 | BT_DBG("Queue HSCFG Command, gpio=0x%x, gap=0x%x", | 286 | BT_DBG("Queue HSCFG Command, gpio=0x%x, gap=0x%x", |
291 | cmd->data[0], cmd->data[1]); | 287 | cmd->data[0], cmd->data[1]); |
292 | } | 288 | } |
293 | 289 | ||
294 | if (priv->btmrvl_dev.pscmd) { | 290 | if (priv->btmrvl_dev.pscmd) { |
@@ -314,7 +310,7 @@ int btmrvl_prepare_command(struct btmrvl_private *priv) | |||
314 | bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; | 310 | bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; |
315 | 311 | ||
316 | skb_put(skb, sizeof(*cmd)); | 312 | skb_put(skb, sizeof(*cmd)); |
317 | skb->dev = (void *)priv->btmrvl_dev.hcidev; | 313 | skb->dev = (void *) priv->btmrvl_dev.hcidev; |
318 | skb_queue_head(&priv->adapter->tx_queue, skb); | 314 | skb_queue_head(&priv->adapter->tx_queue, skb); |
319 | 315 | ||
320 | BT_DBG("Queue PSMODE Command:%d", cmd->data[0]); | 316 | BT_DBG("Queue PSMODE Command:%d", cmd->data[0]); |
@@ -350,7 +346,7 @@ static int btmrvl_tx_pkt(struct btmrvl_private *priv, struct sk_buff *skb) | |||
350 | 346 | ||
351 | if (!skb->len || ((skb->len + BTM_HEADER_LEN) > BTM_UPLD_SIZE)) { | 347 | if (!skb->len || ((skb->len + BTM_HEADER_LEN) > BTM_UPLD_SIZE)) { |
352 | BT_ERR("Tx Error: Bad skb length %d : %d", | 348 | BT_ERR("Tx Error: Bad skb length %d : %d", |
353 | skb->len, BTM_UPLD_SIZE); | 349 | skb->len, BTM_UPLD_SIZE); |
354 | BT_DBG("Leave"); | 350 | BT_DBG("Leave"); |
355 | return -EINVAL; | 351 | return -EINVAL; |
356 | } | 352 | } |
@@ -416,8 +412,8 @@ static void btmrvl_free_adapter(struct btmrvl_private *priv) | |||
416 | BT_DBG("Leave"); | 412 | BT_DBG("Leave"); |
417 | } | 413 | } |
418 | 414 | ||
419 | static int | 415 | static int btmrvl_ioctl(struct hci_dev *hdev, |
420 | btmrvl_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg) | 416 | unsigned int cmd, unsigned long arg) |
421 | { | 417 | { |
422 | BT_DBG("Enter"); | 418 | BT_DBG("Enter"); |
423 | 419 | ||
@@ -435,7 +431,7 @@ static void btmrvl_destruct(struct hci_dev *hdev) | |||
435 | 431 | ||
436 | static int btmrvl_send_frame(struct sk_buff *skb) | 432 | static int btmrvl_send_frame(struct sk_buff *skb) |
437 | { | 433 | { |
438 | struct hci_dev *hdev = (struct hci_dev *)skb->dev; | 434 | struct hci_dev *hdev = (struct hci_dev *) skb->dev; |
439 | struct btmrvl_private *priv = NULL; | 435 | struct btmrvl_private *priv = NULL; |
440 | 436 | ||
441 | BT_DBG("Enter: type=%d, len=%d", skb->pkt_type, skb->len); | 437 | BT_DBG("Enter: type=%d, len=%d", skb->pkt_type, skb->len); |
@@ -446,11 +442,11 @@ static int btmrvl_send_frame(struct sk_buff *skb) | |||
446 | return -ENODEV; | 442 | return -ENODEV; |
447 | } | 443 | } |
448 | 444 | ||
449 | priv = (struct btmrvl_private *)hdev->driver_data; | 445 | priv = (struct btmrvl_private *) hdev->driver_data; |
450 | if (!test_bit(HCI_RUNNING, &hdev->flags)) { | 446 | if (!test_bit(HCI_RUNNING, &hdev->flags)) { |
451 | BT_ERR("Failed testing HCI_RUNING, flags=%lx", hdev->flags); | 447 | BT_ERR("Failed testing HCI_RUNING, flags=%lx", hdev->flags); |
452 | print_hex_dump_bytes("data: ", DUMP_PREFIX_OFFSET, | 448 | print_hex_dump_bytes("data: ", DUMP_PREFIX_OFFSET, |
453 | skb->data, skb->len); | 449 | skb->data, skb->len); |
454 | BT_DBG("Leave"); | 450 | BT_DBG("Leave"); |
455 | return -EBUSY; | 451 | return -EBUSY; |
456 | } | 452 | } |
@@ -480,8 +476,7 @@ static int btmrvl_send_frame(struct sk_buff *skb) | |||
480 | 476 | ||
481 | static int btmrvl_flush(struct hci_dev *hdev) | 477 | static int btmrvl_flush(struct hci_dev *hdev) |
482 | { | 478 | { |
483 | struct btmrvl_private *priv = | 479 | struct btmrvl_private *priv = hdev->driver_data; |
484 | (struct btmrvl_private *) hdev->driver_data; | ||
485 | 480 | ||
486 | BT_DBG("Enter"); | 481 | BT_DBG("Enter"); |
487 | 482 | ||
@@ -494,8 +489,7 @@ static int btmrvl_flush(struct hci_dev *hdev) | |||
494 | 489 | ||
495 | static int btmrvl_close(struct hci_dev *hdev) | 490 | static int btmrvl_close(struct hci_dev *hdev) |
496 | { | 491 | { |
497 | struct btmrvl_private *priv = | 492 | struct btmrvl_private *priv = hdev->driver_data; |
498 | (struct btmrvl_private *) hdev->driver_data; | ||
499 | 493 | ||
500 | BT_DBG("Enter"); | 494 | BT_DBG("Enter"); |
501 | 495 | ||
@@ -547,9 +541,9 @@ static int btmrvl_service_main_thread(void *data) | |||
547 | set_current_state(TASK_INTERRUPTIBLE); | 541 | set_current_state(TASK_INTERRUPTIBLE); |
548 | 542 | ||
549 | if (adapter->wakeup_tries || | 543 | if (adapter->wakeup_tries || |
550 | ((!adapter->int_count) && | 544 | ((!adapter->int_count) && |
551 | (!priv->btmrvl_dev.tx_dnld_rdy || | 545 | (!priv->btmrvl_dev.tx_dnld_rdy || |
552 | skb_queue_empty(&adapter->tx_queue)))) { | 546 | skb_queue_empty(&adapter->tx_queue)))) { |
553 | BT_DBG("main_thread is sleeping..."); | 547 | BT_DBG("main_thread is sleeping..."); |
554 | schedule(); | 548 | schedule(); |
555 | } | 549 | } |
@@ -568,8 +562,8 @@ static int btmrvl_service_main_thread(void *data) | |||
568 | spin_lock_irqsave(&priv->driver_lock, flags); | 562 | spin_lock_irqsave(&priv->driver_lock, flags); |
569 | if (adapter->int_count) { | 563 | if (adapter->int_count) { |
570 | adapter->int_count = 0; | 564 | adapter->int_count = 0; |
571 | } else if ((adapter->ps_state == PS_SLEEP) && | 565 | } else if (adapter->ps_state == PS_SLEEP && |
572 | !skb_queue_empty(&adapter->tx_queue)) { | 566 | !skb_queue_empty(&adapter->tx_queue)) { |
573 | spin_unlock_irqrestore(&priv->driver_lock, flags); | 567 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
574 | adapter->wakeup_tries++; | 568 | adapter->wakeup_tries++; |
575 | priv->hw_wakeup_firmware(priv); | 569 | priv->hw_wakeup_firmware(priv); |
@@ -588,8 +582,7 @@ static int btmrvl_service_main_thread(void *data) | |||
588 | if (btmrvl_tx_pkt(priv, skb)) | 582 | if (btmrvl_tx_pkt(priv, skb)) |
589 | priv->btmrvl_dev.hcidev->stat.err_tx++; | 583 | priv->btmrvl_dev.hcidev->stat.err_tx++; |
590 | else | 584 | else |
591 | priv->btmrvl_dev.hcidev->stat.byte_tx | 585 | priv->btmrvl_dev.hcidev->stat.byte_tx += skb->len; |
592 | += skb->len; | ||
593 | 586 | ||
594 | kfree_skb(skb); | 587 | kfree_skb(skb); |
595 | } | 588 | } |
@@ -603,7 +596,7 @@ static int btmrvl_service_main_thread(void *data) | |||
603 | struct btmrvl_private *btmrvl_add_card(void *card) | 596 | struct btmrvl_private *btmrvl_add_card(void *card) |
604 | { | 597 | { |
605 | struct hci_dev *hdev = NULL; | 598 | struct hci_dev *hdev = NULL; |
606 | struct btmrvl_private *priv = NULL; | 599 | struct btmrvl_private *priv; |
607 | int ret; | 600 | int ret; |
608 | 601 | ||
609 | BT_DBG("Enter"); | 602 | BT_DBG("Enter"); |
@@ -634,7 +627,7 @@ struct btmrvl_private *btmrvl_add_card(void *card) | |||
634 | 627 | ||
635 | init_waitqueue_head(&priv->main_thread.wait_q); | 628 | init_waitqueue_head(&priv->main_thread.wait_q); |
636 | priv->main_thread.task = kthread_run(btmrvl_service_main_thread, | 629 | priv->main_thread.task = kthread_run(btmrvl_service_main_thread, |
637 | &priv->main_thread, "btmrvl_main_service"); | 630 | &priv->main_thread, "btmrvl_main_service"); |
638 | 631 | ||
639 | priv->btmrvl_dev.hcidev = hdev; | 632 | priv->btmrvl_dev.hcidev = hdev; |
640 | priv->btmrvl_dev.card = card; | 633 | priv->btmrvl_dev.card = card; |
@@ -717,6 +710,6 @@ int btmrvl_remove_card(struct btmrvl_private *priv) | |||
717 | EXPORT_SYMBOL_GPL(btmrvl_remove_card); | 710 | EXPORT_SYMBOL_GPL(btmrvl_remove_card); |
718 | 711 | ||
719 | MODULE_AUTHOR("Marvell International Ltd."); | 712 | MODULE_AUTHOR("Marvell International Ltd."); |
720 | MODULE_DESCRIPTION("Marvell Bluetooth Driver v" VERSION); | 713 | MODULE_DESCRIPTION("Marvell Bluetooth Driver ver" VERSION); |
721 | MODULE_VERSION(VERSION); | 714 | MODULE_VERSION(VERSION); |
722 | MODULE_LICENSE("GPL v2"); | 715 | MODULE_LICENSE("GPL v2"); |