Last steps of .shutdown() code are identical for lpuart and lpuart32
cases, so move it all 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]
---
 drivers/tty/serial/fsl_lpuart.c | 42 ++++++++++++++-------------------
 1 file changed, 18 insertions(+), 24 deletions(-)

diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index 2597a877d639..8cf10d12947f 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -1547,6 +1547,22 @@ static int lpuart32_startup(struct uart_port *port)
        return 0;
 }
 
+static void lpuart_dma_shutdown(struct lpuart_port *sport)
+{
+       if (sport->lpuart_dma_rx_use) {
+               del_timer_sync(&sport->lpuart_timer);
+               lpuart_dma_rx_free(&sport->port);
+       }
+
+       if (sport->lpuart_dma_tx_use) {
+               if (wait_event_interruptible(sport->dma_wait,
+                       !sport->dma_tx_in_progress) != false) {
+                       sport->dma_tx_in_progress = false;
+                       dmaengine_terminate_all(sport->dma_tx_chan);
+               }
+       }
+}
+
 static void lpuart_shutdown(struct uart_port *port)
 {
        struct lpuart_port *sport = container_of(port, struct lpuart_port, 
port);
@@ -1563,18 +1579,7 @@ static void lpuart_shutdown(struct uart_port *port)
 
        spin_unlock_irqrestore(&port->lock, flags);
 
-       if (sport->lpuart_dma_rx_use) {
-               del_timer_sync(&sport->lpuart_timer);
-               lpuart_dma_rx_free(&sport->port);
-       }
-
-       if (sport->lpuart_dma_tx_use) {
-               if (wait_event_interruptible(sport->dma_wait,
-                       !sport->dma_tx_in_progress) != false) {
-                       sport->dma_tx_in_progress = false;
-                       dmaengine_terminate_all(sport->dma_tx_chan);
-               }
-       }
+       lpuart_dma_shutdown(sport);
 }
 
 static void lpuart32_shutdown(struct uart_port *port)
@@ -1594,18 +1599,7 @@ static void lpuart32_shutdown(struct uart_port *port)
 
        spin_unlock_irqrestore(&port->lock, flags);
 
-       if (sport->lpuart_dma_rx_use) {
-               del_timer_sync(&sport->lpuart_timer);
-               lpuart_dma_rx_free(&sport->port);
-       }
-
-       if (sport->lpuart_dma_tx_use) {
-               if (wait_event_interruptible(sport->dma_wait,
-                                            !sport->dma_tx_in_progress)) {
-                       sport->dma_tx_in_progress = false;
-                       dmaengine_terminate_all(sport->dma_tx_chan);
-               }
-       }
+       lpuart_dma_shutdown(sport);
 }
 
 static void
-- 
2.21.0

Reply via email to