serial: 8250: factor out serial8250_{set,clear}_THRI() helpers
Factor out similar code pieces that set or clear UART_IER_THRI bit to serial8250_{set,clear}_THRI() helpers. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
099f79c019
commit
7e267b2956
|
@ -128,6 +128,24 @@ static inline void serial_dl_write(struct uart_8250_port *up, int value)
|
|||
up->dl_write(up, value);
|
||||
}
|
||||
|
||||
static inline bool serial8250_set_THRI(struct uart_8250_port *up)
|
||||
{
|
||||
if (up->ier & UART_IER_THRI)
|
||||
return false;
|
||||
up->ier |= UART_IER_THRI;
|
||||
serial_out(up, UART_IER, up->ier);
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline bool serial8250_clear_THRI(struct uart_8250_port *up)
|
||||
{
|
||||
if (!(up->ier & UART_IER_THRI))
|
||||
return false;
|
||||
up->ier &= ~UART_IER_THRI;
|
||||
serial_out(up, UART_IER, up->ier);
|
||||
return true;
|
||||
}
|
||||
|
||||
struct uart_8250_port *serial8250_get_port(int line);
|
||||
|
||||
void serial8250_rpm_get(struct uart_8250_port *p);
|
||||
|
|
|
@ -34,10 +34,8 @@ static void __dma_tx_complete(void *param)
|
|||
uart_write_wakeup(&p->port);
|
||||
|
||||
ret = serial8250_tx_dma(p);
|
||||
if (ret) {
|
||||
p->ier |= UART_IER_THRI;
|
||||
serial_port_out(&p->port, UART_IER, p->ier);
|
||||
}
|
||||
if (ret)
|
||||
serial8250_set_THRI(p);
|
||||
|
||||
spin_unlock_irqrestore(&p->port.lock, flags);
|
||||
}
|
||||
|
@ -100,10 +98,7 @@ int serial8250_tx_dma(struct uart_8250_port *p)
|
|||
dma_async_issue_pending(dma->txchan);
|
||||
if (dma->tx_err) {
|
||||
dma->tx_err = 0;
|
||||
if (p->ier & UART_IER_THRI) {
|
||||
p->ier &= ~UART_IER_THRI;
|
||||
serial_out(p, UART_IER, p->ier);
|
||||
}
|
||||
serial8250_clear_THRI(p);
|
||||
}
|
||||
return 0;
|
||||
err:
|
||||
|
|
|
@ -923,15 +923,13 @@ static void omap_8250_dma_tx_complete(void *param)
|
|||
ret = omap_8250_tx_dma(p);
|
||||
if (ret)
|
||||
en_thri = true;
|
||||
|
||||
} else if (p->capabilities & UART_CAP_RPM) {
|
||||
en_thri = true;
|
||||
}
|
||||
|
||||
if (en_thri) {
|
||||
dma->tx_err = 1;
|
||||
p->ier |= UART_IER_THRI;
|
||||
serial_port_out(&p->port, UART_IER, p->ier);
|
||||
serial8250_set_THRI(p);
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&p->port.lock, flags);
|
||||
|
@ -959,10 +957,7 @@ static int omap_8250_tx_dma(struct uart_8250_port *p)
|
|||
ret = -EBUSY;
|
||||
goto err;
|
||||
}
|
||||
if (p->ier & UART_IER_THRI) {
|
||||
p->ier &= ~UART_IER_THRI;
|
||||
serial_out(p, UART_IER, p->ier);
|
||||
}
|
||||
serial8250_clear_THRI(p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1020,10 +1015,7 @@ static int omap_8250_tx_dma(struct uart_8250_port *p)
|
|||
if (dma->tx_err)
|
||||
dma->tx_err = 0;
|
||||
|
||||
if (p->ier & UART_IER_THRI) {
|
||||
p->ier &= ~UART_IER_THRI;
|
||||
serial_out(p, UART_IER, p->ier);
|
||||
}
|
||||
serial8250_clear_THRI(p);
|
||||
if (skip_byte)
|
||||
serial_out(p, UART_TX, xmit->buf[xmit->tail]);
|
||||
return 0;
|
||||
|
|
|
@ -1502,11 +1502,8 @@ static void __stop_tx_rs485(struct uart_8250_port *p)
|
|||
|
||||
static inline void __do_stop_tx(struct uart_8250_port *p)
|
||||
{
|
||||
if (p->ier & UART_IER_THRI) {
|
||||
p->ier &= ~UART_IER_THRI;
|
||||
serial_out(p, UART_IER, p->ier);
|
||||
if (serial8250_clear_THRI(p))
|
||||
serial8250_rpm_put_tx(p);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void __stop_tx(struct uart_8250_port *p)
|
||||
|
@ -1555,10 +1552,7 @@ static inline void __start_tx(struct uart_port *port)
|
|||
if (up->dma && !up->dma->tx_dma(up))
|
||||
return;
|
||||
|
||||
if (!(up->ier & UART_IER_THRI)) {
|
||||
up->ier |= UART_IER_THRI;
|
||||
serial_port_out(port, UART_IER, up->ier);
|
||||
|
||||
if (serial8250_set_THRI(up)) {
|
||||
if (up->bugs & UART_BUG_TXEN) {
|
||||
unsigned char lsr;
|
||||
|
||||
|
|
Loading…
Reference in New Issue