Return-Path: From: Dean Jenkins To: Marcel Holtmann CC: Dean Jenkins , "Gustavo F . Padovan" , Johan Hedberg , Subject: [PATCH V2 12/16] Bluetooth: hci_ldisc: hci_uart_tty_close() detach tty after last msg Date: Fri, 7 Apr 2017 18:04:34 +0100 Message-ID: <1491584678-27228-13-git-send-email-Dean_Jenkins@mentor.com> In-Reply-To: <1491584678-27228-1-git-send-email-Dean_Jenkins@mentor.com> References: <1491584678-27228-1-git-send-email-Dean_Jenkins@mentor.com> MIME-Version: 1.0 Content-Type: text/plain List-ID: hci_uart_tty_close() is detaching the tty prematurely which prevents the Data Link protocol layer from using the tty serial port in the call to hci_unregister_dev(). Consequently, when hci_unregister_dev() attempts to send a HCI RESET command, the BCSP layer attempts to retransmit the message many times and the command is timed-out after HCI_CMD_TIMEOUT (2) seconds. Nothing was physically transmitted because the tty was detached too early. Therefore, move the detach statement "tty->disc_data = NULL" to after hci_unregister_dev() so that the HCI RESET command maybe sent and acknowledged. Signed-off-by: Dean Jenkins --- drivers/bluetooth/hci_ldisc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index b2b6515..761282f 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c @@ -513,9 +513,6 @@ static void hci_uart_tty_close(struct tty_struct *tty) BT_DBG("tty %p", tty); - /* Detach from the tty */ - tty->disc_data = NULL; - if (!hu) return; @@ -539,6 +536,9 @@ static void hci_uart_tty_close(struct tty_struct *tty) hu->proto->close(hu); } + /* Detach from the tty */ + tty->disc_data = NULL; + clear_bit(HCI_UART_PROTO_SET, &hu->flags); if (test_and_clear_bit(HCI_UART_REGISTERED, &hu->flags)) { -- 2.7.4