diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2014-08-18 13:33:34 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-09-08 13:07:55 -0400 |
commit | 839035a7b3acd17a6f739b1fb50298e9499d3fa4 (patch) | |
tree | 44d3df18f391faee9becea55aea71d96cac4ea40 /net/bluetooth/hci_conn.c | |
parent | e3f2f92a047cd2be3c87a2aaf0a8958e1fd4c17a (diff) |
Bluetooth: Move clock offset reading into hci_disconnect()
To give all hci_disconnect() users the advantage of getting the clock
offset read automatically this patch moves the necessary code from
hci_conn_timeout() into hci_disconnect(). This way we pretty much always
update the clock offset when disconnecting.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/hci_conn.c')
-rw-r--r-- | net/bluetooth/hci_conn.c | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index dd2df20b0f7d..e3d7ae9e2edd 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c | |||
@@ -128,6 +128,19 @@ int hci_disconnect(struct hci_conn *conn, __u8 reason) | |||
128 | 128 | ||
129 | BT_DBG("hcon %p", conn); | 129 | BT_DBG("hcon %p", conn); |
130 | 130 | ||
131 | /* When we are master of an established connection and it enters | ||
132 | * the disconnect timeout, then go ahead and try to read the | ||
133 | * current clock offset. Processing of the result is done | ||
134 | * within the event handling and hci_clock_offset_evt function. | ||
135 | */ | ||
136 | if (conn->type == ACL_LINK && conn->role == HCI_ROLE_MASTER) { | ||
137 | struct hci_dev *hdev = conn->hdev; | ||
138 | struct hci_cp_read_clock_offset cp; | ||
139 | |||
140 | cp.handle = cpu_to_le16(conn->handle); | ||
141 | hci_send_cmd(hdev, HCI_OP_READ_CLOCK_OFFSET, sizeof(cp), &cp); | ||
142 | } | ||
143 | |||
131 | conn->state = BT_DISCONN; | 144 | conn->state = BT_DISCONN; |
132 | 145 | ||
133 | cp.handle = cpu_to_le16(conn->handle); | 146 | cp.handle = cpu_to_le16(conn->handle); |
@@ -325,25 +338,6 @@ static void hci_conn_timeout(struct work_struct *work) | |||
325 | hci_amp_disconn(conn); | 338 | hci_amp_disconn(conn); |
326 | } else { | 339 | } else { |
327 | __u8 reason = hci_proto_disconn_ind(conn); | 340 | __u8 reason = hci_proto_disconn_ind(conn); |
328 | |||
329 | /* When we are master of an established connection | ||
330 | * and it enters the disconnect timeout, then go | ||
331 | * ahead and try to read the current clock offset. | ||
332 | * | ||
333 | * Processing of the result is done within the | ||
334 | * event handling and hci_clock_offset_evt function. | ||
335 | */ | ||
336 | if (conn->type == ACL_LINK && | ||
337 | conn->role == HCI_ROLE_MASTER) { | ||
338 | struct hci_dev *hdev = conn->hdev; | ||
339 | struct hci_cp_read_clock_offset cp; | ||
340 | |||
341 | cp.handle = cpu_to_le16(conn->handle); | ||
342 | |||
343 | hci_send_cmd(hdev, HCI_OP_READ_CLOCK_OFFSET, | ||
344 | sizeof(cp), &cp); | ||
345 | } | ||
346 | |||
347 | hci_disconnect(conn, reason); | 341 | hci_disconnect(conn, reason); |
348 | } | 342 | } |
349 | break; | 343 | break; |