[v9,01/11] serial: 8250_dw: allow port setup to report errors
Commit Message
Return a status from dw8250_setup_port() and propagate failures through
the DW and LPSS probe paths before registering the UART. Use the existing
LPSS cleanup path to release board resources and IRQ vectors on failure.
Keep the current setup behavior by returning zero on both successful
paths. This separates error propagation from the configuration validation
that will use it.
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/tty/serial/8250/8250_dw.c | 4 +++-
drivers/tty/serial/8250/8250_dwlib.c | 6 ++++--
drivers/tty/serial/8250/8250_dwlib.h | 2 +-
drivers/tty/serial/8250/8250_lpss.c | 4 +++-
4 files changed, 11 insertions(+), 5 deletions(-)
@@ -766,7 +766,9 @@ static int dw8250_probe(struct platform_device *pdev)
dw8250_setup_dma_filter(p, data);
if (!data->skip_autocfg)
- dw8250_setup_port(p);
+ err = dw8250_setup_port(p);
+ if (err)
+ return err;
/* Use the BUSY-safe sequence for both integer and fractional divisors. */
p->set_divisor = dw8250_set_divisor;
@@ -208,7 +208,7 @@ static const struct serial_rs485 dw8250_rs485_supported = {
SER_RS485_ADDR_DEST,
};
-void dw8250_setup_port(struct uart_port *p)
+int dw8250_setup_port(struct uart_port *p)
{
struct dw8250_port_data *pd = p->private_data;
struct uart_8250_port *up = up_to_u8250p(p);
@@ -250,7 +250,7 @@ void dw8250_setup_port(struct uart_port *p)
dev_dbg(p->dev, "CPR is not available, using 0x%08x instead\n", reg);
}
if (!reg)
- return;
+ return 0;
/* Select the type based on FIFO */
if (reg & DW_UART_CPR_FIFO_MODE) {
@@ -270,5 +270,7 @@ void dw8250_setup_port(struct uart_port *p)
pd->srbr = DW_UART_SRBR_0;
else
pd->srbr = UART_RX;
+
+ return 0;
}
EXPORT_SYMBOL_GPL(dw8250_setup_port);
@@ -100,7 +100,7 @@ struct dw8250_port_data {
unsigned int dw8250_get_divisor_dlf(struct uart_port *p, unsigned int baud, unsigned int *frac);
void dw8250_set_divisor_dlf(struct uart_port *p, unsigned int quot_frac);
void dw8250_do_set_termios(struct uart_port *p, struct ktermios *termios, const struct ktermios *old);
-void dw8250_setup_port(struct uart_port *p);
+int dw8250_setup_port(struct uart_port *p);
static inline u32 dw8250_readl_ext(struct uart_port *p, int offset)
{
@@ -350,7 +350,9 @@ static int lpss8250_probe(struct pci_dev *pdev, const struct pci_device_id *id)
if (ret)
return ret;
- dw8250_setup_port(&uart.port);
+ ret = dw8250_setup_port(&uart.port);
+ if (ret)
+ goto err_exit;
ret = lpss8250_dma_setup(lpss, &uart);
if (ret)