]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
Bluetooth: hci_ldisc: Add function to wait for characters to be sent
authorSascha Hauer <s.hauer@pengutronix.de>
Fri, 14 Jun 2019 07:23:49 +0000 (09:23 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Sat, 6 Jul 2019 10:53:56 +0000 (12:53 +0200)
The hci UART line discipline sends its characters in a workqueue. Some
devices like the Marvell Bluetooth chips need to make sure that all
queued characters are sent before switching the baudrate. This adds
a function to synchronize with the workqueue.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
drivers/bluetooth/hci_ldisc.c
drivers/bluetooth/hci_uart.h

index c84f985f348dcb5baae982f362d46de070860ac1..8950e07889fef64c75103d68e27688a54b995c85 100644 (file)
@@ -178,6 +178,7 @@ static void hci_uart_write_work(struct work_struct *work)
                goto restart;
 
        clear_bit(HCI_UART_SENDING, &hu->tx_state);
+       wake_up_bit(&hu->tx_state, HCI_UART_SENDING);
 }
 
 void hci_uart_init_work(struct work_struct *work)
@@ -213,6 +214,13 @@ int hci_uart_init_ready(struct hci_uart *hu)
        return 0;
 }
 
+int hci_uart_wait_until_sent(struct hci_uart *hu)
+{
+       return wait_on_bit_timeout(&hu->tx_state, HCI_UART_SENDING,
+                                  TASK_INTERRUPTIBLE,
+                                  msecs_to_jiffies(2000));
+}
+
 /* ------- Interface to HCI layer ------ */
 /* Reset device */
 static int hci_uart_flush(struct hci_dev *hdev)
index d8cf005e3c5deeae0bfc5f7246a02d88526cd5e5..f11af3912ce6c16fd92720e8dccd53d5f3933589 100644 (file)
@@ -100,6 +100,7 @@ int hci_uart_register_device(struct hci_uart *hu, const struct hci_uart_proto *p
 void hci_uart_unregister_device(struct hci_uart *hu);
 
 int hci_uart_tx_wakeup(struct hci_uart *hu);
+int hci_uart_wait_until_sent(struct hci_uart *hu);
 int hci_uart_init_ready(struct hci_uart *hu);
 void hci_uart_init_work(struct work_struct *work);
 void hci_uart_set_baudrate(struct hci_uart *hu, unsigned int speed);