Bluetooth: Make hci_disconnect() behave correctly for all states
There are a few places that don't explicitly check the connection state before calling hci_disconnect(). To make this API do the right thing take advantage of the new hci_abort_conn() API and also make sure to only read the clock offset if we're really connected. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
parent
89e0ccc882
commit
88d07feb09
|
@ -226,8 +226,6 @@ static void hci_acl_create_connection(struct hci_conn *conn)
|
||||||
|
|
||||||
int hci_disconnect(struct hci_conn *conn, __u8 reason)
|
int hci_disconnect(struct hci_conn *conn, __u8 reason)
|
||||||
{
|
{
|
||||||
struct hci_cp_disconnect cp;
|
|
||||||
|
|
||||||
BT_DBG("hcon %p", conn);
|
BT_DBG("hcon %p", conn);
|
||||||
|
|
||||||
/* When we are master of an established connection and it enters
|
/* When we are master of an established connection and it enters
|
||||||
|
@ -235,7 +233,8 @@ int hci_disconnect(struct hci_conn *conn, __u8 reason)
|
||||||
* current clock offset. Processing of the result is done
|
* current clock offset. Processing of the result is done
|
||||||
* within the event handling and hci_clock_offset_evt function.
|
* within the event handling and hci_clock_offset_evt function.
|
||||||
*/
|
*/
|
||||||
if (conn->type == ACL_LINK && conn->role == HCI_ROLE_MASTER) {
|
if (conn->type == ACL_LINK && conn->role == HCI_ROLE_MASTER &&
|
||||||
|
(conn->state == BT_CONNECTED || conn->state == BT_CONFIG)) {
|
||||||
struct hci_dev *hdev = conn->hdev;
|
struct hci_dev *hdev = conn->hdev;
|
||||||
struct hci_cp_read_clock_offset clkoff_cp;
|
struct hci_cp_read_clock_offset clkoff_cp;
|
||||||
|
|
||||||
|
@ -244,11 +243,7 @@ int hci_disconnect(struct hci_conn *conn, __u8 reason)
|
||||||
&clkoff_cp);
|
&clkoff_cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
conn->state = BT_DISCONN;
|
return hci_abort_conn(conn, reason);
|
||||||
|
|
||||||
cp.handle = cpu_to_le16(conn->handle);
|
|
||||||
cp.reason = reason;
|
|
||||||
return hci_send_cmd(conn->hdev, HCI_OP_DISCONNECT, sizeof(cp), &cp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hci_add_sco(struct hci_conn *conn, __u16 handle)
|
static void hci_add_sco(struct hci_conn *conn, __u16 handle)
|
||||||
|
|
Loading…
Reference in New Issue