Bluetooth: Separate btmrvl_register_hdev() from btmrvl_add_card()
[linux-3.10.git] / drivers / bluetooth / btmrvl_main.c
index b4f4445..ec48bfe 100644 (file)
@@ -32,8 +32,6 @@
  */
 void btmrvl_interrupt(struct btmrvl_private *priv)
 {
-       BT_DBG("Enter");
-
        priv->adapter->ps_state = PS_AWAKE;
 
        priv->adapter->wakeup_tries = 0;
@@ -41,43 +39,34 @@ void btmrvl_interrupt(struct btmrvl_private *priv)
        priv->adapter->int_count++;
 
        wake_up_interruptible(&priv->main_thread.wait_q);
-
-       BT_DBG("Leave");
 }
 EXPORT_SYMBOL_GPL(btmrvl_interrupt);
 
 void btmrvl_check_evtpkt(struct btmrvl_private *priv, struct sk_buff *skb)
 {
-       struct hci_event_hdr *hdr = (struct hci_event_hdr *)skb->data;
+       struct hci_event_hdr *hdr = (void *) skb->data;
        struct hci_ev_cmd_complete *ec;
        u16 opcode, ocf;
 
-       BT_DBG("Enter");
-
        if (hdr->evt == HCI_EV_CMD_COMPLETE) {
-               ec = (struct hci_ev_cmd_complete *)(skb->data +
-                                                   HCI_EVENT_HDR_SIZE);
+               ec = (void *) (skb->data + HCI_EVENT_HDR_SIZE);
                opcode = __le16_to_cpu(ec->opcode);
                ocf = hci_opcode_ocf(opcode);
-               if ((ocf == BT_CMD_MODULE_CFG_REQ) &&
-                   (priv->btmrvl_dev.sendcmdflag)) {
+               if (ocf == BT_CMD_MODULE_CFG_REQ &&
+                                       priv->btmrvl_dev.sendcmdflag) {
                        priv->btmrvl_dev.sendcmdflag = false;
                        priv->adapter->cmd_complete = true;
                        wake_up_interruptible(&priv->adapter->cmd_wait_q);
                }
        }
-
-       BT_DBG("Leave");
 }
 EXPORT_SYMBOL_GPL(btmrvl_check_evtpkt);
 
 int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb)
 {
        struct btmrvl_adapter *adapter = priv->adapter;
-       u8 ret = 0;
        struct btmrvl_event *event;
-
-       BT_DBG("Enter");
+       int ret = 0;
 
        event = (struct btmrvl_event *) skb->data;
        if (event->ec != 0xff) {
@@ -103,7 +92,7 @@ int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb)
        case BT_CMD_HOST_SLEEP_CONFIG:
                if (!event->data[3])
                        BT_DBG("gpio=%x, gap=%x", event->data[1],
-                               event->data[2]);
+                                                       event->data[2]);
                else
                        BT_DBG("HSCFG command failed");
                break;
@@ -121,12 +110,14 @@ int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb)
                break;
 
        case BT_CMD_MODULE_CFG_REQ:
-               if ((priv->btmrvl_dev.sendcmdflag) &&
-                       (event->data[1] == MODULE_BRINGUP_REQ)) {
-                       BT_DBG("EVENT:%s", (event->data[2]) ?
-                               "Bring-up failed" : "Bring-up succeed");
-               } else if ((priv->btmrvl_dev.sendcmdflag) &&
-                       (event->data[1] == MODULE_SHUTDOWN_REQ)) {
+               if (priv->btmrvl_dev.sendcmdflag &&
+                               event->data[1] == MODULE_BRINGUP_REQ) {
+                       BT_DBG("EVENT:%s",
+                               ((event->data[2] == MODULE_BROUGHT_UP) ||
+                               (event->data[2] == MODULE_ALREADY_UP)) ?
+                               "Bring-up succeed" : "Bring-up failed");
+               } else if (priv->btmrvl_dev.sendcmdflag &&
+                               event->data[1] == MODULE_SHUTDOWN_REQ) {
                        BT_DBG("EVENT:%s", (event->data[2]) ?
                                "Shutdown failed" : "Shutdown succeed");
                } else {
@@ -152,36 +143,30 @@ exit:
        if (!ret)
                kfree_skb(skb);
 
-       BT_DBG("Leave");
-
        return ret;
 }
 EXPORT_SYMBOL_GPL(btmrvl_process_event);
 
 int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd)
 {
-       struct sk_buff *skb = NULL;
-       u8 ret = 0;
+       struct sk_buff *skb;
        struct btmrvl_cmd *cmd;
-
-       BT_DBG("Enter");
+       int ret = 0;
 
        skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
        if (skb == NULL) {
                BT_ERR("No free skb");
-               ret = -ENOMEM;
-               goto exit;
+               return -ENOMEM;
        }
 
-       cmd = (struct btmrvl_cmd *) skb->tail;
-       cmd->ocf_ogf = cpu_to_le16((OGF << 10) | BT_CMD_MODULE_CFG_REQ);
+       cmd = (struct btmrvl_cmd *) skb_put(skb, sizeof(*cmd));
+       cmd->ocf_ogf = cpu_to_le16(hci_opcode_pack(OGF, BT_CMD_MODULE_CFG_REQ));
        cmd->length = 1;
        cmd->data[0] = subcmd;
 
        bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT;
 
-       skb_put(skb, sizeof(*cmd));
-       skb->dev = (void *)priv->btmrvl_dev.hcidev;
+       skb->dev = (void *) priv->btmrvl_dev.hcidev;
        skb_queue_head(&priv->adapter->tx_queue, skb);
 
        priv->btmrvl_dev.sendcmdflag = true;
@@ -192,77 +177,94 @@ int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd)
 
        wake_up_interruptible(&priv->main_thread.wait_q);
 
-       if (!wait_event_interruptible_timeout(
-                       priv->adapter->cmd_wait_q,
-                       priv->adapter->cmd_complete,
-                       msecs_to_jiffies(WAIT_UNTIL_CMD_RESP))) {
+       if (!wait_event_interruptible_timeout(priv->adapter->cmd_wait_q,
+                               priv->adapter->cmd_complete,
+                               msecs_to_jiffies(WAIT_UNTIL_CMD_RESP))) {
                ret = -ETIMEDOUT;
                BT_ERR("module_cfg_cmd(%x): timeout: %d",
-                       subcmd, priv->btmrvl_dev.sendcmdflag);
+                                       subcmd, priv->btmrvl_dev.sendcmdflag);
        }
 
        BT_DBG("module cfg Command done");
 
-exit:
-       BT_DBG("Leave");
-
        return ret;
 }
 EXPORT_SYMBOL_GPL(btmrvl_send_module_cfg_cmd);
 
-static int btmrvl_enable_hs(struct btmrvl_private *priv)
+int btmrvl_enable_ps(struct btmrvl_private *priv)
 {
-       struct sk_buff *skb = NULL;
-       u8 ret = 0;
+       struct sk_buff *skb;
        struct btmrvl_cmd *cmd;
 
-       BT_DBG("Enter");
+       skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
+       if (skb == NULL) {
+               BT_ERR("No free skb");
+               return -ENOMEM;
+       }
+
+       cmd = (struct btmrvl_cmd *) skb_put(skb, sizeof(*cmd));
+       cmd->ocf_ogf = cpu_to_le16(hci_opcode_pack(OGF,
+                                       BT_CMD_AUTO_SLEEP_MODE));
+       cmd->length = 1;
+
+       if (priv->btmrvl_dev.psmode)
+               cmd->data[0] = BT_PS_ENABLE;
+       else
+               cmd->data[0] = BT_PS_DISABLE;
+
+       bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT;
+
+       skb->dev = (void *) priv->btmrvl_dev.hcidev;
+       skb_queue_head(&priv->adapter->tx_queue, skb);
+
+       BT_DBG("Queue PSMODE Command:%d", cmd->data[0]);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(btmrvl_enable_ps);
+
+static int btmrvl_enable_hs(struct btmrvl_private *priv)
+{
+       struct sk_buff *skb;
+       struct btmrvl_cmd *cmd;
+       int ret = 0;
 
        skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
        if (skb == NULL) {
                BT_ERR("No free skb");
-               ret = -ENOMEM;
-               goto exit;
+               return -ENOMEM;
        }
 
-       cmd = (struct btmrvl_cmd *) skb->tail;
-       cmd->ocf_ogf = cpu_to_le16((OGF << 10) | BT_CMD_HOST_SLEEP_ENABLE);
+       cmd = (struct btmrvl_cmd *) skb_put(skb, sizeof(*cmd));
+       cmd->ocf_ogf = cpu_to_le16(hci_opcode_pack(OGF, BT_CMD_HOST_SLEEP_ENABLE));
        cmd->length = 0;
 
        bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT;
 
-       skb_put(skb, sizeof(*cmd));
-       skb->dev = (void *)priv->btmrvl_dev.hcidev;
+       skb->dev = (void *) priv->btmrvl_dev.hcidev;
        skb_queue_head(&priv->adapter->tx_queue, skb);
 
        BT_DBG("Queue hs enable Command");
 
        wake_up_interruptible(&priv->main_thread.wait_q);
 
-       if (!wait_event_interruptible_timeout(
-                       priv->adapter->cmd_wait_q,
+       if (!wait_event_interruptible_timeout(priv->adapter->cmd_wait_q,
                        priv->adapter->hs_state,
                        msecs_to_jiffies(WAIT_UNTIL_HS_STATE_CHANGED))) {
                ret = -ETIMEDOUT;
-               BT_ERR("timeout: %d, %d,%d",
-                       priv->adapter->hs_state,
-                       priv->adapter->ps_state,
-                       priv->adapter->wakeup_tries);
+               BT_ERR("timeout: %d, %d,%d", priv->adapter->hs_state,
+                                               priv->adapter->ps_state,
+                                               priv->adapter->wakeup_tries);
        }
 
-exit:
-       BT_DBG("Leave");
-
        return ret;
 }
 
 int btmrvl_prepare_command(struct btmrvl_private *priv)
 {
        struct sk_buff *skb = NULL;
-       u8 ret = 0;
        struct btmrvl_cmd *cmd;
-
-       BT_DBG("Enter");
+       int ret = 0;
 
        if (priv->btmrvl_dev.hscfgcmd) {
                priv->btmrvl_dev.hscfgcmd = 0;
@@ -270,54 +272,27 @@ int btmrvl_prepare_command(struct btmrvl_private *priv)
                skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
                if (skb == NULL) {
                        BT_ERR("No free skb");
-                       ret = -ENOMEM;
-                       goto exit;
+                       return -ENOMEM;
                }
 
-               cmd = (struct btmrvl_cmd *) skb->tail;
-               cmd->ocf_ogf = cpu_to_le16((OGF << 10) |
-                                               BT_CMD_HOST_SLEEP_CONFIG);
+               cmd = (struct btmrvl_cmd *) skb_put(skb, sizeof(*cmd));
+               cmd->ocf_ogf = cpu_to_le16(hci_opcode_pack(OGF, BT_CMD_HOST_SLEEP_CONFIG));
                cmd->length = 2;
                cmd->data[0] = (priv->btmrvl_dev.gpio_gap & 0xff00) >> 8;
                cmd->data[1] = (u8) (priv->btmrvl_dev.gpio_gap & 0x00ff);
 
                bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT;
 
-               skb_put(skb, sizeof(*cmd));
-               skb->dev = (void *)priv->btmrvl_dev.hcidev;
+               skb->dev = (void *) priv->btmrvl_dev.hcidev;
                skb_queue_head(&priv->adapter->tx_queue, skb);
 
                BT_DBG("Queue HSCFG Command, gpio=0x%x, gap=0x%x",
-                      cmd->data[0], cmd->data[1]);
+                                               cmd->data[0], cmd->data[1]);
        }
 
        if (priv->btmrvl_dev.pscmd) {
                priv->btmrvl_dev.pscmd = 0;
-
-               skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
-               if (skb == NULL) {
-                       BT_ERR("No free skb");
-                       ret = -ENOMEM;
-                       goto exit;
-               }
-
-               cmd = (struct btmrvl_cmd *) skb->tail;
-               cmd->ocf_ogf = cpu_to_le16((OGF << 10) |
-                                               BT_CMD_AUTO_SLEEP_MODE);
-               cmd->length = 1;
-
-               if (priv->btmrvl_dev.psmode)
-                       cmd->data[0] = BT_PS_ENABLE;
-               else
-                       cmd->data[0] = BT_PS_DISABLE;
-
-               bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT;
-
-               skb_put(skb, sizeof(*cmd));
-               skb->dev = (void *)priv->btmrvl_dev.hcidev;
-               skb_queue_head(&priv->adapter->tx_queue, skb);
-
-               BT_DBG("Queue PSMODE Command:%d", cmd->data[0]);
+               btmrvl_enable_ps(priv);
        }
 
        if (priv->btmrvl_dev.hscmd) {
@@ -331,27 +306,19 @@ int btmrvl_prepare_command(struct btmrvl_private *priv)
                }
        }
 
-exit:
-       BT_DBG("Leave");
-
        return ret;
 }
 
 static int btmrvl_tx_pkt(struct btmrvl_private *priv, struct sk_buff *skb)
 {
-       u8 ret = 0;
+       int ret = 0;
 
-       BT_DBG("Enter");
-
-       if (!skb || !skb->data) {
-               BT_DBG("Leave");
+       if (!skb || !skb->data)
                return -EINVAL;
-       }
 
        if (!skb->len || ((skb->len + BTM_HEADER_LEN) > BTM_UPLD_SIZE)) {
                BT_ERR("Tx Error: Bad skb length %d : %d",
-                       skb->len, BTM_UPLD_SIZE);
-               BT_DBG("Leave");
+                                               skb->len, BTM_UPLD_SIZE);
                return -EINVAL;
        }
 
@@ -363,7 +330,6 @@ static int btmrvl_tx_pkt(struct btmrvl_private *priv, struct sk_buff *skb)
                        BT_ERR("Tx Error: realloc_headroom failed %d",
                                BTM_HEADER_LEN);
                        skb = tmp;
-                       BT_DBG("Leave");
                        return -EINVAL;
                }
 
@@ -385,73 +351,54 @@ static int btmrvl_tx_pkt(struct btmrvl_private *priv, struct sk_buff *skb)
        if (priv->hw_host_to_card)
                ret = priv->hw_host_to_card(priv, skb->data, skb->len);
 
-       BT_DBG("Leave");
-
        return ret;
 }
 
 static void btmrvl_init_adapter(struct btmrvl_private *priv)
 {
-       BT_DBG("Enter");
-
        skb_queue_head_init(&priv->adapter->tx_queue);
 
        priv->adapter->ps_state = PS_AWAKE;
 
        init_waitqueue_head(&priv->adapter->cmd_wait_q);
-
-       BT_DBG("Leave");
 }
 
 static void btmrvl_free_adapter(struct btmrvl_private *priv)
 {
-       BT_DBG("Enter");
-
        skb_queue_purge(&priv->adapter->tx_queue);
 
        kfree(priv->adapter);
 
        priv->adapter = NULL;
-
-       BT_DBG("Leave");
 }
 
-static int
-btmrvl_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg)
+static int btmrvl_ioctl(struct hci_dev *hdev,
+                               unsigned int cmd, unsigned long arg)
 {
-       BT_DBG("Enter");
-
-       BT_DBG("Leave");
-
        return -ENOIOCTLCMD;
 }
 
 static void btmrvl_destruct(struct hci_dev *hdev)
 {
-       BT_DBG("Enter");
-
-       BT_DBG("Leave");
 }
 
 static int btmrvl_send_frame(struct sk_buff *skb)
 {
-       struct hci_dev *hdev = (struct hci_dev *)skb->dev;
+       struct hci_dev *hdev = (struct hci_dev *) skb->dev;
        struct btmrvl_private *priv = NULL;
 
-       BT_DBG("Enter: type=%d, len=%d", skb->pkt_type, skb->len);
+       BT_DBG("type=%d, len=%d", skb->pkt_type, skb->len);
 
        if (!hdev || !hdev->driver_data) {
                BT_ERR("Frame for unknown HCI device");
-               BT_DBG("Leave");
                return -ENODEV;
        }
 
-       priv = (struct btmrvl_private *)hdev->driver_data;
+       priv = (struct btmrvl_private *) hdev->driver_data;
        if (!test_bit(HCI_RUNNING, &hdev->flags)) {
                BT_ERR("Failed testing HCI_RUNING, flags=%lx", hdev->flags);
                print_hex_dump_bytes("data: ", DUMP_PREFIX_OFFSET,
-                                       skb->data, skb->len);
-               BT_DBG("Leave");
+                                                       skb->data, skb->len);
                return -EBUSY;
        }
 
@@ -473,52 +420,34 @@ static int btmrvl_send_frame(struct sk_buff *skb)
 
        wake_up_interruptible(&priv->main_thread.wait_q);
 
-       BT_DBG("Leave");
-
        return 0;
 }
 
 static int btmrvl_flush(struct hci_dev *hdev)
 {
-       struct btmrvl_private *priv =
-                               (struct btmrvl_private *) hdev->driver_data;
-
-       BT_DBG("Enter");
+       struct btmrvl_private *priv = hdev->driver_data;
 
        skb_queue_purge(&priv->adapter->tx_queue);
 
-       BT_DBG("Leave");
-
        return 0;
 }
 
 static int btmrvl_close(struct hci_dev *hdev)
 {
-       struct btmrvl_private *priv =
-                               (struct btmrvl_private *) hdev->driver_data;
-
-       BT_DBG("Enter");
+       struct btmrvl_private *priv = hdev->driver_data;
 
-       if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) {
-               BT_DBG("Leave");
+       if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
                return 0;
-       }
 
        skb_queue_purge(&priv->adapter->tx_queue);
 
-       BT_DBG("Leave");
-
        return 0;
 }
 
 static int btmrvl_open(struct hci_dev *hdev)
 {
-       BT_DBG("Enter");
-
        set_bit(HCI_RUNNING, &hdev->flags);
 
-       BT_DBG("Leave");
-
        return 0;
 }
 
@@ -535,8 +464,6 @@ static int btmrvl_service_main_thread(void *data)
        struct sk_buff *skb;
        ulong flags;
 
-       BT_DBG("Enter");
-
        init_waitqueue_entry(&wait, current);
 
        current->flags |= PF_NOFREEZE;
@@ -547,9 +474,9 @@ static int btmrvl_service_main_thread(void *data)
                set_current_state(TASK_INTERRUPTIBLE);
 
                if (adapter->wakeup_tries ||
-                   ((!adapter->int_count) &&
-                    (!priv->btmrvl_dev.tx_dnld_rdy ||
-                     skb_queue_empty(&adapter->tx_queue)))) {
+                               ((!adapter->int_count) &&
+                               (!priv->btmrvl_dev.tx_dnld_rdy ||
+                               skb_queue_empty(&adapter->tx_queue)))) {
                        BT_DBG("main_thread is sleeping...");
                        schedule();
                }
@@ -568,8 +495,8 @@ static int btmrvl_service_main_thread(void *data)
                spin_lock_irqsave(&priv->driver_lock, flags);
                if (adapter->int_count) {
                        adapter->int_count = 0;
-               } else if ((adapter->ps_state == PS_SLEEP) &&
-                          !skb_queue_empty(&adapter->tx_queue)) {
+               } else if (adapter->ps_state == PS_SLEEP &&
+                                       !skb_queue_empty(&adapter->tx_queue)) {
                        spin_unlock_irqrestore(&priv->driver_lock, flags);
                        adapter->wakeup_tries++;
                        priv->hw_wakeup_firmware(priv);
@@ -588,62 +515,30 @@ static int btmrvl_service_main_thread(void *data)
                        if (btmrvl_tx_pkt(priv, skb))
                                priv->btmrvl_dev.hcidev->stat.err_tx++;
                        else
-                               priv->btmrvl_dev.hcidev->stat.byte_tx
-                                       += skb->len;
+                               priv->btmrvl_dev.hcidev->stat.byte_tx += skb->len;
 
                        kfree_skb(skb);
                }
        }
 
-       BT_DBG("Leave");
-
        return 0;
 }
 
-struct btmrvl_private *btmrvl_add_card(void *card)
+int btmrvl_register_hdev(struct btmrvl_private *priv)
 {
        struct hci_dev *hdev = NULL;
-       struct btmrvl_private *priv = NULL;
        int ret;
 
-       BT_DBG("Enter");
-
-       priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-       if (!priv) {
-               BT_ERR("Can not allocate priv");
-               goto err_priv;
-       }
-
-       priv->adapter = kzalloc(sizeof(*priv->adapter), GFP_KERNEL);
-       if (!priv->adapter) {
-               BT_ERR("Allocate buffer for btmrvl_adapter failed!");
-               goto err_adapter;
-       }
-
-       btmrvl_init_adapter(priv);
-
        hdev = hci_alloc_dev();
        if (!hdev) {
                BT_ERR("Can not allocate HCI device");
                goto err_hdev;
        }
 
-       BT_DBG("Starting kthread...");
-       priv->main_thread.priv = priv;
-       spin_lock_init(&priv->driver_lock);
-
-       init_waitqueue_head(&priv->main_thread.wait_q);
-       priv->main_thread.task = kthread_run(btmrvl_service_main_thread,
-               &priv->main_thread, "btmrvl_main_service");
-
        priv->btmrvl_dev.hcidev = hdev;
-       priv->btmrvl_dev.card = card;
-
        hdev->driver_data = priv;
 
-       priv->btmrvl_dev.tx_dnld_rdy = true;
-
-       hdev->type = HCI_SDIO;
+       hdev->bus = HCI_SDIO;
        hdev->open = btmrvl_open;
        hdev->close = btmrvl_close;
        hdev->flush = btmrvl_flush;
@@ -652,6 +547,8 @@ struct btmrvl_private *btmrvl_add_card(void *card)
        hdev->ioctl = btmrvl_ioctl;
        hdev->owner = THIS_MODULE;
 
+       btmrvl_send_module_cfg_cmd(priv, MODULE_BRINGUP_REQ);
+
        ret = hci_register_dev(hdev);
        if (ret < 0) {
                BT_ERR("Can not register HCI device");
@@ -662,24 +559,57 @@ struct btmrvl_private *btmrvl_add_card(void *card)
        btmrvl_debugfs_init(hdev);
 #endif
 
-       BT_DBG("Leave");
-       return priv;
+       return 0;
 
 err_hci_register_dev:
-       /* Stop the thread servicing the interrupts */
-       kthread_stop(priv->main_thread.task);
-
        hci_free_dev(hdev);
 
 err_hdev:
+       /* Stop the thread servicing the interrupts */
+       kthread_stop(priv->main_thread.task);
+
        btmrvl_free_adapter(priv);
+       kfree(priv);
+
+       return -ENOMEM;
+}
+EXPORT_SYMBOL_GPL(btmrvl_register_hdev);
+
+struct btmrvl_private *btmrvl_add_card(void *card)
+{
+       struct btmrvl_private *priv;
+
+       priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+       if (!priv) {
+               BT_ERR("Can not allocate priv");
+               goto err_priv;
+       }
+
+       priv->adapter = kzalloc(sizeof(*priv->adapter), GFP_KERNEL);
+       if (!priv->adapter) {
+               BT_ERR("Allocate buffer for btmrvl_adapter failed!");
+               goto err_adapter;
+       }
+
+       btmrvl_init_adapter(priv);
+
+       BT_DBG("Starting kthread...");
+       priv->main_thread.priv = priv;
+       spin_lock_init(&priv->driver_lock);
+
+       init_waitqueue_head(&priv->main_thread.wait_q);
+       priv->main_thread.task = kthread_run(btmrvl_service_main_thread,
+                               &priv->main_thread, "btmrvl_main_service");
+
+       priv->btmrvl_dev.card = card;
+       priv->btmrvl_dev.tx_dnld_rdy = true;
+
+       return priv;
 
 err_adapter:
        kfree(priv);
 
 err_priv:
-       BT_DBG("Leave");
-
        return NULL;
 }
 EXPORT_SYMBOL_GPL(btmrvl_add_card);
@@ -688,8 +618,6 @@ int btmrvl_remove_card(struct btmrvl_private *priv)
 {
        struct hci_dev *hdev;
 
-       BT_DBG("Enter");
-
        hdev = priv->btmrvl_dev.hcidev;
 
        wake_up_interruptible(&priv->adapter->cmd_wait_q);
@@ -710,13 +638,11 @@ int btmrvl_remove_card(struct btmrvl_private *priv)
 
        kfree(priv);
 
-       BT_DBG("Leave");
-
        return 0;
 }
 EXPORT_SYMBOL_GPL(btmrvl_remove_card);
 
 MODULE_AUTHOR("Marvell International Ltd.");
-MODULE_DESCRIPTION("Marvell Bluetooth Driver v" VERSION);
+MODULE_DESCRIPTION("Marvell Bluetooth driver ver " VERSION);
 MODULE_VERSION(VERSION);
 MODULE_LICENSE("GPL v2");