提交 653d00c8 编写于 作者: A Andy Shevchenko 提交者: Greg Kroah-Hartman

serial: 8250_exar: Consolidate callback assignments in default_setup()

For better maintenance consolidate port callbacks in default_setup().
Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20190805142535.21948-1-andriy.shevchenko@linux.intel.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 44e60d52
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册