Skip to content
This repository was archived by the owner on Jun 18, 2024. It is now read-only.

Commit

Permalink
Bluetooth: Add suspend reason for device disconnect
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
apandit authored and holtmann committed Sep 13, 2020
1 parent 346ce5b commit f0cfc48
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/net/bluetooth/mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions net/bluetooth/mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f0cfc48

Please sign in to comment.