Bluetooth: Add suspend reason for device disconnect
authorAbhishek Pandit-Subedi <abhishekpandit@chromium.org>
Fri, 11 Sep 2020 21:07:12 +0000 (14:07 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Sun, 13 Sep 2020 07:54:28 +0000 (09:54 +0200)
Update device disconnect event with reason 0x5 to indicate that device
disconnected because the controller is suspending.

Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
include/net/bluetooth/mgmt.h
net/bluetooth/mgmt.c

index e19e33c7b65c342ae9dfa0aecf886845a387d29b..a4b8935e0db97a19f4cc06fd5a0158207861f929 100644 (file)
@@ -842,6 +842,7 @@ struct mgmt_ev_device_connected {
 #define MGMT_DEV_DISCONN_LOCAL_HOST    0x02
 #define MGMT_DEV_DISCONN_REMOTE                0x03
 #define MGMT_DEV_DISCONN_AUTH_FAILURE  0x04
+#define MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND    0x05
 
 #define MGMT_EV_DEVICE_DISCONNECTED    0x000C
 struct mgmt_ev_device_disconnected {
index db48ee3c213cbd278879409a2d1c5b83a03e6354..0b711ad80f6bd15400869ddca860a3f58d440818 100644 (file)
@@ -8270,6 +8270,10 @@ void mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr,
        ev.addr.type = link_to_bdaddr(link_type, addr_type);
        ev.reason = reason;
 
+       /* Report disconnects due to suspend */
+       if (hdev->suspended)
+               ev.reason = MGMT_DEV_DISCONN_LOCAL_HOST_SUSPEND;
+
        mgmt_event(MGMT_EV_DEVICE_DISCONNECTED, hdev, &ev, sizeof(ev), sk);
 
        if (sk)