serial: 8250_dw: Call dw8250_quirks() conditionally
Subsystems (3)
Andy Shevchenko
reviewerPATCH v2 1/1 serial: 8250_dw: Call dw8250_quirks() conditionally
Not all the cases provide the driver data, that is represented by an object instance of struct dw8250_platform_data. Id est the change missed the case when the driver is instantiated via board files as pure platform driver. Fix this by calling dw8250_quirks() conditionally. This will require splitting dw8250_setup_dma_filter() out of dw8250_quirks(). Also make sure IRQ handler won't crash, it also requires driver data to be present.
Fixes bfd3d4a40f39 ("serial: 8250_dw: Drop unneeded NULL checks in dw8250_quirks()")
Reported-by kernel test robot <[email protected]>
Signed-off-by Andy Shevchenko <[email protected]>
---
v2: made sure IRQ handler won't be called when no driver data provided
Note, there is no Cc: stable@ as the culprit is only in Linux Next.
drivers/tty/serial/8250/8250_dw.c | 36 ++++++++++++++++++------------- 1 file changed, 21 insertions(+), 15 deletions(-)
drivers/tty/serial/8250/8250_dw.c +21 -15
@@ -421,6 +421,18 @@ static bool dw8250_idma_filter(struct dma_chan *chan, void *param)return param == chan->device->dev; } +static void dw8250_setup_dma_filter (struct uart_port *p,struct dw8250_data *data) +{ +/* Platforms with iDMA 64-bit */ +if (platform_get_resource_byname (to_platform_device (p->dev),IORESOURCE_MEM ,"lpss_priv" )) { + data->data.dma.rx_param = p->dev->parent; + data->data.dma.tx_param = p->dev->parent; + data->data.dma.fn = dw8250_idma_filter; + }else { + data->data.dma.fn = dw8250_fallback_dma_filter; + } +} +static u32 dw8250_rzn1_get_dmacr_burst (int max_burst) {if (max_burst >=8 )
@@ -491,14 +503,6 @@ static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data) p->serial_in = dw8250_serial_in32; data->uart_16550_compatible = true; } - -/* Platforms with iDMA 64-bit */ -if (platform_get_resource_byname (to_platform_device (p->dev), -IORESOURCE_MEM ,"lpss_priv" )) { - data->data.dma.rx_param = p->dev->parent; - data->data.dma.tx_param = p->dev->parent; - data->data.dma.fn = dw8250_idma_filter; - } }static void dw8250_reset_control_assert (void *data)
@@ -520,7 +524,6 @@ static int dw8250_probe(struct platform_device *pdev)return dev_err_probe (dev, -EINVAL ,"no registers defined\n" );spin_lock_init (&p->lock); - p->handle_irq = dw8250_handle_irq; p->pm = dw8250_do_pm; p->type =PORT_8250 ; p->flags =UPF_FIXED_PORT ;
@@ -532,13 +535,8 @@ static int dw8250_probe(struct platform_device *pdev)if (!data)return -ENOMEM ; - data->data.dma.fn = dw8250_fallback_dma_filter; - data->pdata =device_get_match_data (p->dev); p->private_data = &data->data; - data->uart_16550_compatible =device_property_read_bool (dev, -"snps,uart-16550-compatible" ); - p->mapbase = regs->start; p->mapsize =resource_size (regs);
@@ -626,11 +624,19 @@ static int dw8250_probe(struct platform_device *pdev)if (err)return err; -dw8250_quirks (p, data); + data->uart_16550_compatible =device_property_read_bool (dev,"snps,uart-16550-compatible" ); + + data->pdata =device_get_match_data (p->dev); +if (data->pdata) +dw8250_quirks (p, data);/* If the Busy Functionality is not implemented, don't handle it */ if (data->uart_16550_compatible) p->handle_irq =NULL ; +else if (data->pdata) + p->handle_irq = dw8250_handle_irq; + +dw8250_setup_dma_filter (p, data);if (!data->skip_autocfg)dw8250_setup_port (p);
Signature · 1 line
2.45.1.3035.g276e886db78b