aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bluetooth/btmrvl_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/bluetooth/btmrvl_main.c')
-rw-r--r--drivers/bluetooth/btmrvl_main.c92
1 files changed, 57 insertions, 35 deletions
diff --git a/drivers/bluetooth/btmrvl_main.c b/drivers/bluetooth/btmrvl_main.c
index 53a43adf2e21..ee37ef0caee2 100644
--- a/drivers/bluetooth/btmrvl_main.c
+++ b/drivers/bluetooth/btmrvl_main.c
@@ -66,7 +66,7 @@ int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb)
66{ 66{
67 struct btmrvl_adapter *adapter = priv->adapter; 67 struct btmrvl_adapter *adapter = priv->adapter;
68 struct btmrvl_event *event; 68 struct btmrvl_event *event;
69 u8 ret = 0; 69 int ret = 0;
70 70
71 event = (struct btmrvl_event *) skb->data; 71 event = (struct btmrvl_event *) skb->data;
72 if (event->ec != 0xff) { 72 if (event->ec != 0xff) {
@@ -112,8 +112,17 @@ int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb)
112 case BT_CMD_MODULE_CFG_REQ: 112 case BT_CMD_MODULE_CFG_REQ:
113 if (priv->btmrvl_dev.sendcmdflag && 113 if (priv->btmrvl_dev.sendcmdflag &&
114 event->data[1] == MODULE_BRINGUP_REQ) { 114 event->data[1] == MODULE_BRINGUP_REQ) {
115 BT_DBG("EVENT:%s", (event->data[2]) ? 115 BT_DBG("EVENT:%s",
116 "Bring-up failed" : "Bring-up succeed"); 116 ((event->data[2] == MODULE_BROUGHT_UP) ||
117 (event->data[2] == MODULE_ALREADY_UP)) ?
118 "Bring-up succeed" : "Bring-up failed");
119
120 if (event->length > 3)
121 priv->btmrvl_dev.dev_type = event->data[3];
122 else
123 priv->btmrvl_dev.dev_type = HCI_BREDR;
124
125 BT_DBG("dev_type: %d", priv->btmrvl_dev.dev_type);
117 } else if (priv->btmrvl_dev.sendcmdflag && 126 } else if (priv->btmrvl_dev.sendcmdflag &&
118 event->data[1] == MODULE_SHUTDOWN_REQ) { 127 event->data[1] == MODULE_SHUTDOWN_REQ) {
119 BT_DBG("EVENT:%s", (event->data[2]) ? 128 BT_DBG("EVENT:%s", (event->data[2]) ?
@@ -522,47 +531,20 @@ static int btmrvl_service_main_thread(void *data)
522 return 0; 531 return 0;
523} 532}
524 533
525struct btmrvl_private *btmrvl_add_card(void *card) 534int btmrvl_register_hdev(struct btmrvl_private *priv)
526{ 535{
527 struct hci_dev *hdev = NULL; 536 struct hci_dev *hdev = NULL;
528 struct btmrvl_private *priv;
529 int ret; 537 int ret;
530 538
531 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
532 if (!priv) {
533 BT_ERR("Can not allocate priv");
534 goto err_priv;
535 }
536
537 priv->adapter = kzalloc(sizeof(*priv->adapter), GFP_KERNEL);
538 if (!priv->adapter) {
539 BT_ERR("Allocate buffer for btmrvl_adapter failed!");
540 goto err_adapter;
541 }
542
543 btmrvl_init_adapter(priv);
544
545 hdev = hci_alloc_dev(); 539 hdev = hci_alloc_dev();
546 if (!hdev) { 540 if (!hdev) {
547 BT_ERR("Can not allocate HCI device"); 541 BT_ERR("Can not allocate HCI device");
548 goto err_hdev; 542 goto err_hdev;
549 } 543 }
550 544
551 BT_DBG("Starting kthread...");
552 priv->main_thread.priv = priv;
553 spin_lock_init(&priv->driver_lock);
554
555 init_waitqueue_head(&priv->main_thread.wait_q);
556 priv->main_thread.task = kthread_run(btmrvl_service_main_thread,
557 &priv->main_thread, "btmrvl_main_service");
558
559 priv->btmrvl_dev.hcidev = hdev; 545 priv->btmrvl_dev.hcidev = hdev;
560 priv->btmrvl_dev.card = card;
561
562 hdev->driver_data = priv; 546 hdev->driver_data = priv;
563 547
564 priv->btmrvl_dev.tx_dnld_rdy = true;
565
566 hdev->bus = HCI_SDIO; 548 hdev->bus = HCI_SDIO;
567 hdev->open = btmrvl_open; 549 hdev->open = btmrvl_open;
568 hdev->close = btmrvl_close; 550 hdev->close = btmrvl_close;
@@ -572,6 +554,10 @@ struct btmrvl_private *btmrvl_add_card(void *card)
572 hdev->ioctl = btmrvl_ioctl; 554 hdev->ioctl = btmrvl_ioctl;
573 hdev->owner = THIS_MODULE; 555 hdev->owner = THIS_MODULE;
574 556
557 btmrvl_send_module_cfg_cmd(priv, MODULE_BRINGUP_REQ);
558
559 hdev->dev_type = priv->btmrvl_dev.dev_type;
560
575 ret = hci_register_dev(hdev); 561 ret = hci_register_dev(hdev);
576 if (ret < 0) { 562 if (ret < 0) {
577 BT_ERR("Can not register HCI device"); 563 BT_ERR("Can not register HCI device");
@@ -582,16 +568,52 @@ struct btmrvl_private *btmrvl_add_card(void *card)
582 btmrvl_debugfs_init(hdev); 568 btmrvl_debugfs_init(hdev);
583#endif 569#endif
584 570
585 return priv; 571 return 0;
586 572
587err_hci_register_dev: 573err_hci_register_dev:
588 /* Stop the thread servicing the interrupts */
589 kthread_stop(priv->main_thread.task);
590
591 hci_free_dev(hdev); 574 hci_free_dev(hdev);
592 575
593err_hdev: 576err_hdev:
577 /* Stop the thread servicing the interrupts */
578 kthread_stop(priv->main_thread.task);
579
594 btmrvl_free_adapter(priv); 580 btmrvl_free_adapter(priv);
581 kfree(priv);
582
583 return -ENOMEM;
584}
585EXPORT_SYMBOL_GPL(btmrvl_register_hdev);
586
587struct btmrvl_private *btmrvl_add_card(void *card)
588{
589 struct btmrvl_private *priv;
590
591 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
592 if (!priv) {
593 BT_ERR("Can not allocate priv");
594 goto err_priv;
595 }
596
597 priv->adapter = kzalloc(sizeof(*priv->adapter), GFP_KERNEL);
598 if (!priv->adapter) {
599 BT_ERR("Allocate buffer for btmrvl_adapter failed!");
600 goto err_adapter;
601 }
602
603 btmrvl_init_adapter(priv);
604
605 BT_DBG("Starting kthread...");
606 priv->main_thread.priv = priv;
607 spin_lock_init(&priv->driver_lock);
608
609 init_waitqueue_head(&priv->main_thread.wait_q);
610 priv->main_thread.task = kthread_run(btmrvl_service_main_thread,
611 &priv->main_thread, "btmrvl_main_service");
612
613 priv->btmrvl_dev.card = card;
614 priv->btmrvl_dev.tx_dnld_rdy = true;
615
616 return priv;
595 617
596err_adapter: 618err_adapter:
597 kfree(priv); 619 kfree(priv);