btmrvl_main.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. /**
  2. * Marvell Bluetooth driver
  3. *
  4. * Copyright (C) 2009, Marvell International Ltd.
  5. *
  6. * This software file (the "File") is distributed by Marvell International
  7. * Ltd. under the terms of the GNU General Public License Version 2, June 1991
  8. * (the "License"). You may use, redistribute and/or modify this File in
  9. * accordance with the terms and conditions of the License, a copy of which
  10. * is available by writing to the Free Software Foundation, Inc.,
  11. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
  12. * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
  13. *
  14. *
  15. * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
  16. * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
  17. * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
  18. * this warranty disclaimer.
  19. **/
  20. #include <net/bluetooth/bluetooth.h>
  21. #include <net/bluetooth/hci_core.h>
  22. #include "btmrvl_drv.h"
  23. #define VERSION "1.0"
  24. /*
  25. * This function is called by interface specific interrupt handler.
  26. * It updates Power Save & Host Sleep states, and wakes up the main
  27. * thread.
  28. */
  29. void btmrvl_interrupt(struct btmrvl_private *priv)
  30. {
  31. priv->adapter->ps_state = PS_AWAKE;
  32. priv->adapter->wakeup_tries = 0;
  33. priv->adapter->int_count++;
  34. wake_up_interruptible(&priv->main_thread.wait_q);
  35. }
  36. EXPORT_SYMBOL_GPL(btmrvl_interrupt);
  37. void btmrvl_check_evtpkt(struct btmrvl_private *priv, struct sk_buff *skb)
  38. {
  39. struct hci_event_hdr *hdr = (void *) skb->data;
  40. struct hci_ev_cmd_complete *ec;
  41. u16 opcode, ocf;
  42. if (hdr->evt == HCI_EV_CMD_COMPLETE) {
  43. ec = (void *) (skb->data + HCI_EVENT_HDR_SIZE);
  44. opcode = __le16_to_cpu(ec->opcode);
  45. ocf = hci_opcode_ocf(opcode);
  46. if (ocf == BT_CMD_MODULE_CFG_REQ &&
  47. priv->btmrvl_dev.sendcmdflag) {
  48. priv->btmrvl_dev.sendcmdflag = false;
  49. priv->adapter->cmd_complete = true;
  50. wake_up_interruptible(&priv->adapter->cmd_wait_q);
  51. }
  52. }
  53. }
  54. EXPORT_SYMBOL_GPL(btmrvl_check_evtpkt);
  55. int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb)
  56. {
  57. struct btmrvl_adapter *adapter = priv->adapter;
  58. struct btmrvl_event *event;
  59. int ret = 0;
  60. event = (struct btmrvl_event *) skb->data;
  61. if (event->ec != 0xff) {
  62. BT_DBG("Not Marvell Event=%x", event->ec);
  63. ret = -EINVAL;
  64. goto exit;
  65. }
  66. switch (event->data[0]) {
  67. case BT_CMD_AUTO_SLEEP_MODE:
  68. if (!event->data[2]) {
  69. if (event->data[1] == BT_PS_ENABLE)
  70. adapter->psmode = 1;
  71. else
  72. adapter->psmode = 0;
  73. BT_DBG("PS Mode:%s",
  74. (adapter->psmode) ? "Enable" : "Disable");
  75. } else {
  76. BT_DBG("PS Mode command failed");
  77. }
  78. break;
  79. case BT_CMD_HOST_SLEEP_CONFIG:
  80. if (!event->data[3])
  81. BT_DBG("gpio=%x, gap=%x", event->data[1],
  82. event->data[2]);
  83. else
  84. BT_DBG("HSCFG command failed");
  85. break;
  86. case BT_CMD_HOST_SLEEP_ENABLE:
  87. if (!event->data[1]) {
  88. adapter->hs_state = HS_ACTIVATED;
  89. if (adapter->psmode)
  90. adapter->ps_state = PS_SLEEP;
  91. wake_up_interruptible(&adapter->cmd_wait_q);
  92. BT_DBG("HS ACTIVATED!");
  93. } else {
  94. BT_DBG("HS Enable failed");
  95. }
  96. break;
  97. case BT_CMD_MODULE_CFG_REQ:
  98. if (priv->btmrvl_dev.sendcmdflag &&
  99. event->data[1] == MODULE_BRINGUP_REQ) {
  100. BT_DBG("EVENT:%s",
  101. ((event->data[2] == MODULE_BROUGHT_UP) ||
  102. (event->data[2] == MODULE_ALREADY_UP)) ?
  103. "Bring-up succeed" : "Bring-up failed");
  104. if (event->length > 3 && event->data[3])
  105. priv->btmrvl_dev.dev_type = HCI_AMP;
  106. else
  107. priv->btmrvl_dev.dev_type = HCI_BREDR;
  108. BT_DBG("dev_type: %d", priv->btmrvl_dev.dev_type);
  109. } else if (priv->btmrvl_dev.sendcmdflag &&
  110. event->data[1] == MODULE_SHUTDOWN_REQ) {
  111. BT_DBG("EVENT:%s", (event->data[2]) ?
  112. "Shutdown failed" : "Shutdown succeed");
  113. } else {
  114. BT_DBG("BT_CMD_MODULE_CFG_REQ resp for APP");
  115. ret = -EINVAL;
  116. }
  117. break;
  118. case BT_EVENT_POWER_STATE:
  119. if (event->data[1] == BT_PS_SLEEP)
  120. adapter->ps_state = PS_SLEEP;
  121. BT_DBG("EVENT:%s",
  122. (adapter->ps_state) ? "PS_SLEEP" : "PS_AWAKE");
  123. break;
  124. default:
  125. BT_DBG("Unknown Event=%d", event->data[0]);
  126. ret = -EINVAL;
  127. break;
  128. }
  129. exit:
  130. if (!ret)
  131. kfree_skb(skb);
  132. return ret;
  133. }
  134. EXPORT_SYMBOL_GPL(btmrvl_process_event);
  135. int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd)
  136. {
  137. struct sk_buff *skb;
  138. struct btmrvl_cmd *cmd;
  139. int ret = 0;
  140. skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
  141. if (skb == NULL) {
  142. BT_ERR("No free skb");
  143. return -ENOMEM;
  144. }
  145. cmd = (struct btmrvl_cmd *) skb_put(skb, sizeof(*cmd));
  146. cmd->ocf_ogf = cpu_to_le16(hci_opcode_pack(OGF, BT_CMD_MODULE_CFG_REQ));
  147. cmd->length = 1;
  148. cmd->data[0] = subcmd;
  149. bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT;
  150. skb->dev = (void *) priv->btmrvl_dev.hcidev;
  151. skb_queue_head(&priv->adapter->tx_queue, skb);
  152. priv->btmrvl_dev.sendcmdflag = true;
  153. priv->adapter->cmd_complete = false;
  154. BT_DBG("Queue module cfg Command");
  155. wake_up_interruptible(&priv->main_thread.wait_q);
  156. if (!wait_event_interruptible_timeout(priv->adapter->cmd_wait_q,
  157. priv->adapter->cmd_complete,
  158. msecs_to_jiffies(WAIT_UNTIL_CMD_RESP))) {
  159. ret = -ETIMEDOUT;
  160. BT_ERR("module_cfg_cmd(%x): timeout: %d",
  161. subcmd, priv->btmrvl_dev.sendcmdflag);
  162. }
  163. BT_DBG("module cfg Command done");
  164. return ret;
  165. }
  166. EXPORT_SYMBOL_GPL(btmrvl_send_module_cfg_cmd);
  167. int btmrvl_enable_ps(struct btmrvl_private *priv)
  168. {
  169. struct sk_buff *skb;
  170. struct btmrvl_cmd *cmd;
  171. skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
  172. if (skb == NULL) {
  173. BT_ERR("No free skb");
  174. return -ENOMEM;
  175. }
  176. cmd = (struct btmrvl_cmd *) skb_put(skb, sizeof(*cmd));
  177. cmd->ocf_ogf = cpu_to_le16(hci_opcode_pack(OGF,
  178. BT_CMD_AUTO_SLEEP_MODE));
  179. cmd->length = 1;
  180. if (priv->btmrvl_dev.psmode)
  181. cmd->data[0] = BT_PS_ENABLE;
  182. else
  183. cmd->data[0] = BT_PS_DISABLE;
  184. bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT;
  185. skb->dev = (void *) priv->btmrvl_dev.hcidev;
  186. skb_queue_head(&priv->adapter->tx_queue, skb);
  187. BT_DBG("Queue PSMODE Command:%d", cmd->data[0]);
  188. return 0;
  189. }
  190. EXPORT_SYMBOL_GPL(btmrvl_enable_ps);
  191. static int btmrvl_enable_hs(struct btmrvl_private *priv)
  192. {
  193. struct sk_buff *skb;
  194. struct btmrvl_cmd *cmd;
  195. int ret = 0;
  196. skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
  197. if (skb == NULL) {
  198. BT_ERR("No free skb");
  199. return -ENOMEM;
  200. }
  201. cmd = (struct btmrvl_cmd *) skb_put(skb, sizeof(*cmd));
  202. cmd->ocf_ogf = cpu_to_le16(hci_opcode_pack(OGF, BT_CMD_HOST_SLEEP_ENABLE));
  203. cmd->length = 0;
  204. bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT;
  205. skb->dev = (void *) priv->btmrvl_dev.hcidev;
  206. skb_queue_head(&priv->adapter->tx_queue, skb);
  207. BT_DBG("Queue hs enable Command");
  208. wake_up_interruptible(&priv->main_thread.wait_q);
  209. if (!wait_event_interruptible_timeout(priv->adapter->cmd_wait_q,
  210. priv->adapter->hs_state,
  211. msecs_to_jiffies(WAIT_UNTIL_HS_STATE_CHANGED))) {
  212. ret = -ETIMEDOUT;
  213. BT_ERR("timeout: %d, %d,%d", priv->adapter->hs_state,
  214. priv->adapter->ps_state,
  215. priv->adapter->wakeup_tries);
  216. }
  217. return ret;
  218. }
  219. int btmrvl_prepare_command(struct btmrvl_private *priv)
  220. {
  221. struct sk_buff *skb = NULL;
  222. struct btmrvl_cmd *cmd;
  223. int ret = 0;
  224. if (priv->btmrvl_dev.hscfgcmd) {
  225. priv->btmrvl_dev.hscfgcmd = 0;
  226. skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
  227. if (skb == NULL) {
  228. BT_ERR("No free skb");
  229. return -ENOMEM;
  230. }
  231. cmd = (struct btmrvl_cmd *) skb_put(skb, sizeof(*cmd));
  232. cmd->ocf_ogf = cpu_to_le16(hci_opcode_pack(OGF, BT_CMD_HOST_SLEEP_CONFIG));
  233. cmd->length = 2;
  234. cmd->data[0] = (priv->btmrvl_dev.gpio_gap & 0xff00) >> 8;
  235. cmd->data[1] = (u8) (priv->btmrvl_dev.gpio_gap & 0x00ff);
  236. bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT;
  237. skb->dev = (void *) priv->btmrvl_dev.hcidev;
  238. skb_queue_head(&priv->adapter->tx_queue, skb);
  239. BT_DBG("Queue HSCFG Command, gpio=0x%x, gap=0x%x",
  240. cmd->data[0], cmd->data[1]);
  241. }
  242. if (priv->btmrvl_dev.pscmd) {
  243. priv->btmrvl_dev.pscmd = 0;
  244. btmrvl_enable_ps(priv);
  245. }
  246. if (priv->btmrvl_dev.hscmd) {
  247. priv->btmrvl_dev.hscmd = 0;
  248. if (priv->btmrvl_dev.hsmode) {
  249. ret = btmrvl_enable_hs(priv);
  250. } else {
  251. ret = priv->hw_wakeup_firmware(priv);
  252. priv->adapter->hs_state = HS_DEACTIVATED;
  253. }
  254. }
  255. return ret;
  256. }
  257. static int btmrvl_tx_pkt(struct btmrvl_private *priv, struct sk_buff *skb)
  258. {
  259. int ret = 0;
  260. if (!skb || !skb->data)
  261. return -EINVAL;
  262. if (!skb->len || ((skb->len + BTM_HEADER_LEN) > BTM_UPLD_SIZE)) {
  263. BT_ERR("Tx Error: Bad skb length %d : %d",
  264. skb->len, BTM_UPLD_SIZE);
  265. return -EINVAL;
  266. }
  267. if (skb_headroom(skb) < BTM_HEADER_LEN) {
  268. struct sk_buff *tmp = skb;
  269. skb = skb_realloc_headroom(skb, BTM_HEADER_LEN);
  270. if (!skb) {
  271. BT_ERR("Tx Error: realloc_headroom failed %d",
  272. BTM_HEADER_LEN);
  273. skb = tmp;
  274. return -EINVAL;
  275. }
  276. kfree_skb(tmp);
  277. }
  278. skb_push(skb, BTM_HEADER_LEN);
  279. /* header type: byte[3]
  280. * HCI_COMMAND = 1, ACL_DATA = 2, SCO_DATA = 3, 0xFE = Vendor
  281. * header length: byte[2][1][0]
  282. */
  283. skb->data[0] = (skb->len & 0x0000ff);
  284. skb->data[1] = (skb->len & 0x00ff00) >> 8;
  285. skb->data[2] = (skb->len & 0xff0000) >> 16;
  286. skb->data[3] = bt_cb(skb)->pkt_type;
  287. if (priv->hw_host_to_card)
  288. ret = priv->hw_host_to_card(priv, skb->data, skb->len);
  289. return ret;
  290. }
  291. static void btmrvl_init_adapter(struct btmrvl_private *priv)
  292. {
  293. skb_queue_head_init(&priv->adapter->tx_queue);
  294. priv->adapter->ps_state = PS_AWAKE;
  295. init_waitqueue_head(&priv->adapter->cmd_wait_q);
  296. }
  297. static void btmrvl_free_adapter(struct btmrvl_private *priv)
  298. {
  299. skb_queue_purge(&priv->adapter->tx_queue);
  300. kfree(priv->adapter);
  301. priv->adapter = NULL;
  302. }
  303. static int btmrvl_ioctl(struct hci_dev *hdev,
  304. unsigned int cmd, unsigned long arg)
  305. {
  306. return -ENOIOCTLCMD;
  307. }
  308. static void btmrvl_destruct(struct hci_dev *hdev)
  309. {
  310. }
  311. static int btmrvl_send_frame(struct sk_buff *skb)
  312. {
  313. struct hci_dev *hdev = (struct hci_dev *) skb->dev;
  314. struct btmrvl_private *priv = NULL;
  315. BT_DBG("type=%d, len=%d", skb->pkt_type, skb->len);
  316. if (!hdev || !hdev->driver_data) {
  317. BT_ERR("Frame for unknown HCI device");
  318. return -ENODEV;
  319. }
  320. priv = (struct btmrvl_private *) hdev->driver_data;
  321. if (!test_bit(HCI_RUNNING, &hdev->flags)) {
  322. BT_ERR("Failed testing HCI_RUNING, flags=%lx", hdev->flags);
  323. print_hex_dump_bytes("data: ", DUMP_PREFIX_OFFSET,
  324. skb->data, skb->len);
  325. return -EBUSY;
  326. }
  327. switch (bt_cb(skb)->pkt_type) {
  328. case HCI_COMMAND_PKT:
  329. hdev->stat.cmd_tx++;
  330. break;
  331. case HCI_ACLDATA_PKT:
  332. hdev->stat.acl_tx++;
  333. break;
  334. case HCI_SCODATA_PKT:
  335. hdev->stat.sco_tx++;
  336. break;
  337. }
  338. skb_queue_tail(&priv->adapter->tx_queue, skb);
  339. wake_up_interruptible(&priv->main_thread.wait_q);
  340. return 0;
  341. }
  342. static int btmrvl_flush(struct hci_dev *hdev)
  343. {
  344. struct btmrvl_private *priv = hdev->driver_data;
  345. skb_queue_purge(&priv->adapter->tx_queue);
  346. return 0;
  347. }
  348. static int btmrvl_close(struct hci_dev *hdev)
  349. {
  350. struct btmrvl_private *priv = hdev->driver_data;
  351. if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
  352. return 0;
  353. skb_queue_purge(&priv->adapter->tx_queue);
  354. return 0;
  355. }
  356. static int btmrvl_open(struct hci_dev *hdev)
  357. {
  358. set_bit(HCI_RUNNING, &hdev->flags);
  359. return 0;
  360. }
  361. /*
  362. * This function handles the event generated by firmware, rx data
  363. * received from firmware, and tx data sent from kernel.
  364. */
  365. static int btmrvl_service_main_thread(void *data)
  366. {
  367. struct btmrvl_thread *thread = data;
  368. struct btmrvl_private *priv = thread->priv;
  369. struct btmrvl_adapter *adapter = priv->adapter;
  370. wait_queue_t wait;
  371. struct sk_buff *skb;
  372. ulong flags;
  373. init_waitqueue_entry(&wait, current);
  374. current->flags |= PF_NOFREEZE;
  375. for (;;) {
  376. add_wait_queue(&thread->wait_q, &wait);
  377. set_current_state(TASK_INTERRUPTIBLE);
  378. if (adapter->wakeup_tries ||
  379. ((!adapter->int_count) &&
  380. (!priv->btmrvl_dev.tx_dnld_rdy ||
  381. skb_queue_empty(&adapter->tx_queue)))) {
  382. BT_DBG("main_thread is sleeping...");
  383. schedule();
  384. }
  385. set_current_state(TASK_RUNNING);
  386. remove_wait_queue(&thread->wait_q, &wait);
  387. BT_DBG("main_thread woke up");
  388. if (kthread_should_stop()) {
  389. BT_DBG("main_thread: break from main thread");
  390. break;
  391. }
  392. spin_lock_irqsave(&priv->driver_lock, flags);
  393. if (adapter->int_count) {
  394. adapter->int_count = 0;
  395. spin_unlock_irqrestore(&priv->driver_lock, flags);
  396. priv->hw_process_int_status(priv);
  397. } else if (adapter->ps_state == PS_SLEEP &&
  398. !skb_queue_empty(&adapter->tx_queue)) {
  399. spin_unlock_irqrestore(&priv->driver_lock, flags);
  400. adapter->wakeup_tries++;
  401. priv->hw_wakeup_firmware(priv);
  402. continue;
  403. } else {
  404. spin_unlock_irqrestore(&priv->driver_lock, flags);
  405. }
  406. if (adapter->ps_state == PS_SLEEP)
  407. continue;
  408. if (!priv->btmrvl_dev.tx_dnld_rdy)
  409. continue;
  410. skb = skb_dequeue(&adapter->tx_queue);
  411. if (skb) {
  412. if (btmrvl_tx_pkt(priv, skb))
  413. priv->btmrvl_dev.hcidev->stat.err_tx++;
  414. else
  415. priv->btmrvl_dev.hcidev->stat.byte_tx += skb->len;
  416. kfree_skb(skb);
  417. }
  418. }
  419. return 0;
  420. }
  421. int btmrvl_register_hdev(struct btmrvl_private *priv)
  422. {
  423. struct hci_dev *hdev = NULL;
  424. int ret;
  425. hdev = hci_alloc_dev();
  426. if (!hdev) {
  427. BT_ERR("Can not allocate HCI device");
  428. goto err_hdev;
  429. }
  430. priv->btmrvl_dev.hcidev = hdev;
  431. hdev->driver_data = priv;
  432. hdev->bus = HCI_SDIO;
  433. hdev->open = btmrvl_open;
  434. hdev->close = btmrvl_close;
  435. hdev->flush = btmrvl_flush;
  436. hdev->send = btmrvl_send_frame;
  437. hdev->destruct = btmrvl_destruct;
  438. hdev->ioctl = btmrvl_ioctl;
  439. hdev->owner = THIS_MODULE;
  440. btmrvl_send_module_cfg_cmd(priv, MODULE_BRINGUP_REQ);
  441. hdev->dev_type = priv->btmrvl_dev.dev_type;
  442. ret = hci_register_dev(hdev);
  443. if (ret < 0) {
  444. BT_ERR("Can not register HCI device");
  445. goto err_hci_register_dev;
  446. }
  447. #ifdef CONFIG_DEBUG_FS
  448. btmrvl_debugfs_init(hdev);
  449. #endif
  450. return 0;
  451. err_hci_register_dev:
  452. hci_free_dev(hdev);
  453. err_hdev:
  454. /* Stop the thread servicing the interrupts */
  455. kthread_stop(priv->main_thread.task);
  456. btmrvl_free_adapter(priv);
  457. kfree(priv);
  458. return -ENOMEM;
  459. }
  460. EXPORT_SYMBOL_GPL(btmrvl_register_hdev);
  461. struct btmrvl_private *btmrvl_add_card(void *card)
  462. {
  463. struct btmrvl_private *priv;
  464. priv = kzalloc(sizeof(*priv), GFP_KERNEL);
  465. if (!priv) {
  466. BT_ERR("Can not allocate priv");
  467. goto err_priv;
  468. }
  469. priv->adapter = kzalloc(sizeof(*priv->adapter), GFP_KERNEL);
  470. if (!priv->adapter) {
  471. BT_ERR("Allocate buffer for btmrvl_adapter failed!");
  472. goto err_adapter;
  473. }
  474. btmrvl_init_adapter(priv);
  475. BT_DBG("Starting kthread...");
  476. priv->main_thread.priv = priv;
  477. spin_lock_init(&priv->driver_lock);
  478. init_waitqueue_head(&priv->main_thread.wait_q);
  479. priv->main_thread.task = kthread_run(btmrvl_service_main_thread,
  480. &priv->main_thread, "btmrvl_main_service");
  481. priv->btmrvl_dev.card = card;
  482. priv->btmrvl_dev.tx_dnld_rdy = true;
  483. return priv;
  484. err_adapter:
  485. kfree(priv);
  486. err_priv:
  487. return NULL;
  488. }
  489. EXPORT_SYMBOL_GPL(btmrvl_add_card);
  490. int btmrvl_remove_card(struct btmrvl_private *priv)
  491. {
  492. struct hci_dev *hdev;
  493. hdev = priv->btmrvl_dev.hcidev;
  494. wake_up_interruptible(&priv->adapter->cmd_wait_q);
  495. kthread_stop(priv->main_thread.task);
  496. #ifdef CONFIG_DEBUG_FS
  497. btmrvl_debugfs_remove(hdev);
  498. #endif
  499. hci_unregister_dev(hdev);
  500. hci_free_dev(hdev);
  501. priv->btmrvl_dev.hcidev = NULL;
  502. btmrvl_free_adapter(priv);
  503. kfree(priv);
  504. return 0;
  505. }
  506. EXPORT_SYMBOL_GPL(btmrvl_remove_card);
  507. MODULE_AUTHOR("Marvell International Ltd.");
  508. MODULE_DESCRIPTION("Marvell Bluetooth driver ver " VERSION);
  509. MODULE_VERSION(VERSION);
  510. MODULE_LICENSE("GPL v2");