diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2019-06-14 03:23:49 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2019-07-06 06:53:56 -0400 |
commit | 40fbb915fd0f4b088f5c9b07061b7d665287d26f (patch) | |
tree | 765fb7b8865ae2ecadc9df3c2676ba42374f25e5 /drivers/bluetooth | |
parent | db50450d096a452ae36dc265575cbff50f0f9f01 (diff) |
Bluetooth: hci_ldisc: Add function to wait for characters to be sent
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>
Diffstat (limited to 'drivers/bluetooth')
-rw-r--r-- | drivers/bluetooth/hci_ldisc.c | 8 | ||||
-rw-r--r-- | drivers/bluetooth/hci_uart.h | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index c84f985f348d..8950e07889fe 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c | |||
@@ -178,6 +178,7 @@ restart: | |||
178 | goto restart; | 178 | goto restart; |
179 | 179 | ||
180 | clear_bit(HCI_UART_SENDING, &hu->tx_state); | 180 | clear_bit(HCI_UART_SENDING, &hu->tx_state); |
181 | wake_up_bit(&hu->tx_state, HCI_UART_SENDING); | ||
181 | } | 182 | } |
182 | 183 | ||
183 | void hci_uart_init_work(struct work_struct *work) | 184 | void hci_uart_init_work(struct work_struct *work) |
@@ -213,6 +214,13 @@ int hci_uart_init_ready(struct hci_uart *hu) | |||
213 | return 0; | 214 | return 0; |
214 | } | 215 | } |
215 | 216 | ||
217 | int hci_uart_wait_until_sent(struct hci_uart *hu) | ||
218 | { | ||
219 | return wait_on_bit_timeout(&hu->tx_state, HCI_UART_SENDING, | ||
220 | TASK_INTERRUPTIBLE, | ||
221 | msecs_to_jiffies(2000)); | ||
222 | } | ||
223 | |||
216 | /* ------- Interface to HCI layer ------ */ | 224 | /* ------- Interface to HCI layer ------ */ |
217 | /* Reset device */ | 225 | /* Reset device */ |
218 | static int hci_uart_flush(struct hci_dev *hdev) | 226 | static int hci_uart_flush(struct hci_dev *hdev) |
diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h index d8cf005e3c5d..f11af3912ce6 100644 --- a/drivers/bluetooth/hci_uart.h +++ b/drivers/bluetooth/hci_uart.h | |||
@@ -100,6 +100,7 @@ int hci_uart_register_device(struct hci_uart *hu, const struct hci_uart_proto *p | |||
100 | void hci_uart_unregister_device(struct hci_uart *hu); | 100 | void hci_uart_unregister_device(struct hci_uart *hu); |
101 | 101 | ||
102 | int hci_uart_tx_wakeup(struct hci_uart *hu); | 102 | int hci_uart_tx_wakeup(struct hci_uart *hu); |
103 | int hci_uart_wait_until_sent(struct hci_uart *hu); | ||
103 | int hci_uart_init_ready(struct hci_uart *hu); | 104 | int hci_uart_init_ready(struct hci_uart *hu); |
104 | void hci_uart_init_work(struct work_struct *work); | 105 | void hci_uart_init_work(struct work_struct *work); |
105 | void hci_uart_set_baudrate(struct hci_uart *hu, unsigned int speed); | 106 | void hci_uart_set_baudrate(struct hci_uart *hu, unsigned int speed); |