Skip to content

Commit 94ec165

Browse files
Jiri Slaby (SUSE)gregkh
authored andcommitted
serial: atmel: cleanup atmel_start+stop_tx()
Define local variables holding information about whether pdc or dma is used in the HW. These are retested several times by calls to atmel_use_pdc_tx() and atmel_use_dma_tx(). So to make the code more readable, simply cache the values. This is also a preparatory patch for the next one (where is_pdc is used once more in atmel_stop_tx()). Cc: Richard Genoud <[email protected]> Cc: Nicolas Ferre <[email protected]> Cc: Alexandre Belloni <[email protected]> Cc: Claudiu Beznea <[email protected]> Cc: [email protected] Reported-by: Michael Walle <[email protected]> Signed-off-by: Jiri Slaby (SUSE) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8682ab0 commit 94ec165

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

drivers/tty/serial/atmel_serial.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,9 @@ static u_int atmel_get_mctrl(struct uart_port *port)
552552
static void atmel_stop_tx(struct uart_port *port)
553553
{
554554
struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
555+
bool is_pdc = atmel_use_pdc_tx(port);
555556

556-
if (atmel_use_pdc_tx(port)) {
557+
if (is_pdc) {
557558
/* disable PDC transmit */
558559
atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTDIS);
559560
}
@@ -572,7 +573,6 @@ static void atmel_stop_tx(struct uart_port *port)
572573
if (atmel_uart_is_half_duplex(port))
573574
if (!atomic_read(&atmel_port->tasklet_shutdown))
574575
atmel_start_rx(port);
575-
576576
}
577577

578578
/*
@@ -581,20 +581,22 @@ static void atmel_stop_tx(struct uart_port *port)
581581
static void atmel_start_tx(struct uart_port *port)
582582
{
583583
struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
584+
bool is_pdc = atmel_use_pdc_tx(port);
585+
bool is_dma = is_pdc || atmel_use_dma_tx(port);
584586

585-
if (atmel_use_pdc_tx(port) && (atmel_uart_readl(port, ATMEL_PDC_PTSR)
587+
if (is_pdc && (atmel_uart_readl(port, ATMEL_PDC_PTSR)
586588
& ATMEL_PDC_TXTEN))
587589
/* The transmitter is already running. Yes, we
588590
really need this.*/
589591
return;
590592

591-
if (atmel_use_pdc_tx(port) || atmel_use_dma_tx(port))
592-
if (atmel_uart_is_half_duplex(port))
593-
atmel_stop_rx(port);
593+
if (is_dma && atmel_uart_is_half_duplex(port))
594+
atmel_stop_rx(port);
594595

595-
if (atmel_use_pdc_tx(port))
596+
if (is_pdc) {
596597
/* re-enable PDC transmit */
597598
atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTEN);
599+
}
598600

599601
/* Enable interrupts */
600602
atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask);

0 commit comments

Comments
 (0)