Commit 7e267b29 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Greg Kroah-Hartman

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 099f79c0
...@@ -128,6 +128,24 @@ static inline void serial_dl_write(struct uart_8250_port *up, int value) ...@@ -128,6 +128,24 @@ static inline void serial_dl_write(struct uart_8250_port *up, int value)
up->dl_write(up, 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); struct uart_8250_port *serial8250_get_port(int line);
void serial8250_rpm_get(struct uart_8250_port *p); void serial8250_rpm_get(struct uart_8250_port *p);
......
...@@ -34,10 +34,8 @@ static void __dma_tx_complete(void *param) ...@@ -34,10 +34,8 @@ static void __dma_tx_complete(void *param)
uart_write_wakeup(&p->port); uart_write_wakeup(&p->port);
ret = serial8250_tx_dma(p); ret = serial8250_tx_dma(p);
if (ret) { if (ret)
p->ier |= UART_IER_THRI; serial8250_set_THRI(p);
serial_port_out(&p->port, UART_IER, p->ier);
}
spin_unlock_irqrestore(&p->port.lock, flags); spin_unlock_irqrestore(&p->port.lock, flags);
} }
...@@ -100,10 +98,7 @@ int serial8250_tx_dma(struct uart_8250_port *p) ...@@ -100,10 +98,7 @@ int serial8250_tx_dma(struct uart_8250_port *p)
dma_async_issue_pending(dma->txchan); dma_async_issue_pending(dma->txchan);
if (dma->tx_err) { if (dma->tx_err) {
dma->tx_err = 0; dma->tx_err = 0;
if (p->ier & UART_IER_THRI) { serial8250_clear_THRI(p);
p->ier &= ~UART_IER_THRI;
serial_out(p, UART_IER, p->ier);
}
} }
return 0; return 0;
err: err:
......
...@@ -923,15 +923,13 @@ static void omap_8250_dma_tx_complete(void *param) ...@@ -923,15 +923,13 @@ static void omap_8250_dma_tx_complete(void *param)
ret = omap_8250_tx_dma(p); ret = omap_8250_tx_dma(p);
if (ret) if (ret)
en_thri = true; en_thri = true;
} else if (p->capabilities & UART_CAP_RPM) { } else if (p->capabilities & UART_CAP_RPM) {
en_thri = true; en_thri = true;
} }
if (en_thri) { if (en_thri) {
dma->tx_err = 1; dma->tx_err = 1;
p->ier |= UART_IER_THRI; serial8250_set_THRI(p);
serial_port_out(&p->port, UART_IER, p->ier);
} }
spin_unlock_irqrestore(&p->port.lock, flags); spin_unlock_irqrestore(&p->port.lock, flags);
...@@ -959,10 +957,7 @@ static int omap_8250_tx_dma(struct uart_8250_port *p) ...@@ -959,10 +957,7 @@ static int omap_8250_tx_dma(struct uart_8250_port *p)
ret = -EBUSY; ret = -EBUSY;
goto err; goto err;
} }
if (p->ier & UART_IER_THRI) { serial8250_clear_THRI(p);
p->ier &= ~UART_IER_THRI;
serial_out(p, UART_IER, p->ier);
}
return 0; return 0;
} }
...@@ -1020,10 +1015,7 @@ static int omap_8250_tx_dma(struct uart_8250_port *p) ...@@ -1020,10 +1015,7 @@ static int omap_8250_tx_dma(struct uart_8250_port *p)
if (dma->tx_err) if (dma->tx_err)
dma->tx_err = 0; dma->tx_err = 0;
if (p->ier & UART_IER_THRI) { serial8250_clear_THRI(p);
p->ier &= ~UART_IER_THRI;
serial_out(p, UART_IER, p->ier);
}
if (skip_byte) if (skip_byte)
serial_out(p, UART_TX, xmit->buf[xmit->tail]); serial_out(p, UART_TX, xmit->buf[xmit->tail]);
return 0; return 0;
......
...@@ -1502,11 +1502,8 @@ static void __stop_tx_rs485(struct uart_8250_port *p) ...@@ -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) static inline void __do_stop_tx(struct uart_8250_port *p)
{ {
if (p->ier & UART_IER_THRI) { if (serial8250_clear_THRI(p))
p->ier &= ~UART_IER_THRI;
serial_out(p, UART_IER, p->ier);
serial8250_rpm_put_tx(p); serial8250_rpm_put_tx(p);
}
} }
static inline void __stop_tx(struct uart_8250_port *p) static inline void __stop_tx(struct uart_8250_port *p)
...@@ -1555,10 +1552,7 @@ static inline void __start_tx(struct uart_port *port) ...@@ -1555,10 +1552,7 @@ static inline void __start_tx(struct uart_port *port)
if (up->dma && !up->dma->tx_dma(up)) if (up->dma && !up->dma->tx_dma(up))
return; return;
if (!(up->ier & UART_IER_THRI)) { if (serial8250_set_THRI(up)) {
up->ier |= UART_IER_THRI;
serial_port_out(port, UART_IER, up->ier);
if (up->bugs & UART_BUG_TXEN) { if (up->bugs & UART_BUG_TXEN) {
unsigned char lsr; unsigned char lsr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment