Bluetooth: Fix Class of Device indication when powering off
authorJohan Hedberg <johan.hedberg@intel.com>
Wed, 16 Jan 2013 14:15:34 +0000 (16:15 +0200)
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>
Wed, 23 Jan 2013 03:41:23 +0000 (01:41 -0200)
When a HCI device is powered off the Management interface specification
dictates that the class of device value is indicated as zero. This patch
fixes sending of the appropriate class of device changed event when a
HCI device is powered off.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
net/bluetooth/mgmt.c

index fc171f222ba45859544ca8e0cfd8b064b262b5cd..54f3ddba9139bf214776f268476f8b8f3a12137a 100644 (file)
@@ -2987,7 +2987,13 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered)
                }
        } else {
                u8 status = MGMT_STATUS_NOT_POWERED;
+               u8 zero_cod[] = { 0, 0, 0 };
+
                mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status);
+
+               if (memcmp(hdev->dev_class, zero_cod, sizeof(zero_cod)) != 0)
+                       mgmt_event(MGMT_EV_CLASS_OF_DEV_CHANGED, hdev,
+                                  zero_cod, sizeof(zero_cod), NULL);
        }
 
        err = new_settings(hdev, match.sk);