diff options
author | Andrey Smirnov <[email protected]> | 2019-08-05 11:56:57 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <[email protected]> | 2019-09-04 12:43:51 +0200 |
commit | fd60e8e4a701043831370f6f635de2738fec07c8 (patch) | |
tree | d74a7312987b3dde65f70ee5b9c627138e295c3a | |
parent | 5982199ca071cb4f11503ecd6f37aa5c6a8dea6e (diff) |
tty: serial: fsl_lpuart: Introduce lpuart_rx_dma_startup()
Code doing initial DMA RX configuration in lpuart_startup() and
lpuart32_startup() is exactly the same, so move it into a standalone
subroutine.
Signed-off-by: Andrey Smirnov <[email protected]>
Cc: Stefan Agner <[email protected]>
Cc: Chris Healy <[email protected]>
Cc: Cory Tusar <[email protected]>
Cc: Lucas Stach <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Jiri Slaby <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
-rw-r--r-- | drivers/tty/serial/fsl_lpuart.c | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index 9da4529ee223..4b59801a0a0c 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -1455,6 +1455,21 @@ static void lpuart_tx_dma_startup(struct lpuart_port *sport) } } +static void lpuart_rx_dma_startup(struct lpuart_port *sport) +{ + if (sport->dma_rx_chan && !lpuart_start_rx_dma(sport)) { + /* set Rx DMA timeout */ + sport->dma_rx_timeout = msecs_to_jiffies(DMA_RX_TIMEOUT); + if (!sport->dma_rx_timeout) + sport->dma_rx_timeout = 1; + + sport->lpuart_dma_rx_use = true; + rx_dma_timer_init(sport); + } else { + sport->lpuart_dma_rx_use = false; + } +} + static int lpuart_startup(struct uart_port *port) { struct lpuart_port *sport = container_of(port, struct lpuart_port, port); @@ -1479,18 +1494,7 @@ static int lpuart_startup(struct uart_port *port) temp |= UARTCR2_RIE | UARTCR2_TIE | UARTCR2_RE | UARTCR2_TE; writeb(temp, sport->port.membase + UARTCR2); - if (sport->dma_rx_chan && !lpuart_start_rx_dma(sport)) { - /* set Rx DMA timeout */ - sport->dma_rx_timeout = msecs_to_jiffies(DMA_RX_TIMEOUT); - if (!sport->dma_rx_timeout) - sport->dma_rx_timeout = 1; - - sport->lpuart_dma_rx_use = true; - rx_dma_timer_init(sport); - } else { - sport->lpuart_dma_rx_use = false; - } - + lpuart_rx_dma_startup(sport); lpuart_tx_dma_startup(sport); spin_unlock_irqrestore(&sport->port.lock, flags); @@ -1522,18 +1526,8 @@ static int lpuart32_startup(struct uart_port *port) temp |= UARTCTRL_RE | UARTCTRL_TE | UARTCTRL_ILIE; lpuart32_write(&sport->port, temp, UARTCTRL); - if (sport->dma_rx_chan && !lpuart_start_rx_dma(sport)) { - /* set Rx DMA timeout */ - sport->dma_rx_timeout = msecs_to_jiffies(DMA_RX_TIMEOUT); - if (!sport->dma_rx_timeout) - sport->dma_rx_timeout = 1; - - sport->lpuart_dma_rx_use = true; - rx_dma_timer_init(sport); - } else { - sport->lpuart_dma_rx_use = false; - } + lpuart_rx_dma_startup(sport); lpuart_tx_dma_startup(sport); if (sport->lpuart_dma_rx_use) { |