Skip to content

Commit d6ff82c

Browse files
andy-shevvinodkoul
authored andcommitted
dmaengine: dw: Simplify DT property parser
Since we converted internal data types to match DT, there is no need to have an intermediate conversion layer, hence drop a few conditionals and for loops for good. Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Serge Semin <[email protected]> Tested-by: Serge Semin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 08bf54f commit d6ff82c

File tree

1 file changed

+16
-28
lines changed

1 file changed

+16
-28
lines changed

drivers/dma/dw/of.c

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct dw_dma_platform_data *dw_dma_parse_dt(struct platform_device *pdev)
5050
{
5151
struct device_node *np = pdev->dev.of_node;
5252
struct dw_dma_platform_data *pdata;
53-
u32 tmp, arr[DW_DMA_MAX_NR_MASTERS], mb[DW_DMA_MAX_NR_CHANNELS];
53+
u32 tmp, arr[DW_DMA_MAX_NR_MASTERS];
5454
u32 nr_masters;
5555
u32 nr_channels;
5656

@@ -71,41 +71,29 @@ struct dw_dma_platform_data *dw_dma_parse_dt(struct platform_device *pdev)
7171
pdata->nr_masters = nr_masters;
7272
pdata->nr_channels = nr_channels;
7373

74-
if (!of_property_read_u32(np, "chan_allocation_order", &tmp))
75-
pdata->chan_allocation_order = (unsigned char)tmp;
74+
of_property_read_u32(np, "chan_allocation_order", &pdata->chan_allocation_order);
75+
of_property_read_u32(np, "chan_priority", &pdata->chan_priority);
7676

77-
if (!of_property_read_u32(np, "chan_priority", &tmp))
78-
pdata->chan_priority = tmp;
77+
of_property_read_u32(np, "block_size", &pdata->block_size);
7978

80-
if (!of_property_read_u32(np, "block_size", &tmp))
81-
pdata->block_size = tmp;
82-
83-
if (!of_property_read_u32_array(np, "data-width", arr, nr_masters)) {
84-
for (tmp = 0; tmp < nr_masters; tmp++)
85-
pdata->data_width[tmp] = arr[tmp];
86-
} else if (!of_property_read_u32_array(np, "data_width", arr, nr_masters)) {
79+
/* Try deprecated property first */
80+
if (!of_property_read_u32_array(np, "data_width", arr, nr_masters)) {
8781
for (tmp = 0; tmp < nr_masters; tmp++)
8882
pdata->data_width[tmp] = BIT(arr[tmp] & 0x07);
8983
}
9084

91-
if (!of_property_read_u32_array(np, "multi-block", mb, nr_channels)) {
92-
for (tmp = 0; tmp < nr_channels; tmp++)
93-
pdata->multi_block[tmp] = mb[tmp];
94-
} else {
95-
for (tmp = 0; tmp < nr_channels; tmp++)
96-
pdata->multi_block[tmp] = 1;
97-
}
85+
/* If "data_width" and "data-width" both provided use the latter one */
86+
of_property_read_u32_array(np, "data-width", pdata->data_width, nr_masters);
9887

99-
if (of_property_read_u32_array(np, "snps,max-burst-len", pdata->max_burst,
100-
nr_channels)) {
101-
memset32(pdata->max_burst, DW_DMA_MAX_BURST, nr_channels);
102-
}
88+
memset32(pdata->multi_block, 1, nr_channels);
89+
of_property_read_u32_array(np, "multi-block", pdata->multi_block, nr_channels);
10390

104-
if (!of_property_read_u32(np, "snps,dma-protection-control", &tmp)) {
105-
if (tmp > CHAN_PROTCTL_MASK)
106-
return NULL;
107-
pdata->protctl = tmp;
108-
}
91+
memset32(pdata->max_burst, DW_DMA_MAX_BURST, nr_channels);
92+
of_property_read_u32_array(np, "snps,max-burst-len", pdata->max_burst, nr_channels);
93+
94+
of_property_read_u32(np, "snps,dma-protection-control", &pdata->protctl);
95+
if (pdata->protctl > CHAN_PROTCTL_MASK)
96+
return NULL;
10997

11098
return pdata;
11199
}

0 commit comments

Comments
 (0)