diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2016-04-27 14:15:37 +0300 |
---|---|---|
committer | Vinod Koul <vinod.koul@intel.com> | 2016-05-02 15:30:25 +0530 |
commit | 969f750fc63d3fd2f26eceedcdeca5878b785b2e (patch) | |
tree | 04eb31a9002a6db7463fb5937874cbfab909af70 /drivers/dma/dw | |
parent | ab703f818ac36b9e74f61b8890f14e5446b7c012 (diff) | |
download | linux-969f750fc63d3fd2f26eceedcdeca5878b785b2e.tar.bz2 |
dmaengine: dw: platform: check nr_masters to be non-zero
The value of nr_masters equal to 0 is invalid since this DMA controller has to
have at least one master.
Check this before we proceed with the rest of properties.
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to 'drivers/dma/dw')
-rw-r--r-- | drivers/dma/dw/platform.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/dma/dw/platform.c b/drivers/dma/dw/platform.c index 23616c57645c..e65ebe5ab88f 100644 --- a/drivers/dma/dw/platform.c +++ b/drivers/dma/dw/platform.c @@ -103,6 +103,7 @@ dw_dma_parse_dt(struct platform_device *pdev) struct device_node *np = pdev->dev.of_node; struct dw_dma_platform_data *pdata; u32 tmp, arr[DW_DMA_MAX_NR_MASTERS]; + u32 nr_masters; u32 nr_channels; if (!np) { @@ -110,6 +111,11 @@ dw_dma_parse_dt(struct platform_device *pdev) return NULL; } + if (of_property_read_u32(np, "dma-masters", &nr_masters)) + return NULL; + if (nr_masters < 1 || nr_masters > DW_DMA_MAX_NR_MASTERS) + return NULL; + if (of_property_read_u32(np, "dma-channels", &nr_channels)) return NULL; @@ -117,6 +123,7 @@ dw_dma_parse_dt(struct platform_device *pdev) if (!pdata) return NULL; + pdata->nr_masters = nr_masters; pdata->nr_channels = nr_channels; if (of_property_read_bool(np, "is_private")) @@ -131,17 +138,10 @@ dw_dma_parse_dt(struct platform_device *pdev) if (!of_property_read_u32(np, "block_size", &tmp)) pdata->block_size = tmp; - if (!of_property_read_u32(np, "dma-masters", &tmp)) { - if (tmp > DW_DMA_MAX_NR_MASTERS) - return NULL; - - pdata->nr_masters = tmp; - } - - if (!of_property_read_u32_array(np, "data_width", arr, - pdata->nr_masters)) - for (tmp = 0; tmp < pdata->nr_masters; tmp++) + if (!of_property_read_u32_array(np, "data_width", arr, nr_masters)) { + for (tmp = 0; tmp < nr_masters; tmp++) pdata->data_width[tmp] = arr[tmp]; + } return pdata; } |