Skip to contentSkip to conversation

serial: 8250_dma: couple of cleanups

PATCH New Andy Shevchenko 1 participant 3 messages Nov 6, 2014 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

v2 cover serial: 8250_dma: couple of cleanups

Here are couple of cleanups against DMA support for 8250 serial driver.

Since v1:
- rebase on top of tty-testing
- append patch 2/2

Andy Shevchenko (2):
serial: 8250_dma: call serial8250_tx_dma unconditionally
serial: 8250_dma: no need to set tx_err twice

 drivers/tty/serial/8250/8250_dma.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
Signature · 1 line
2.1.1
#1 lore raw

PATCH v2 1/2 serial: 8250_dma: call serial8250_tx_dma unconditionally

Since we have the same check inside the function we may drop it away in __dma_tx_complete().

---
 drivers/tty/serial/8250/8250_dma.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/tty/serial/8250/8250_dma.c +6 -9
index 258430b..b16f9b1 100644
@@ -21,6 +21,7 @@ static void __dma_tx_complete(void *param)
 	struct uart_8250_dma	*dma = p->dma;
 	struct circ_buf		*xmit = &p->port.state->xmit;
 	unsigned long	flags;
+	int		ret;
 
 	dma_sync_single_for_cpu(dma->txchan->device->dev, dma->tx_addr,
 				UART_XMIT_SIZE, DMA_TO_DEVICE);
@@ -36,15 +37,11 @@ static void __dma_tx_complete(void *param)
 	if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
 		uart_write_wakeup(&p->port);
 
-	if (!uart_circ_empty(xmit) && !uart_tx_stopped(&p->port)) {
-		int ret;
-
-		ret = serial8250_tx_dma(p);
-		if (ret) {
-			dma->tx_err = 1;
-			p->ier |= UART_IER_THRI;
-			serial_port_out(&p->port, UART_IER, p->ier);
-		}
+	ret = serial8250_tx_dma(p);
+	if (ret) {
+		dma->tx_err = 1;
+		p->ier |= UART_IER_THRI;
+		serial_port_out(&p->port, UART_IER, p->ier);
 	}
 
 	spin_unlock_irqrestore(&p->port.lock, flags);
Signature · 1 line
2.1.1
#2 lore raw

PATCH v2 2/2 serial: 8250_dma: no need to set tx_err twice

In reply to Andy Shevchenko

In the serial8250_tx_dma() the tx_err flag is set in case of error. Thus, there is no need to repeat this in __dma_tx_complete().

---
 drivers/tty/serial/8250/8250_dma.c | 2 --
 1 file changed, 2 deletions(-)
drivers/tty/serial/8250/8250_dma.c +0 -2
index b16f9b1..fcd7ac6 100644
@@ -39,7 +39,6 @@ static void __dma_tx_complete(void *param)
 
 	ret = serial8250_tx_dma(p);
 	if (ret) {
-		dma->tx_err = 1;
 		p->ier |= UART_IER_THRI;
 		serial_port_out(&p->port, UART_IER, p->ier);
 	}
@@ -93,7 +92,6 @@ int serial8250_tx_dma(struct uart_8250_port *p)
 	}
 
 	dma->tx_running = 1;
-
 	desc->callback = __dma_tx_complete;
 	desc->callback_param = p;
 
Signature · 1 line
2.1.1