mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
Simplify uart_tx_start()
All calls to it did
if (uart_tx_stopped())
uart_tx_start();
And that was the only use of uart_tx_stopped(). Merge the functions.
BUG=chrome-os-partner:20485
BRANCH=none
TEST=EC debug console still prints output and accepts commands.
Ctrl+Q pauses output and Ctrl+S resumes it.
Change-Id: I113c64f5fdfc6b02b63034a74b1a3c6c6a76c351
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/169329
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
This commit is contained in:
committed by
chrome-internal-fetch
parent
fa76d68ce9
commit
573e695a69
@@ -25,6 +25,10 @@ int uart_init_done(void)
|
||||
|
||||
void uart_tx_start(void)
|
||||
{
|
||||
/* If interrupt is already enabled, nothing to do */
|
||||
if (LM4_UART_IM(0) & 0x20)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Re-enable the transmit interrupt, then forcibly trigger the
|
||||
* interrupt. This works around a hardware problem with the
|
||||
@@ -40,11 +44,6 @@ void uart_tx_stop(void)
|
||||
LM4_UART_IM(0) &= ~0x20;
|
||||
}
|
||||
|
||||
int uart_tx_stopped(void)
|
||||
{
|
||||
return !(LM4_UART_IM(0) & 0x20);
|
||||
}
|
||||
|
||||
void uart_tx_flush(void)
|
||||
{
|
||||
/* Wait for transmit FIFO empty */
|
||||
|
||||
@@ -41,6 +41,10 @@ int uart_init_done(void)
|
||||
|
||||
void uart_tx_start(void)
|
||||
{
|
||||
/* If interrupt is already enabled, nothing to do */
|
||||
if (STM32_USART_CR1(UARTN) & UART_TX_INT_ENABLE)
|
||||
return;
|
||||
|
||||
disable_sleep(SLEEP_MASK_UART);
|
||||
should_stop = 0;
|
||||
STM32_USART_CR1(UARTN) |= UART_TX_INT_ENABLE;
|
||||
@@ -54,11 +58,6 @@ void uart_tx_stop(void)
|
||||
enable_sleep(SLEEP_MASK_UART);
|
||||
}
|
||||
|
||||
int uart_tx_stopped(void)
|
||||
{
|
||||
return !(STM32_USART_CR1(UARTN) & UART_TX_INT_ENABLE);
|
||||
}
|
||||
|
||||
void uart_tx_flush(void)
|
||||
{
|
||||
while (!(STM32_USART_SR(UARTN) & STM32_USART_SR_TXE))
|
||||
|
||||
@@ -146,8 +146,7 @@ void uart_process_input(void)
|
||||
} else if (c == CTRL('S')) {
|
||||
/* Software flow control - XON */
|
||||
uart_suspended = 0;
|
||||
if (uart_tx_stopped())
|
||||
uart_tx_start();
|
||||
uart_tx_start();
|
||||
} else if (rx_buf_next != rx_buf_tail) {
|
||||
/* Buffer all other input */
|
||||
rx_buf[rx_buf_head] = c;
|
||||
@@ -165,7 +164,7 @@ int uart_putc(int c)
|
||||
{
|
||||
int rv = __tx_char(NULL, c);
|
||||
|
||||
if (!uart_suspended && uart_tx_stopped())
|
||||
if (!uart_suspended)
|
||||
uart_tx_start();
|
||||
|
||||
return rv ? EC_ERROR_OVERFLOW : EC_SUCCESS;
|
||||
@@ -179,7 +178,7 @@ int uart_puts(const char *outstr)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!uart_suspended && uart_tx_stopped())
|
||||
if (!uart_suspended)
|
||||
uart_tx_start();
|
||||
|
||||
/* Successful if we consumed all output */
|
||||
@@ -190,7 +189,7 @@ int uart_vprintf(const char *format, va_list args)
|
||||
{
|
||||
int rv = vfnprintf(__tx_char, NULL, format, args);
|
||||
|
||||
if (!uart_suspended && uart_tx_stopped())
|
||||
if (!uart_suspended)
|
||||
uart_tx_start();
|
||||
|
||||
return rv;
|
||||
@@ -222,7 +221,7 @@ void uart_flush_output(void)
|
||||
* we're in now.
|
||||
*/
|
||||
uart_process_output();
|
||||
} else if (uart_tx_stopped()) {
|
||||
} else {
|
||||
/*
|
||||
* It's possible we switched from a previous context
|
||||
* which was doing a printf() or puts() but hadn't
|
||||
|
||||
@@ -149,8 +149,8 @@ void uart_enable_interrupt(void);
|
||||
/**
|
||||
* Re-enable the UART transmit interrupt.
|
||||
*
|
||||
* This also forces triggering an interrupt if the hardware doesn't
|
||||
* automatically trigger it when the transmit buffer was filled beforehand.
|
||||
* This also forces triggering a UART interrupt, if the transmit interrupt was
|
||||
* disabled.
|
||||
*/
|
||||
void uart_tx_start(void);
|
||||
|
||||
@@ -159,11 +159,6 @@ void uart_tx_start(void);
|
||||
*/
|
||||
void uart_tx_stop(void);
|
||||
|
||||
/**
|
||||
* Return non-zero if the UART transmit interrupt is disabled.
|
||||
*/
|
||||
int uart_tx_stopped(void);
|
||||
|
||||
/**
|
||||
* Helper for processing UART input.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user