[PATCH 13/30] leon, apbuart: Wait for shift register on close
Daniel Hellstrom
daniel at gaisler.com
Thu Apr 13 19:31:22 UTC 2017
From: Martin Aberg <maberg at gaisler.com>
Do not disable transmitter until shift register is empty when closing device.
It is correct to look at the sending software state when closing the device.
However, the sending state must be cleared only when everything is sent.
---
c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c b/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c
index fc1c454..769efc4 100644
--- a/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c
+++ b/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c
@@ -497,6 +497,12 @@ static void last_close(
while (uart->sending) {
/* Wait until all data has been sent */
}
+ while (
+ (uart->regs->ctrl & APBUART_CTRL_TE) &&
+ !(uart->regs->status & APBUART_STATUS_TS)
+ ) {
+ /* Wait until all data has left shift register */
+ }
/* Disable and unregister interrupt handler */
drvmgr_interrupt_unregister(uart->dev, 0, apbuart_cons_isr, tty);
@@ -846,7 +852,6 @@ static void apbuart_cons_isr(void *arg)
if (uart->sending && (status & APBUART_STATUS_TE)) {
/* Tell close that we sent everything */
cnt = uart->sending;
- uart->sending = 0;
/*
* Tell termios how much we have sent. dequeue() may call
--
2.7.4
More information about the devel
mailing list