For better maintenance consolidate port callbacks in default_setup(). Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> --- drivers/tty/serial/8250/8250_exar.c | 43 ++++++++++++++--------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c index 3e93bd2326c9..873aa6b0c2f3 100644 --- a/drivers/tty/serial/8250/8250_exar.c +++ b/drivers/tty/serial/8250/8250_exar.c @@ -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); -- 2.20.1