dmaengine: dw: define DW_DMA_MAX_NR_MASTERS
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 13 Jan 2015 17:08:14 +0000 (19:08 +0200)
committerVinod Koul <vinod.koul@intel.com>
Thu, 5 Feb 2015 06:39:44 +0000 (22:39 -0800)
Instead of using magic number in the code the patch provides
DW_DMA_MAX_NR_MASTERS constant.

While here, restrict the reading of data width array by amount of the actual
number of AHB masters.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Documentation/devicetree/bindings/dma/snps-dma.txt
arch/arc/boot/dts/abilis_tb10x.dtsi
arch/arm/boot/dts/spear13xx.dtsi
arch/avr32/mach-at32ap/at32ap700x.c
drivers/dma/dw/core.c
drivers/dma/dw/platform.c
drivers/dma/dw/regs.h
include/linux/platform_data/dma-dw.h

index d58675ea1abf2e998af99b8d69f5a2b6b1b71e2a..c261598164a7612c929092ebf2876b478a1c70f6 100644 (file)
@@ -38,7 +38,7 @@ Example:
                chan_allocation_order = <1>;
                chan_priority = <1>;
                block_size = <0xfff>;
-               data_width = <3 3 0 0>;
+               data_width = <3 3>;
        };
 
 DMA clients connected to the Designware DMA controller must use the format
index a098d7c05e967461cc200fbb52d1acb51dcee966..cfb5052239a1cffdcb3f8ac3dc07537441d55bef 100644 (file)
                        chan_allocation_order = <0>;
                        chan_priority = <1>;
                        block_size = <0x7ff>;
-                       data_width = <2 0 0 0>;
+                       data_width = <2>;
                        clocks = <&ahb_clk>;
                        clock-names = "hclk";
                };
index a6eb5436d26d45f62f336b86fb0be8f06ea560bd..40accc87e3a252580c1008fa041356a40093620e 100644 (file)
                        chan_priority = <1>;
                        block_size = <0xfff>;
                        dma-masters = <2>;
-                       data_width = <3 3 0 0>;
+                       data_width = <3 3>;
                };
 
                dma@eb000000 {
                        chan_allocation_order = <1>;
                        chan_priority = <1>;
                        block_size = <0xfff>;
-                       data_width = <3 3 0 0>;
+                       data_width = <3 3>;
                };
 
                fsmc: flash@b0000000 {
index cc92cdb9994c8850f36c146d2a77f68b60d1e8a5..1d8b147282cf789498843c7817552d9959a46544 100644 (file)
@@ -607,7 +607,7 @@ static struct dw_dma_platform_data dw_dmac0_data = {
        .nr_channels    = 3,
        .block_size     = 4095U,
        .nr_masters     = 2,
-       .data_width     = { 2, 2, 0, 0 },
+       .data_width     = { 2, 2 },
 };
 
 static struct resource dw_dmac0_resource[] = {
index fcb9a916e6f65c2c06bd9a051e5afd00e5caaa0c..0469d8eda25369652d1f8375a4e121afb0f3157a 100644 (file)
@@ -1562,7 +1562,8 @@ int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)
                }
        } else {
                dw->nr_masters = pdata->nr_masters;
-               memcpy(dw->data_width, pdata->data_width, 4);
+               for (i = 0; i < dw->nr_masters; i++)
+                       dw->data_width[i] = pdata->data_width[i];
        }
 
        /* Calculate all channel mask before DMA setup */
index a630161473a4fa69c2586a257949d7f0956d4db7..aaff37f53523c21597c7fae896b32a0fdc3eb3f8 100644 (file)
@@ -99,7 +99,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[4];
+       u32 tmp, arr[DW_DMA_MAX_NR_MASTERS];
 
        if (!np) {
                dev_err(&pdev->dev, "Missing DT data\n");
@@ -126,7 +126,7 @@ dw_dma_parse_dt(struct platform_device *pdev)
                pdata->block_size = tmp;
 
        if (!of_property_read_u32(np, "dma-masters", &tmp)) {
-               if (tmp > 4)
+               if (tmp > DW_DMA_MAX_NR_MASTERS)
                        return NULL;
 
                pdata->nr_masters = tmp;
index 254a1db03680798cbd81d4a121ef33dd41a78625..241ff2b1402bf95572d053c09616414ba5eb2044 100644 (file)
@@ -285,7 +285,7 @@ struct dw_dma {
 
        /* hardware configuration */
        unsigned char           nr_masters;
-       unsigned char           data_width[4];
+       unsigned char           data_width[DW_DMA_MAX_NR_MASTERS];
 };
 
 static inline struct dw_dma_regs __iomem *__dw_regs(struct dw_dma *dw)
index 359127d290e74dd9c5ba5cb3b909472ec5e15c42..87ac14c584f2cddb11f173aed3e8c92000813119 100644 (file)
@@ -13,6 +13,8 @@
 
 #include <linux/device.h>
 
+#define DW_DMA_MAX_NR_MASTERS  4
+
 /**
  * struct dw_dma_slave - Controller-specific information about a slave
  *
@@ -53,7 +55,7 @@ struct dw_dma_platform_data {
        unsigned char   chan_priority;
        unsigned short  block_size;
        unsigned char   nr_masters;
-       unsigned char   data_width[4];
+       unsigned char   data_width[DW_DMA_MAX_NR_MASTERS];
 };
 
 #endif /* _PLATFORM_DATA_DMA_DW_H */