Skip to content

Commit 53502d6

Browse files
finikorgGustavo Padovan
authored andcommitted
Bluetooth: AMP: Handle AMP_LINK timeout
When AMP_LINK timeouts execute HCI_OP_DISCONN_PHY_LINK as analog to HCI_OP_DISCONNECT for ACL_LINK. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
1 parent 12d5978 commit 53502d6

2 files changed

Lines changed: 31 additions & 3 deletions

File tree

‎include/net/bluetooth/hci_core.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@ struct hci_dev {
285285
int (*ioctl)(struct hci_dev *hdev, unsigned int cmd, unsigned long arg);
286286
};
287287

288+
#define HCI_PHY_HANDLE(handle) (handle & 0xff)
289+
288290
struct hci_conn {
289291
struct list_head list;
290292

‎net/bluetooth/hci_conn.c‎

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,20 @@ void hci_acl_disconn(struct hci_conn *conn, __u8 reason)
130130
hci_send_cmd(conn->hdev, HCI_OP_DISCONNECT, sizeof(cp), &cp);
131131
}
132132

133+
static void hci_amp_disconn(struct hci_conn *conn, __u8 reason)
134+
{
135+
struct hci_cp_disconn_phy_link cp;
136+
137+
BT_DBG("hcon %p", conn);
138+
139+
conn->state = BT_DISCONN;
140+
141+
cp.phy_handle = HCI_PHY_HANDLE(conn->handle);
142+
cp.reason = reason;
143+
hci_send_cmd(conn->hdev, HCI_OP_DISCONN_PHY_LINK,
144+
sizeof(cp), &cp);
145+
}
146+
133147
static void hci_add_sco(struct hci_conn *conn, __u16 handle)
134148
{
135149
struct hci_dev *hdev = conn->hdev;
@@ -230,11 +244,24 @@ void hci_sco_setup(struct hci_conn *conn, __u8 status)
230244
}
231245
}
232246

247+
static void hci_conn_disconnect(struct hci_conn *conn)
248+
{
249+
__u8 reason = hci_proto_disconn_ind(conn);
250+
251+
switch (conn->type) {
252+
case ACL_LINK:
253+
hci_acl_disconn(conn, reason);
254+
break;
255+
case AMP_LINK:
256+
hci_amp_disconn(conn, reason);
257+
break;
258+
}
259+
}
260+
233261
static void hci_conn_timeout(struct work_struct *work)
234262
{
235263
struct hci_conn *conn = container_of(work, struct hci_conn,
236264
disc_work.work);
237-
__u8 reason;
238265

239266
BT_DBG("hcon %p state %s", conn, state_to_string(conn->state));
240267

@@ -253,8 +280,7 @@ static void hci_conn_timeout(struct work_struct *work)
253280
break;
254281
case BT_CONFIG:
255282
case BT_CONNECTED:
256-
reason = hci_proto_disconn_ind(conn);
257-
hci_acl_disconn(conn, reason);
283+
hci_conn_disconnect(conn);
258284
break;
259285
default:
260286
conn->state = BT_CLOSED;

0 commit comments

Comments
 (0)