Skip to content

Commit c213375

Browse files
andy-shevgregkh
authored andcommitted
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: bfd3d4a ("serial: 8250_dw: Drop unneeded NULL checks in dw8250_quirks()") Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-lkp/[email protected] Signed-off-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 22a6984 commit c213375

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

drivers/tty/serial/8250/8250_dw.c

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,18 @@ static bool dw8250_idma_filter(struct dma_chan *chan, void *param)
421421
return param == chan->device->dev;
422422
}
423423

424+
static void dw8250_setup_dma_filter(struct uart_port *p, struct dw8250_data *data)
425+
{
426+
/* Platforms with iDMA 64-bit */
427+
if (platform_get_resource_byname(to_platform_device(p->dev), IORESOURCE_MEM, "lpss_priv")) {
428+
data->data.dma.rx_param = p->dev->parent;
429+
data->data.dma.tx_param = p->dev->parent;
430+
data->data.dma.fn = dw8250_idma_filter;
431+
} else {
432+
data->data.dma.fn = dw8250_fallback_dma_filter;
433+
}
434+
}
435+
424436
static u32 dw8250_rzn1_get_dmacr_burst(int max_burst)
425437
{
426438
if (max_burst >= 8)
@@ -491,14 +503,6 @@ static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data)
491503
p->serial_in = dw8250_serial_in32;
492504
data->uart_16550_compatible = true;
493505
}
494-
495-
/* Platforms with iDMA 64-bit */
496-
if (platform_get_resource_byname(to_platform_device(p->dev),
497-
IORESOURCE_MEM, "lpss_priv")) {
498-
data->data.dma.rx_param = p->dev->parent;
499-
data->data.dma.tx_param = p->dev->parent;
500-
data->data.dma.fn = dw8250_idma_filter;
501-
}
502506
}
503507

504508
static void dw8250_reset_control_assert(void *data)
@@ -520,7 +524,6 @@ static int dw8250_probe(struct platform_device *pdev)
520524
return dev_err_probe(dev, -EINVAL, "no registers defined\n");
521525

522526
spin_lock_init(&p->lock);
523-
p->handle_irq = dw8250_handle_irq;
524527
p->pm = dw8250_do_pm;
525528
p->type = PORT_8250;
526529
p->flags = UPF_FIXED_PORT;
@@ -532,13 +535,8 @@ static int dw8250_probe(struct platform_device *pdev)
532535
if (!data)
533536
return -ENOMEM;
534537

535-
data->data.dma.fn = dw8250_fallback_dma_filter;
536-
data->pdata = device_get_match_data(p->dev);
537538
p->private_data = &data->data;
538539

539-
data->uart_16550_compatible = device_property_read_bool(dev,
540-
"snps,uart-16550-compatible");
541-
542540
p->mapbase = regs->start;
543541
p->mapsize = resource_size(regs);
544542

@@ -626,11 +624,19 @@ static int dw8250_probe(struct platform_device *pdev)
626624
if (err)
627625
return err;
628626

629-
dw8250_quirks(p, data);
627+
data->uart_16550_compatible = device_property_read_bool(dev, "snps,uart-16550-compatible");
628+
629+
data->pdata = device_get_match_data(p->dev);
630+
if (data->pdata)
631+
dw8250_quirks(p, data);
630632

631633
/* If the Busy Functionality is not implemented, don't handle it */
632634
if (data->uart_16550_compatible)
633635
p->handle_irq = NULL;
636+
else if (data->pdata)
637+
p->handle_irq = dw8250_handle_irq;
638+
639+
dw8250_setup_dma_filter(p, data);
634640

635641
if (!data->skip_autocfg)
636642
dw8250_setup_port(p);

0 commit comments

Comments
 (0)