]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
serial: 8250_exar: Consolidate callback assignments in default_setup()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 5 Aug 2019 14:25:34 +0000 (17:25 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Sep 2019 10:43:51 +0000 (12:43 +0200)
For better maintenance consolidate port callbacks in default_setup().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20190805142535.21948-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/8250/8250_exar.c

index 3e93bd2326c93f1b985f29c6ad262816d2c63725..873aa6b0c2f3f316613b21391992da12d741b365 100644 (file)
@@ -166,6 +166,26 @@ static void xr17v35x_set_divisor(struct uart_port *p, unsigned int baud,
        serial_port_out(p, 0x2, quot_frac);
 }
 
+static void exar_shutdown(struct uart_port *port)
+{
+       unsigned char lsr;
+       bool tx_complete = 0;
+       struct uart_8250_port *up = up_to_u8250p(port);
+       struct circ_buf *xmit = &port->state->xmit;
+       int i = 0;
+
+       do {
+               lsr = serial_in(up, UART_LSR);
+               if (lsr & (UART_LSR_TEMT | UART_LSR_THRE))
+                       tx_complete = 1;
+               else
+                       tx_complete = 0;
+               msleep(1);
+       } while (!uart_circ_empty(xmit) && !tx_complete && i++ < 1000);
+
+       serial8250_do_shutdown(port);
+}
+
 static int default_setup(struct exar8250 *priv, struct pci_dev *pcidev,
                         int idx, unsigned int offset,
                         struct uart_8250_port *port)
@@ -197,6 +217,7 @@ static int default_setup(struct exar8250 *priv, struct pci_dev *pcidev,
        }
 
        port->port.pm = exar_pm;
+       port->port.shutdown = exar_shutdown;
 
        return 0;
 }
@@ -519,27 +540,6 @@ static irqreturn_t exar_misc_handler(int irq, void *data)
        return IRQ_HANDLED;
 }
 
-static void
-exar_shutdown(struct uart_port *port)
-{
-       unsigned char lsr;
-       bool tx_complete = 0;
-       struct uart_8250_port *up = up_to_u8250p(port);
-       struct circ_buf *xmit = &port->state->xmit;
-       int i = 0;
-
-       do {
-               lsr = serial_in(up, UART_LSR);
-               if (lsr & (UART_LSR_TEMT | UART_LSR_THRE))
-                       tx_complete = 1;
-               else
-                       tx_complete = 0;
-               msleep(1);
-       } while (!uart_circ_empty(xmit) && !tx_complete && i++ < 1000);
-
-       serial8250_do_shutdown(port);
-}
-
 static int
 exar_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
 {
@@ -580,7 +580,6 @@ exar_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
        uart.port.flags = UPF_SHARE_IRQ | UPF_EXAR_EFR | UPF_FIXED_TYPE | UPF_FIXED_PORT;
        uart.port.irq = pci_irq_vector(pcidev, 0);
        uart.port.dev = &pcidev->dev;
-       uart.port.shutdown = exar_shutdown;
 
        rc = devm_request_irq(&pcidev->dev, uart.port.irq, exar_misc_handler,
                         IRQF_SHARED, "exar_uart", priv);