linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2 0/6] dmaengine: introduce is_slave_xfer helper
@ 2012-11-16 15:51 Andy Shevchenko
  2012-11-16 15:52 ` [PATCHv2 1/6] dmaengine: introduce is_slave_xfer function Andy Shevchenko
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Andy Shevchenko @ 2012-11-16 15:51 UTC (permalink / raw)
  To: Vinod Koul, spear-devel, linux-kernel, Viresh Kumar; +Cc: Andy Shevchenko

There is a common practice to distinguish slave type transfers by checking
direction of the channel. This series introduces the check helper and its usage
across the drivers.

Since v1:
 - append commit messages to the all patches
 - update description for the patches against dw_dmac and at_hdmac
 - apply all current Reviewed-by and Acked-by tags

Andy Shevchenko (6):
  dmaengine: introduce is_slave_xfer function
  dma: at_hdmac: check direction properly for cyclic transfers
  dma: dw_dmac: check direction properly in dw_dma_cyclic_prep
  dma: ep93xx_dma: reuse is_slave_xfer helper
  dma: ipu_idmac: reuse is_slave_xfer helper
  dma: ste_dma40: reuse is_slave_xfer helper

 drivers/dma/at_hdmac.c      |   10 +++++-----
 drivers/dma/dw_dmac.c       |    5 +++--
 drivers/dma/ep93xx_dma.c    |    3 +--
 drivers/dma/ipu/ipu_idmac.c |    2 +-
 drivers/dma/ste_dma40.c     |    2 +-
 include/linux/dmaengine.h   |    5 +++++
 6 files changed, 16 insertions(+), 11 deletions(-)

-- 
1.7.10.4


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCHv2 1/6] dmaengine: introduce is_slave_xfer function
  2012-11-16 15:51 [PATCHv2 0/6] dmaengine: introduce is_slave_xfer helper Andy Shevchenko
@ 2012-11-16 15:52 ` Andy Shevchenko
  2012-11-20 22:03   ` Linus Walleij
  2012-11-16 15:52 ` [PATCHv2 2/6] dma: at_hdmac: check direction properly for cyclic transfers Andy Shevchenko
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 9+ messages in thread
From: Andy Shevchenko @ 2012-11-16 15:52 UTC (permalink / raw)
  To: Vinod Koul, spear-devel, linux-kernel, Viresh Kumar
  Cc: Andy Shevchenko, Nicolas Ferre, Guennadi Liakhovetski, Linus Walleij

This function helps to distinguish the slave type of transfer by checking the
direction parameter.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
---
 include/linux/dmaengine.h |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 6402b18..3e1a9026 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -618,6 +618,11 @@ static inline int dmaengine_slave_config(struct dma_chan *chan,
 			(unsigned long)config);
 }
 
+static inline bool is_slave_xfer(enum dma_transfer_direction direction)
+{
+	return (direction == DMA_MEM_TO_DEV) || (direction == DMA_DEV_TO_MEM);
+}
+
 static inline struct dma_async_tx_descriptor *dmaengine_prep_slave_single(
 	struct dma_chan *chan, dma_addr_t buf, size_t len,
 	enum dma_transfer_direction dir, unsigned long flags)
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCHv2 2/6] dma: at_hdmac: check direction properly for cyclic transfers
  2012-11-16 15:51 [PATCHv2 0/6] dmaengine: introduce is_slave_xfer helper Andy Shevchenko
  2012-11-16 15:52 ` [PATCHv2 1/6] dmaengine: introduce is_slave_xfer function Andy Shevchenko
@ 2012-11-16 15:52 ` Andy Shevchenko
  2012-11-16 15:52 ` [PATCHv2 3/6] dma: dw_dmac: check direction properly in dw_dma_cyclic_prep Andy Shevchenko
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2012-11-16 15:52 UTC (permalink / raw)
  To: Vinod Koul, spear-devel, linux-kernel, Viresh Kumar; +Cc: Andy Shevchenko

dma_transfer_direction is a normal enum. It means we can't usually use the
values as bit fields. Let's adjust this check and move it above the usage of
the direction parameter, due to the nature of the following usage of it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
---
 drivers/dma/at_hdmac.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index 13a02f4..997ae54 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -778,7 +778,7 @@ err:
  */
 static int
 atc_dma_cyclic_check_values(unsigned int reg_width, dma_addr_t buf_addr,
-		size_t period_len, enum dma_transfer_direction direction)
+		size_t period_len)
 {
 	if (period_len > (ATC_BTSIZE_MAX << reg_width))
 		goto err_out;
@@ -786,8 +786,6 @@ atc_dma_cyclic_check_values(unsigned int reg_width, dma_addr_t buf_addr,
 		goto err_out;
 	if (unlikely(buf_addr & ((1 << reg_width) - 1)))
 		goto err_out;
-	if (unlikely(!(direction & (DMA_DEV_TO_MEM | DMA_MEM_TO_DEV))))
-		goto err_out;
 
 	return 0;
 
@@ -886,14 +884,16 @@ atc_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len,
 		return NULL;
 	}
 
+	if (unlikely(!is_slave_xfer(direction)))
+		goto err_out;
+
 	if (sconfig->direction == DMA_MEM_TO_DEV)
 		reg_width = convert_buswidth(sconfig->dst_addr_width);
 	else
 		reg_width = convert_buswidth(sconfig->src_addr_width);
 
 	/* Check for too big/unaligned periods and unaligned DMA buffer */
-	if (atc_dma_cyclic_check_values(reg_width, buf_addr,
-					period_len, direction))
+	if (atc_dma_cyclic_check_values(reg_width, buf_addr, period_len))
 		goto err_out;
 
 	/* build cyclic linked list */
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCHv2 3/6] dma: dw_dmac: check direction properly in dw_dma_cyclic_prep
  2012-11-16 15:51 [PATCHv2 0/6] dmaengine: introduce is_slave_xfer helper Andy Shevchenko
  2012-11-16 15:52 ` [PATCHv2 1/6] dmaengine: introduce is_slave_xfer function Andy Shevchenko
  2012-11-16 15:52 ` [PATCHv2 2/6] dma: at_hdmac: check direction properly for cyclic transfers Andy Shevchenko
@ 2012-11-16 15:52 ` Andy Shevchenko
  2012-11-16 15:52 ` [PATCHv2 4/6] dma: ep93xx_dma: reuse is_slave_xfer helper Andy Shevchenko
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2012-11-16 15:52 UTC (permalink / raw)
  To: Vinod Koul, spear-devel, linux-kernel, Viresh Kumar; +Cc: Andy Shevchenko

dma_transfer_direction is a normal enum. It means we can't usually use the
values as bit fields. Let's adjust this check and move it above the usage of
the direction parameter, due to the nature of the following usage of it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/dma/dw_dmac.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index a4a5c80..5e2c4dc 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -1336,6 +1336,9 @@ struct dw_cyclic_desc *dw_dma_cyclic_prep(struct dma_chan *chan,
 
 	retval = ERR_PTR(-EINVAL);
 
+	if (unlikely(!is_slave_xfer(direction)))
+		goto out_err;
+
 	if (direction == DMA_MEM_TO_DEV)
 		reg_width = __ffs(sconfig->dst_addr_width);
 	else
@@ -1350,8 +1353,6 @@ struct dw_cyclic_desc *dw_dma_cyclic_prep(struct dma_chan *chan,
 		goto out_err;
 	if (unlikely(buf_addr & ((1 << reg_width) - 1)))
 		goto out_err;
-	if (unlikely(!(direction & (DMA_MEM_TO_DEV | DMA_DEV_TO_MEM))))
-		goto out_err;
 
 	retval = ERR_PTR(-ENOMEM);
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCHv2 4/6] dma: ep93xx_dma: reuse is_slave_xfer helper
  2012-11-16 15:51 [PATCHv2 0/6] dmaengine: introduce is_slave_xfer helper Andy Shevchenko
                   ` (2 preceding siblings ...)
  2012-11-16 15:52 ` [PATCHv2 3/6] dma: dw_dmac: check direction properly in dw_dma_cyclic_prep Andy Shevchenko
@ 2012-11-16 15:52 ` Andy Shevchenko
  2012-11-16 15:52 ` [PATCHv2 5/6] dma: ipu_idmac: " Andy Shevchenko
  2012-11-16 15:52 ` [PATCHv2 6/6] dma: ste_dma40: " Andy Shevchenko
  5 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2012-11-16 15:52 UTC (permalink / raw)
  To: Vinod Koul, spear-devel, linux-kernel, Viresh Kumar; +Cc: Andy Shevchenko

The is_slave_xfer helps to check if the transfer type is slave.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/dma/ep93xx_dma.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/dma/ep93xx_dma.c b/drivers/dma/ep93xx_dma.c
index bcfde40..a2f1d9f 100644
--- a/drivers/dma/ep93xx_dma.c
+++ b/drivers/dma/ep93xx_dma.c
@@ -903,8 +903,7 @@ static int ep93xx_dma_alloc_chan_resources(struct dma_chan *chan)
 			switch (data->port) {
 			case EP93XX_DMA_SSP:
 			case EP93XX_DMA_IDE:
-				if (data->direction != DMA_MEM_TO_DEV &&
-				    data->direction != DMA_DEV_TO_MEM)
+				if (!is_slave_xfer(data->direction))
 					return -EINVAL;
 				break;
 			default:
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCHv2 5/6] dma: ipu_idmac: reuse is_slave_xfer helper
  2012-11-16 15:51 [PATCHv2 0/6] dmaengine: introduce is_slave_xfer helper Andy Shevchenko
                   ` (3 preceding siblings ...)
  2012-11-16 15:52 ` [PATCHv2 4/6] dma: ep93xx_dma: reuse is_slave_xfer helper Andy Shevchenko
@ 2012-11-16 15:52 ` Andy Shevchenko
  2012-11-16 15:52 ` [PATCHv2 6/6] dma: ste_dma40: " Andy Shevchenko
  5 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2012-11-16 15:52 UTC (permalink / raw)
  To: Vinod Koul, spear-devel, linux-kernel, Viresh Kumar
  Cc: Andy Shevchenko, Guennadi Liakhovetski

The is_slave_xfer helps to check if the transfer type is slave.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
 drivers/dma/ipu/ipu_idmac.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/ipu/ipu_idmac.c b/drivers/dma/ipu/ipu_idmac.c
index 6585537..c8d0254 100644
--- a/drivers/dma/ipu/ipu_idmac.c
+++ b/drivers/dma/ipu/ipu_idmac.c
@@ -1347,7 +1347,7 @@ static struct dma_async_tx_descriptor *idmac_prep_slave_sg(struct dma_chan *chan
 	    chan->chan_id != IDMAC_IC_7)
 		return NULL;
 
-	if (direction != DMA_DEV_TO_MEM && direction != DMA_MEM_TO_DEV) {
+	if (!is_slave_xfer(direction)) {
 		dev_err(chan->device->dev, "Invalid DMA direction %d!\n", direction);
 		return NULL;
 	}
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCHv2 6/6] dma: ste_dma40: reuse is_slave_xfer helper
  2012-11-16 15:51 [PATCHv2 0/6] dmaengine: introduce is_slave_xfer helper Andy Shevchenko
                   ` (4 preceding siblings ...)
  2012-11-16 15:52 ` [PATCHv2 5/6] dma: ipu_idmac: " Andy Shevchenko
@ 2012-11-16 15:52 ` Andy Shevchenko
  2012-11-20 22:04   ` Linus Walleij
  5 siblings, 1 reply; 9+ messages in thread
From: Andy Shevchenko @ 2012-11-16 15:52 UTC (permalink / raw)
  To: Vinod Koul, spear-devel, linux-kernel, Viresh Kumar
  Cc: Andy Shevchenko, Linus Walleij

The is_slave_xfer helps to check if the transfer type is slave.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/dma/ste_dma40.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 23c5573..9f4fdf4 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -2337,7 +2337,7 @@ static struct dma_async_tx_descriptor *d40_prep_slave_sg(struct dma_chan *chan,
 							 unsigned long dma_flags,
 							 void *context)
 {
-	if (direction != DMA_DEV_TO_MEM && direction != DMA_MEM_TO_DEV)
+	if (!is_slave_xfer(direction))
 		return NULL;
 
 	return d40_prep_sg(chan, sgl, sgl, sg_len, direction, dma_flags);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCHv2 1/6] dmaengine: introduce is_slave_xfer function
  2012-11-16 15:52 ` [PATCHv2 1/6] dmaengine: introduce is_slave_xfer function Andy Shevchenko
@ 2012-11-20 22:03   ` Linus Walleij
  0 siblings, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2012-11-20 22:03 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Vinod Koul, spear-devel, linux-kernel, Viresh Kumar,
	Nicolas Ferre, Guennadi Liakhovetski

On Fri, Nov 16, 2012 at 4:52 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> This function helps to distinguish the slave type of transfer by checking the
> direction parameter.

Looks like a good idea.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCHv2 6/6] dma: ste_dma40: reuse is_slave_xfer helper
  2012-11-16 15:52 ` [PATCHv2 6/6] dma: ste_dma40: " Andy Shevchenko
@ 2012-11-20 22:04   ` Linus Walleij
  0 siblings, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2012-11-20 22:04 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Vinod Koul, spear-devel, linux-kernel, Viresh Kumar

On Fri, Nov 16, 2012 at 4:52 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> The is_slave_xfer helps to check if the transfer type is slave.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
> Cc: Linus Walleij <linus.walleij@linaro.org>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-11-20 22:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-16 15:51 [PATCHv2 0/6] dmaengine: introduce is_slave_xfer helper Andy Shevchenko
2012-11-16 15:52 ` [PATCHv2 1/6] dmaengine: introduce is_slave_xfer function Andy Shevchenko
2012-11-20 22:03   ` Linus Walleij
2012-11-16 15:52 ` [PATCHv2 2/6] dma: at_hdmac: check direction properly for cyclic transfers Andy Shevchenko
2012-11-16 15:52 ` [PATCHv2 3/6] dma: dw_dmac: check direction properly in dw_dma_cyclic_prep Andy Shevchenko
2012-11-16 15:52 ` [PATCHv2 4/6] dma: ep93xx_dma: reuse is_slave_xfer helper Andy Shevchenko
2012-11-16 15:52 ` [PATCHv2 5/6] dma: ipu_idmac: " Andy Shevchenko
2012-11-16 15:52 ` [PATCHv2 6/6] dma: ste_dma40: " Andy Shevchenko
2012-11-20 22:04   ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).