serial: fsl_linflexuart: deduplicate character sending
Introduce a new linflex_put_char() helper to send a character. And use it on both places this code was duplicated. Cc: Stefan-gabriel Mirea <stefan-gabriel.mirea@nxp.com> Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20220124071430.14907-9-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
32330c8334
commit
7b9528c291
@@ -157,27 +157,29 @@ static void linflex_stop_rx(struct uart_port *port)
|
||||
writel(ier & ~LINFLEXD_LINIER_DRIE, port->membase + LINIER);
|
||||
}
|
||||
|
||||
static void linflex_put_char(struct uart_port *sport, unsigned char c)
|
||||
{
|
||||
unsigned long status;
|
||||
|
||||
writeb(c, sport->membase + BDRL);
|
||||
|
||||
/* Waiting for data transmission completed. */
|
||||
while (((status = readl(sport->membase + UARTSR)) &
|
||||
LINFLEXD_UARTSR_DTFTFF) !=
|
||||
LINFLEXD_UARTSR_DTFTFF)
|
||||
;
|
||||
|
||||
writel(status | LINFLEXD_UARTSR_DTFTFF, sport->membase + UARTSR);
|
||||
}
|
||||
|
||||
static inline void linflex_transmit_buffer(struct uart_port *sport)
|
||||
{
|
||||
struct circ_buf *xmit = &sport->state->xmit;
|
||||
unsigned char c;
|
||||
unsigned long status;
|
||||
|
||||
while (!uart_circ_empty(xmit)) {
|
||||
c = xmit->buf[xmit->tail];
|
||||
writeb(c, sport->membase + BDRL);
|
||||
|
||||
/* Waiting for data transmission completed. */
|
||||
while (((status = readl(sport->membase + UARTSR)) &
|
||||
LINFLEXD_UARTSR_DTFTFF) !=
|
||||
LINFLEXD_UARTSR_DTFTFF)
|
||||
;
|
||||
|
||||
linflex_put_char(sport, xmit->buf[xmit->tail]);
|
||||
xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
|
||||
sport->icount.tx++;
|
||||
|
||||
writel(status | LINFLEXD_UARTSR_DTFTFF,
|
||||
sport->membase + UARTSR);
|
||||
}
|
||||
|
||||
if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
|
||||
@@ -201,21 +203,11 @@ static irqreturn_t linflex_txint(int irq, void *dev_id)
|
||||
struct uart_port *sport = dev_id;
|
||||
struct circ_buf *xmit = &sport->state->xmit;
|
||||
unsigned long flags;
|
||||
unsigned long status;
|
||||
|
||||
spin_lock_irqsave(&sport->lock, flags);
|
||||
|
||||
if (sport->x_char) {
|
||||
writeb(sport->x_char, sport->membase + BDRL);
|
||||
|
||||
/* waiting for data transmission completed */
|
||||
while (((status = readl(sport->membase + UARTSR)) &
|
||||
LINFLEXD_UARTSR_DTFTFF) != LINFLEXD_UARTSR_DTFTFF)
|
||||
;
|
||||
|
||||
writel(status | LINFLEXD_UARTSR_DTFTFF,
|
||||
sport->membase + UARTSR);
|
||||
|
||||
linflex_put_char(sport, sport->x_char);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user