diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2014-06-27 08:32:16 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-07-03 11:42:48 -0400 |
commit | df935429be40b02568d4bcf9ebfacf8011b85a85 (patch) | |
tree | fd6f43e7d52e9747de18add0558f3177ef8e1696 | |
parent | 40051e4686d6fa8743a38933727604f75bef05cf (diff) |
Bluetooth: Send HCI_Read_Clock_Offset before disconnecting
When the connection is in master role and it is going to be
disconnected based on the disconnection timeout, then send
the HCI_Read_Clock_Offset command in an attempt to update the
clock offset value in the inquiry cache.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
-rw-r--r-- | include/net/bluetooth/hci.h | 5 | ||||
-rw-r--r-- | net/bluetooth/hci_conn.c | 19 |
2 files changed, 24 insertions, 0 deletions
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index cc2e88dd20ea..6933766e7215 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h | |||
@@ -533,6 +533,11 @@ struct hci_cp_read_remote_version { | |||
533 | __le16 handle; | 533 | __le16 handle; |
534 | } __packed; | 534 | } __packed; |
535 | 535 | ||
536 | #define HCI_OP_READ_CLOCK_OFFSET 0x041f | ||
537 | struct hci_cp_read_clock_offset { | ||
538 | __le16 handle; | ||
539 | } __packed; | ||
540 | |||
536 | #define HCI_OP_SETUP_SYNC_CONN 0x0428 | 541 | #define HCI_OP_SETUP_SYNC_CONN 0x0428 |
537 | struct hci_cp_setup_sync_conn { | 542 | struct hci_cp_setup_sync_conn { |
538 | __le16 handle; | 543 | __le16 handle; |
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 6d0fe3df2fa5..8a0c7a0ac1b6 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c | |||
@@ -309,6 +309,25 @@ static void hci_conn_timeout(struct work_struct *work) | |||
309 | hci_amp_disconn(conn); | 309 | hci_amp_disconn(conn); |
310 | } else { | 310 | } else { |
311 | __u8 reason = hci_proto_disconn_ind(conn); | 311 | __u8 reason = hci_proto_disconn_ind(conn); |
312 | |||
313 | /* When we are master of an established connection | ||
314 | * and it enters the disconnect timeout, then go | ||
315 | * ahead and try to read the current clock offset. | ||
316 | * | ||
317 | * Processing of the result is done within the | ||
318 | * event handling and hci_clock_offset_evt function. | ||
319 | */ | ||
320 | if (conn->type == ACL_LINK && | ||
321 | test_bit(HCI_CONN_MASTER, &conn->flags)) { | ||
322 | struct hci_dev *hdev = conn->hdev; | ||
323 | struct hci_cp_read_clock_offset cp; | ||
324 | |||
325 | cp.handle = cpu_to_le16(conn->handle); | ||
326 | |||
327 | hci_send_cmd(hdev, HCI_OP_READ_CLOCK_OFFSET, | ||
328 | sizeof(cp), &cp); | ||
329 | } | ||
330 | |||
312 | hci_disconnect(conn, reason); | 331 | hci_disconnect(conn, reason); |
313 | } | 332 | } |
314 | break; | 333 | break; |