btintel.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. *
  3. * Bluetooth support for Intel devices
  4. *
  5. * Copyright (C) 2015 Intel Corporation
  6. *
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. */
  23. #include <linux/module.h>
  24. #include <net/bluetooth/bluetooth.h>
  25. #include <net/bluetooth/hci_core.h>
  26. #include "btintel.h"
  27. #define VERSION "0.1"
  28. #define BDADDR_INTEL (&(bdaddr_t) {{0x00, 0x8b, 0x9e, 0x19, 0x03, 0x00}})
  29. int btintel_check_bdaddr(struct hci_dev *hdev)
  30. {
  31. struct hci_rp_read_bd_addr *bda;
  32. struct sk_buff *skb;
  33. skb = __hci_cmd_sync(hdev, HCI_OP_READ_BD_ADDR, 0, NULL,
  34. HCI_INIT_TIMEOUT);
  35. if (IS_ERR(skb)) {
  36. int err = PTR_ERR(skb);
  37. BT_ERR("%s: Reading Intel device address failed (%d)",
  38. hdev->name, err);
  39. return err;
  40. }
  41. if (skb->len != sizeof(*bda)) {
  42. BT_ERR("%s: Intel device address length mismatch", hdev->name);
  43. kfree_skb(skb);
  44. return -EIO;
  45. }
  46. bda = (struct hci_rp_read_bd_addr *)skb->data;
  47. /* For some Intel based controllers, the default Bluetooth device
  48. * address 00:03:19:9E:8B:00 can be found. These controllers are
  49. * fully operational, but have the danger of duplicate addresses
  50. * and that in turn can cause problems with Bluetooth operation.
  51. */
  52. if (!bacmp(&bda->bdaddr, BDADDR_INTEL)) {
  53. BT_ERR("%s: Found Intel default device address (%pMR)",
  54. hdev->name, &bda->bdaddr);
  55. set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks);
  56. }
  57. kfree_skb(skb);
  58. return 0;
  59. }
  60. EXPORT_SYMBOL_GPL(btintel_check_bdaddr);
  61. int btintel_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
  62. {
  63. struct sk_buff *skb;
  64. int err;
  65. skb = __hci_cmd_sync(hdev, 0xfc31, 6, bdaddr, HCI_INIT_TIMEOUT);
  66. if (IS_ERR(skb)) {
  67. err = PTR_ERR(skb);
  68. BT_ERR("%s: Changing Intel device address failed (%d)",
  69. hdev->name, err);
  70. return err;
  71. }
  72. kfree_skb(skb);
  73. return 0;
  74. }
  75. EXPORT_SYMBOL_GPL(btintel_set_bdaddr);
  76. MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
  77. MODULE_DESCRIPTION("Bluetooth support for Intel devices ver " VERSION);
  78. MODULE_VERSION(VERSION);
  79. MODULE_LICENSE("GPL");