dmaengine: dw: Remove error message from DT parsing code
Subsystems (2)
Andy Shevchenko
reviewerPATCH 1/3 dmaengine: dw: Remove error message from DT parsing code
Users are a bit frightened of the harmless message that tells that DT is missed on ACPI-based platforms. Remove it for good, it will simplify the future conversion to fwnode and device property APIs.
Depends-on: f5e84eae7956 ("dmaengine: dw: platform: Split OF helpers to separate module")
--- drivers/dma/dw/of.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/dma/dw/of.c +0 -5
@@ -54,11 +54,6 @@ struct dw_dma_platform_data *dw_dma_parse_dt(struct platform_device *pdev)u32 nr_masters;u32 nr_channels; -if (!np) { -dev_err (&pdev->dev,"Missing DT data\n" ); -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 )
Signature · 1 line
2.30.2
Andy Shevchenko
reviewerPATCH 2/3 dmaengine: dw: Convert members to u32 in platform data
u32 is a type that is used for properties retrieval from DT. With the type change it allows to clean up properties reading routine.
While at it, order the fields in way how they are parsed.
--- include/linux/platform_data/dma-dw.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
include/linux/platform_data/dma-dw.h +10 -10
@@ -41,11 +41,11 @@ struct dw_dma_slave {/** * struct dw_dma_platform_data - Controller configuration parameters +* @nr_masters: Number of AHB masters supported by the controller * @nr_channels: Number of channels supported by hardware (max 8) * @chan_allocation_order: Allocate channels starting from 0 or 7 * @chan_priority: Set channel priority increasing from 0 to 7 or 7 to 0. * @block_size: Maximum block size supported by the controller -* @nr_masters: Number of AHB masters supported by the controller * @data_width: Maximum data width supported by hardware per AHB master * (in bytes, power of 2) * @multi_block: Multi block transfers supported by hardware per channel.
@@ -55,25 +55,25 @@ struct dw_dma_slave {* @quirks: Optional platform quirks. */ struct dw_dma_platform_data { -unsigned int nr_channels; +u32 nr_masters; +u32 nr_channels;#define CHAN_ALLOCATION_ASCENDING 0/* zero to seven */ #define CHAN_ALLOCATION_DESCENDING 1/* seven to zero */ -unsigned char chan_allocation_order; +u32 chan_allocation_order;#define CHAN_PRIORITY_ASCENDING 0/* chan0 highest */ #define CHAN_PRIORITY_DESCENDING 1/* chan7 highest */ -unsigned char chan_priority; -unsigned int block_size; -unsigned char nr_masters; -unsigned char data_width[DW_DMA_MAX_NR_MASTERS ]; -unsigned char multi_block[DW_DMA_MAX_NR_CHANNELS ]; +u32 chan_priority; +u32 block_size; +u32 data_width[DW_DMA_MAX_NR_MASTERS ]; +u32 multi_block[DW_DMA_MAX_NR_CHANNELS ];u32 max_burst[DW_DMA_MAX_NR_CHANNELS ];#define CHAN_PROTCTL_PRIVILEGED BIT(0)#define CHAN_PROTCTL_BUFFERABLE BIT(1)#define CHAN_PROTCTL_CACHEABLE BIT(2)#define CHAN_PROTCTL_MASK GENMASK(2, 0) -unsigned char protctl; +u32 protctl;#define DW_DMA_QUIRK_XBAR_PRESENT BIT(0) -unsigned int quirks; +u32 quirks; };#endif /* _PLATFORM_DATA_DMA_DW_H */
Signature · 1 line
2.30.2
Andy Shevchenko
reviewerPATCH 3/3 dmaengine: dw: Simplify DT property parser
In reply to Andy ShevchenkoSince 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.
--- drivers/dma/dw/of.c | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-)
drivers/dma/dw/of.c +16 -28
@@ -50,7 +50,7 @@ struct dw_dma_platform_data *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 ], mb[DW_DMA_MAX_NR_CHANNELS ]; +u32 tmp, arr[DW_DMA_MAX_NR_MASTERS ];u32 nr_masters;u32 nr_channels;
@@ -71,41 +71,29 @@ struct dw_dma_platform_data *dw_dma_parse_dt(struct platform_device *pdev) pdata->nr_masters = nr_masters; pdata->nr_channels = nr_channels; -if (!of_property_read_u32 (np,"chan_allocation_order" , &tmp)) - pdata->chan_allocation_order = (unsigned char )tmp; +of_property_read_u32 (np,"chan_allocation_order" , &pdata->chan_allocation_order); +of_property_read_u32 (np,"chan_priority" , &pdata->chan_priority); -if (!of_property_read_u32 (np,"chan_priority" , &tmp)) - pdata->chan_priority = tmp; +of_property_read_u32 (np,"block_size" , &pdata->block_size); -if (!of_property_read_u32 (np,"block_size" , &tmp)) - pdata->block_size = 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]; - }else if (!of_property_read_u32_array (np,"data_width" , arr, nr_masters)) { +/* Try deprecated property first */ +if (!of_property_read_u32_array (np,"data_width" , arr, nr_masters)) {for (tmp =0 ; tmp < nr_masters; tmp++) pdata->data_width[tmp] =BIT (arr[tmp] &0x07 ); } -if (!of_property_read_u32_array (np,"multi-block" , mb, nr_channels)) { -for (tmp =0 ; tmp < nr_channels; tmp++) - pdata->multi_block[tmp] = mb[tmp]; - }else { -for (tmp =0 ; tmp < nr_channels; tmp++) - pdata->multi_block[tmp] =1 ; - } +/* If "data_width" and "data-width" both provided use the latter one */ +of_property_read_u32_array (np,"data-width" , pdata->data_width, nr_masters); -if (of_property_read_u32_array (np,"snps,max-burst-len" , pdata->max_burst, - nr_channels)) { -memset32 (pdata->max_burst,DW_DMA_MAX_BURST , nr_channels); - } +memset32 (pdata->multi_block,1 , nr_channels); +of_property_read_u32_array (np,"multi-block" , pdata->multi_block, nr_channels); -if (!of_property_read_u32 (np,"snps,dma-protection-control" , &tmp)) { -if (tmp >CHAN_PROTCTL_MASK ) -return NULL ; - pdata->protctl = tmp; - } +memset32 (pdata->max_burst,DW_DMA_MAX_BURST , nr_channels); +of_property_read_u32_array (np,"snps,max-burst-len" , pdata->max_burst, nr_channels); + +of_property_read_u32 (np,"snps,dma-protection-control" , &pdata->protctl); +if (pdata->protctl >CHAN_PROTCTL_MASK ) +return NULL ;return pdata; }
Signature · 1 line
2.30.2
Hello Andy
Quoted 3 lines · Andy Shevchenko
Users are a bit frightened of the harmless message that tells that DT is missed on ACPI-based platforms. Remove it for good, it will simplify the future conversion to fwnode and device property APIs.
Thanks for the cleanup patchset. No comments from me, just the tags for the whole series:
[Tested on Baikal-T1 DW DMAC with 8 channels, 12 requests, 2 masters, no multi-block support and uneven max burst length setup]
-Sergey
Quoted 28 lines
Fixes a9ddb575d6d6 ("dmaengine: dw_dmac: Enhance device tree support")Depends-on:
f5e84eae7956("dmaengine: dw: platform: Split OF helpers to separate module")Signed-off-by Andy Shevchenko <[email protected]>--- drivers/dma/dw/of.c | 5 ----- 1 file changed, 5 deletions(-)drivers/dma/dw/of.c +0
-5@@ -54,11 +54,6 @@ struct dw_dma_platform_data *dw_dma_parse_dt(struct platform_device *pdev)u32 nr_masters;u32 nr_channels; -if (!np) { -dev_err (&pdev->dev,"Missing DT data\n" ); -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 )Signature · 1 line
2.30.2
Quoted 11 lines · Serge Semin
Quoted 3 lines · Andy Shevchenko
Users are a bit frightened of the harmless message that tells that DT is missed on ACPI-based platforms. Remove it for good, it will simplify the future conversion to fwnode and device property APIs.
Thanks for the cleanup patchset. No comments from me, just the tags for the whole series:
Reviewed-by Serge Semin <[email protected]>Tested-by Serge Semin <[email protected]>[Tested on Baikal-T1 DW DMAC with 8 channels, 12 requests, 2 masters, no multi-block support and uneven max burst length setup]
Thank you, appreciate it!
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 3 lines · Andy Shevchenko
Users are a bit frightened of the harmless message that tells that DT is missed on ACPI-based platforms. Remove it for good, it will simplify the future conversion to fwnode and device property APIs.
Applied all, thanks
Signature · 1 line
~Vinod