Bluetooth: Send management event for class of device changes
authorMarcel Holtmann <marcel@holtmann.org>
Wed, 22 Feb 2012 17:38:01 +0000 (18:38 +0100)
committerJohan Hedberg <johan.hedberg@intel.com>
Thu, 23 Feb 2012 11:07:00 +0000 (13:07 +0200)
Currently there are no events to other management sockets if the class of
device got changed. So make sure they are sent.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
include/net/bluetooth/hci_core.h
net/bluetooth/hci_event.c
net/bluetooth/mgmt.c

index abdaa7900edbd974206bf9a85380d9eba5144b6a..24dd770d442b7ec40b16da087cf04cc83742192c 100644 (file)
@@ -1007,6 +1007,8 @@ int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
                                                u8 addr_type, u8 status);
 int mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status);
 int mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 enable, u8 status);
+int mgmt_set_class_of_dev_complete(struct hci_dev *hdev, u8 *dev_class,
+                                                               u8 status);
 int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status);
 int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash,
                                                u8 *randomizer, u8 status);
index e44e3fd68628faa16a8743d35e1d874f1e588fa1..c79ffb95555429f3207dd28a0e899ec18dfc7c6f 100644 (file)
@@ -350,14 +350,19 @@ static void hci_cc_write_class_of_dev(struct hci_dev *hdev, struct sk_buff *skb)
 
        BT_DBG("%s status 0x%x", hdev->name, status);
 
-       if (status)
-               return;
-
        sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_CLASS_OF_DEV);
        if (!sent)
                return;
 
-       memcpy(hdev->dev_class, sent, 3);
+       hci_dev_lock(hdev);
+
+       if (status == 0)
+               memcpy(hdev->dev_class, sent, 3);
+
+       if (test_bit(HCI_MGMT, &hdev->dev_flags))
+               mgmt_set_class_of_dev_complete(hdev, sent, status);
+
+       hci_dev_unlock(hdev);
 }
 
 static void hci_cc_read_voice_setting(struct hci_dev *hdev, struct sk_buff *skb)
index f7e111f30434dc41ab77907aadc6ed650c105d77..16bddd22713f1882bb75327a24101137a58532fb 100644 (file)
@@ -3546,6 +3546,16 @@ int mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 enable, u8 status)
        return err;
 }
 
+int mgmt_set_class_of_dev_complete(struct hci_dev *hdev, u8 *dev_class,
+                                                               u8 status)
+{
+       int err;
+
+       err = mgmt_event(MGMT_EV_CLASS_OF_DEV_CHANGED, hdev, dev_class, 3, NULL);
+
+       return err;
+}
+
 int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status)
 {
        struct pending_cmd *cmd;