diff options
Diffstat (limited to 'net/bluetooth/hci_event.c')
-rw-r--r-- | net/bluetooth/hci_event.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index bfa9bcc0f5ef..48d730228c2f 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -29,6 +29,7 @@ | |||
29 | 29 | ||
30 | #include <net/bluetooth/bluetooth.h> | 30 | #include <net/bluetooth/bluetooth.h> |
31 | #include <net/bluetooth/hci_core.h> | 31 | #include <net/bluetooth/hci_core.h> |
32 | #include <net/bluetooth/mgmt.h> | ||
32 | 33 | ||
33 | /* Handle HCI Event packets */ | 34 | /* Handle HCI Event packets */ |
34 | 35 | ||
@@ -1875,6 +1876,22 @@ static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
1875 | } | 1876 | } |
1876 | } | 1877 | } |
1877 | 1878 | ||
1879 | static u8 hci_to_mgmt_reason(u8 err) | ||
1880 | { | ||
1881 | switch (err) { | ||
1882 | case HCI_ERROR_CONNECTION_TIMEOUT: | ||
1883 | return MGMT_DEV_DISCONN_TIMEOUT; | ||
1884 | case HCI_ERROR_REMOTE_USER_TERM: | ||
1885 | case HCI_ERROR_REMOTE_LOW_RESOURCES: | ||
1886 | case HCI_ERROR_REMOTE_POWER_OFF: | ||
1887 | return MGMT_DEV_DISCONN_REMOTE; | ||
1888 | case HCI_ERROR_LOCAL_HOST_TERM: | ||
1889 | return MGMT_DEV_DISCONN_LOCAL_HOST; | ||
1890 | default: | ||
1891 | return MGMT_DEV_DISCONN_UNKNOWN; | ||
1892 | } | ||
1893 | } | ||
1894 | |||
1878 | static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) | 1895 | static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) |
1879 | { | 1896 | { |
1880 | struct hci_ev_disconn_complete *ev = (void *) skb->data; | 1897 | struct hci_ev_disconn_complete *ev = (void *) skb->data; |
@@ -1893,12 +1910,15 @@ static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
1893 | 1910 | ||
1894 | if (test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags) && | 1911 | if (test_and_clear_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags) && |
1895 | (conn->type == ACL_LINK || conn->type == LE_LINK)) { | 1912 | (conn->type == ACL_LINK || conn->type == LE_LINK)) { |
1896 | if (ev->status) | 1913 | if (ev->status) { |
1897 | mgmt_disconnect_failed(hdev, &conn->dst, conn->type, | 1914 | mgmt_disconnect_failed(hdev, &conn->dst, conn->type, |
1898 | conn->dst_type, ev->status); | 1915 | conn->dst_type, ev->status); |
1899 | else | 1916 | } else { |
1917 | u8 reason = hci_to_mgmt_reason(ev->reason); | ||
1918 | |||
1900 | mgmt_device_disconnected(hdev, &conn->dst, conn->type, | 1919 | mgmt_device_disconnected(hdev, &conn->dst, conn->type, |
1901 | conn->dst_type); | 1920 | conn->dst_type, reason); |
1921 | } | ||
1902 | } | 1922 | } |
1903 | 1923 | ||
1904 | if (ev->status == 0) { | 1924 | if (ev->status == 0) { |