提交 969f750f 编写于 作者: A Andy Shevchenko 提交者: Vinod Koul

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: NViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: NVinod Koul <vinod.koul@intel.com>
上级 ab703f81
...@@ -103,6 +103,7 @@ dw_dma_parse_dt(struct platform_device *pdev) ...@@ -103,6 +103,7 @@ dw_dma_parse_dt(struct platform_device *pdev)
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct dw_dma_platform_data *pdata; struct dw_dma_platform_data *pdata;
u32 tmp, arr[DW_DMA_MAX_NR_MASTERS]; u32 tmp, arr[DW_DMA_MAX_NR_MASTERS];
u32 nr_masters;
u32 nr_channels; u32 nr_channels;
if (!np) { if (!np) {
...@@ -110,6 +111,11 @@ dw_dma_parse_dt(struct platform_device *pdev) ...@@ -110,6 +111,11 @@ dw_dma_parse_dt(struct platform_device *pdev)
return NULL; 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)) if (of_property_read_u32(np, "dma-channels", &nr_channels))
return NULL; return NULL;
...@@ -117,6 +123,7 @@ dw_dma_parse_dt(struct platform_device *pdev) ...@@ -117,6 +123,7 @@ dw_dma_parse_dt(struct platform_device *pdev)
if (!pdata) if (!pdata)
return NULL; return NULL;
pdata->nr_masters = nr_masters;
pdata->nr_channels = nr_channels; pdata->nr_channels = nr_channels;
if (of_property_read_bool(np, "is_private")) if (of_property_read_bool(np, "is_private"))
...@@ -131,17 +138,10 @@ dw_dma_parse_dt(struct platform_device *pdev) ...@@ -131,17 +138,10 @@ dw_dma_parse_dt(struct platform_device *pdev)
if (!of_property_read_u32(np, "block_size", &tmp)) if (!of_property_read_u32(np, "block_size", &tmp))
pdata->block_size = tmp; pdata->block_size = tmp;
if (!of_property_read_u32(np, "dma-masters", &tmp)) { if (!of_property_read_u32_array(np, "data_width", arr, nr_masters)) {
if (tmp > DW_DMA_MAX_NR_MASTERS) for (tmp = 0; tmp < nr_masters; tmp++)
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++)
pdata->data_width[tmp] = arr[tmp]; pdata->data_width[tmp] = arr[tmp];
}
return pdata; return pdata;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册