]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
dw_dmac: absence of pdata isn't critical when autocfg is set
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Wed, 9 Jan 2013 08:17:01 +0000 (10:17 +0200)
committerVinod Koul <vinod.koul@intel.com>
Wed, 9 Jan 2013 14:30:34 +0000 (06:30 -0800)
The patch allows to probe the device when platform data is absent and hardware
auto configuration is enabled. In that case the default platform data is used
where the channel allocation order is set to ascending, channel priority is set
to ascending, and private property is set to true.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
drivers/dma/dw_dmac.c

index 476e9c8fb6ca71a37919ca0d79de83e0357db6b2..c0c9370ddd3ff8b0ee596daa551a53d040b75994 100644 (file)
@@ -1600,13 +1600,6 @@ static int dw_probe(struct platform_device *pdev)
        int                     err;
        int                     i;
 
-       pdata = dev_get_platdata(&pdev->dev);
-       if (!pdata)
-               pdata = dw_dma_parse_dt(pdev);
-
-       if (!pdata || pdata->nr_channels > DW_DMA_MAX_NR_CHANNELS)
-               return -EINVAL;
-
        io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (!io)
                return -EINVAL;
@@ -1622,6 +1615,22 @@ static int dw_probe(struct platform_device *pdev)
        dw_params = dma_read_byaddr(regs, DW_PARAMS);
        autocfg = dw_params >> DW_PARAMS_EN & 0x1;
 
+       pdata = dev_get_platdata(&pdev->dev);
+       if (!pdata)
+               pdata = dw_dma_parse_dt(pdev);
+
+       if (!pdata && autocfg) {
+               pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+               if (!pdata)
+                       return -ENOMEM;
+
+               /* Fill platform data with the default values */
+               pdata->is_private = true;
+               pdata->chan_allocation_order = CHAN_ALLOCATION_ASCENDING;
+               pdata->chan_priority = CHAN_PRIORITY_ASCENDING;
+       } else if (!pdata || pdata->nr_channels > DW_DMA_MAX_NR_CHANNELS)
+               return -EINVAL;
+
        if (autocfg)
                nr_channels = (dw_params >> DW_PARAMS_NR_CHAN & 0x7) + 1;
        else