Merge "Bluetooth: Update Local COD to bluez userspace on write complete." into msm-3.4
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index ac85423..b773553 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -418,6 +418,7 @@
static int update_class(struct hci_dev *hdev)
{
u8 cod[3];
+ int err = 0;
BT_DBG("%s", hdev->name);
@@ -431,7 +432,12 @@
if (memcmp(cod, hdev->dev_class, 3) == 0)
return 0;
- return hci_send_cmd(hdev, HCI_OP_WRITE_CLASS_OF_DEV, sizeof(cod), cod);
+ err = hci_send_cmd(hdev, HCI_OP_WRITE_CLASS_OF_DEV, sizeof(cod), cod);
+
+ if (err == 0)
+ memcpy(hdev->dev_class, cod, 3);
+
+ return err;
}
static int set_limited_discoverable(struct sock *sk, u16 index,
@@ -1000,12 +1006,12 @@
hdev->major_class |= cp->major & MGMT_MAJOR_CLASS_MASK;
hdev->minor_class = cp->minor;
- if (test_bit(HCI_UP, &hdev->flags))
+ if (test_bit(HCI_UP, &hdev->flags)) {
err = update_class(hdev);
- else
- err = 0;
-
- if (err == 0)
+ if (err == 0)
+ err = cmd_complete(sk, index,
+ MGMT_OP_SET_DEV_CLASS, hdev->dev_class, sizeof(u8)*3);
+ } else
err = cmd_complete(sk, index, MGMT_OP_SET_DEV_CLASS, NULL, 0);
hci_dev_unlock_bh(hdev);