serial: 8250_dw: provide a filter for DMA channel detection
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>
Thu, 5 Sep 2013 14:34:54 +0000 (17:34 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 26 Sep 2013 21:27:24 +0000 (14:27 -0700)
The channel IDs are set to -1 by default. It will prevent
dmaengine from trying to provide the first free channel if
it fails to allocate exclusive channel. This will fix an
issue with ACPI enumerated UARTs that do not support DMA
but still end up getting a DMA channel incorrectly.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/8250/8250_dw.c

index d7a405b12600ff4127b385f92791a7c74559adb6..8edf7697fdb2789b850bb49a0f2b3e3f9aae49db 100644 (file)
@@ -154,6 +154,14 @@ dw8250_do_pm(struct uart_port *port, unsigned int state, unsigned int old)
                pm_runtime_put_sync_suspend(port->dev);
 }
 
+static bool dw8250_dma_filter(struct dma_chan *chan, void *param)
+{
+       struct dw8250_data *data = param;
+
+       return chan->chan_id == data->dma.tx_chan_id ||
+              chan->chan_id == data->dma.rx_chan_id;
+}
+
 static void dw8250_setup_port(struct uart_8250_port *up)
 {
        struct uart_port        *p = &up->port;
@@ -314,6 +322,12 @@ static int dw8250_probe(struct platform_device *pdev)
                uart.port.uartclk = clk_get_rate(data->clk);
        }
 
+       data->dma.rx_chan_id = -1;
+       data->dma.tx_chan_id = -1;
+       data->dma.rx_param = data;
+       data->dma.tx_param = data;
+       data->dma.fn = dw8250_dma_filter;
+
        uart.port.iotype = UPIO_MEM;
        uart.port.serial_in = dw8250_serial_in;
        uart.port.serial_out = dw8250_serial_out;