Bluetooth: btmrvl: add public address configuration support
authorAmitkumar Karwar <akarwar@marvell.com>
Fri, 18 Jul 2014 21:47:07 +0000 (14:47 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Sat, 19 Jul 2014 00:33:21 +0000 (02:33 +0200)
.set_bdaddr handler is implemented for public address configuration.
A reboot restores the bdaddr to its original address.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
drivers/bluetooth/btmrvl_drv.h
drivers/bluetooth/btmrvl_main.c

index caf684119a4e38d5da089fcebf9289f0acb89c0d..38ad66289ad6206204138a31d4d4bda83a4297c9 100644 (file)
@@ -91,6 +91,7 @@ struct btmrvl_private {
 
 /* Vendor specific Bluetooth commands */
 #define BT_CMD_PSCAN_WIN_REPORT_ENABLE 0xFC03
+#define BT_CMD_SET_BDADDR              0xFC22
 #define BT_CMD_AUTO_SLEEP_MODE         0xFC23
 #define BT_CMD_HOST_SLEEP_CONFIG       0xFC59
 #define BT_CMD_HOST_SLEEP_ENABLE       0xFC5A
index cc65fd2fe856cb992b81da7c9f45e3f509757a54..bae8e6a0ecf684b64d71d42b730ba96c58da327c 100644 (file)
@@ -539,6 +539,29 @@ static int btmrvl_setup(struct hci_dev *hdev)
        return 0;
 }
 
+static int btmrvl_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
+{
+       struct sk_buff *skb;
+       long ret;
+       u8 buf[8];
+
+       buf[0] = MRVL_VENDOR_PKT;
+       buf[1] = sizeof(bdaddr_t);
+       memcpy(buf + 2, bdaddr, sizeof(bdaddr_t));
+
+       skb = __hci_cmd_sync(hdev, BT_CMD_SET_BDADDR, sizeof(buf), buf,
+                            HCI_INIT_TIMEOUT);
+       if (IS_ERR(skb)) {
+               ret = PTR_ERR(skb);
+               BT_ERR("%s: changing btmrvl device address failed (%ld)",
+                      hdev->name, ret);
+               return ret;
+       }
+       kfree_skb(skb);
+
+       return 0;
+}
+
 /*
  * This function handles the event generated by firmware, rx data
  * received from firmware, and tx data sent from kernel.
@@ -632,6 +655,7 @@ int btmrvl_register_hdev(struct btmrvl_private *priv)
        hdev->flush = btmrvl_flush;
        hdev->send  = btmrvl_send_frame;
        hdev->setup = btmrvl_setup;
+       hdev->set_bdaddr = btmrvl_set_bdaddr;
 
        hdev->dev_type = priv->btmrvl_dev.dev_type;