All of lore.kernel.org
 help / color / mirror / Atom feed
From: stillcompiling@gmail.com (Joshua Clayton)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 06/10] dma: imx-sdma: config in sdma_config_channel()
Date: Mon, 15 Jun 2015 09:19:01 -0700	[thread overview]
Message-ID: <1434385144-4432-7-git-send-email-stillcompiling@gmail.com> (raw)
In-Reply-To: <1434385144-4432-1-git-send-email-stillcompiling@gmail.com>

Move functionality that is part of sdma_config_channel()
from the switch statement into the function itself.
This puts code together that belongs together, and
gets rid of a single use variable in struct sdma_channel

Signed-off-by: Joshua Clayton <stillcompiling@gmail.com>
---
 drivers/dma/imx-sdma.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index 8358a1a..a13383b 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -258,7 +258,6 @@ struct sdma_channel {
 	struct sdma_buffer_descriptor	*bd;
 	dma_addr_t			bd_phys;
 	unsigned long			flags;
-	dma_addr_t			per_address;
 	unsigned long			event_mask[2];
 	unsigned long			watermark_level;
 	u32				shp_addr, per_addr;
@@ -840,12 +839,26 @@ static void sdma_disable_channel(struct sdma_engine *sdma, int channel)
 	sdma->channel[channel].status = DMA_ERROR;
 }
 
-static int sdma_config_channel(struct sdma_channel *sdmac)
+static int sdma_config_channel(struct sdma_channel *sdmac,
+		struct dma_slave_config *dmaengine_cfg)
 {
 	int ret;
 	int channel = sdmac->channel;
 	struct sdma_engine *sdma = to_sdma_engine(sdmac);
+	dma_addr_t per_address;
 
+	if (dmaengine_cfg->direction == DMA_DEV_TO_MEM) {
+		per_address = dmaengine_cfg->src_addr;
+		sdmac->watermark_level = dmaengine_cfg->src_maxburst *
+					dmaengine_cfg->src_addr_width;
+		sdmac->word_size = dmaengine_cfg->src_addr_width;
+	} else {
+		per_address = dmaengine_cfg->dst_addr;
+		sdmac->watermark_level = dmaengine_cfg->dst_maxburst *
+					dmaengine_cfg->dst_addr_width;
+		sdmac->word_size = dmaengine_cfg->dst_addr_width;
+	}
+	sdmac->direction = dmaengine_cfg->direction;
 	sdma_disable_channel(sdma, channel);
 
 	sdmac->event_mask[0] = 0;
@@ -887,7 +900,7 @@ static int sdma_config_channel(struct sdma_channel *sdmac)
 		/* Watermark Level */
 		sdmac->watermark_level |= sdmac->watermark_level;
 		/* Address */
-		sdmac->shp_addr = sdmac->per_address;
+		sdmac->shp_addr = per_address;
 	} else {
 		sdmac->watermark_level = 0; /* FIXME: M3_BASE_ADDRESS */
 	}
@@ -1215,19 +1228,7 @@ static int sdma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
 		sdma_disable_channel(sdma, sdmac->channel);
 		return 0;
 	case DMA_SLAVE_CONFIG:
-		if (dmaengine_cfg->direction == DMA_DEV_TO_MEM) {
-			sdmac->per_address = dmaengine_cfg->src_addr;
-			sdmac->watermark_level = dmaengine_cfg->src_maxburst *
-						dmaengine_cfg->src_addr_width;
-			sdmac->word_size = dmaengine_cfg->src_addr_width;
-		} else {
-			sdmac->per_address = dmaengine_cfg->dst_addr;
-			sdmac->watermark_level = dmaengine_cfg->dst_maxburst *
-						dmaengine_cfg->dst_addr_width;
-			sdmac->word_size = dmaengine_cfg->dst_addr_width;
-		}
-		sdmac->direction = dmaengine_cfg->direction;
-		return sdma_config_channel(sdmac);
+		return sdma_config_channel(sdmac, dmaengine_cfg);
 	default:
 		return -ENOSYS;
 	}
-- 
2.1.4

WARNING: multiple messages have this Message-ID (diff)
From: Joshua Clayton <stillcompiling@gmail.com>
To: Vinod Koul <vinod.koul@intel.com>
Cc: Joshua Clayton <stillcompiling@gmail.com>,
	Dan Williams <dan.j.williams@intel.com>,
	dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Shawn Guo <shawn.guo@linaro.org>
Subject: [PATCH 06/10] dma: imx-sdma: config in sdma_config_channel()
Date: Mon, 15 Jun 2015 09:19:01 -0700	[thread overview]
Message-ID: <1434385144-4432-7-git-send-email-stillcompiling@gmail.com> (raw)
In-Reply-To: <1434385144-4432-1-git-send-email-stillcompiling@gmail.com>

Move functionality that is part of sdma_config_channel()
from the switch statement into the function itself.
This puts code together that belongs together, and
gets rid of a single use variable in struct sdma_channel

Signed-off-by: Joshua Clayton <stillcompiling@gmail.com>
---
 drivers/dma/imx-sdma.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index 8358a1a..a13383b 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -258,7 +258,6 @@ struct sdma_channel {
 	struct sdma_buffer_descriptor	*bd;
 	dma_addr_t			bd_phys;
 	unsigned long			flags;
-	dma_addr_t			per_address;
 	unsigned long			event_mask[2];
 	unsigned long			watermark_level;
 	u32				shp_addr, per_addr;
@@ -840,12 +839,26 @@ static void sdma_disable_channel(struct sdma_engine *sdma, int channel)
 	sdma->channel[channel].status = DMA_ERROR;
 }
 
-static int sdma_config_channel(struct sdma_channel *sdmac)
+static int sdma_config_channel(struct sdma_channel *sdmac,
+		struct dma_slave_config *dmaengine_cfg)
 {
 	int ret;
 	int channel = sdmac->channel;
 	struct sdma_engine *sdma = to_sdma_engine(sdmac);
+	dma_addr_t per_address;
 
+	if (dmaengine_cfg->direction == DMA_DEV_TO_MEM) {
+		per_address = dmaengine_cfg->src_addr;
+		sdmac->watermark_level = dmaengine_cfg->src_maxburst *
+					dmaengine_cfg->src_addr_width;
+		sdmac->word_size = dmaengine_cfg->src_addr_width;
+	} else {
+		per_address = dmaengine_cfg->dst_addr;
+		sdmac->watermark_level = dmaengine_cfg->dst_maxburst *
+					dmaengine_cfg->dst_addr_width;
+		sdmac->word_size = dmaengine_cfg->dst_addr_width;
+	}
+	sdmac->direction = dmaengine_cfg->direction;
 	sdma_disable_channel(sdma, channel);
 
 	sdmac->event_mask[0] = 0;
@@ -887,7 +900,7 @@ static int sdma_config_channel(struct sdma_channel *sdmac)
 		/* Watermark Level */
 		sdmac->watermark_level |= sdmac->watermark_level;
 		/* Address */
-		sdmac->shp_addr = sdmac->per_address;
+		sdmac->shp_addr = per_address;
 	} else {
 		sdmac->watermark_level = 0; /* FIXME: M3_BASE_ADDRESS */
 	}
@@ -1215,19 +1228,7 @@ static int sdma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
 		sdma_disable_channel(sdma, sdmac->channel);
 		return 0;
 	case DMA_SLAVE_CONFIG:
-		if (dmaengine_cfg->direction == DMA_DEV_TO_MEM) {
-			sdmac->per_address = dmaengine_cfg->src_addr;
-			sdmac->watermark_level = dmaengine_cfg->src_maxburst *
-						dmaengine_cfg->src_addr_width;
-			sdmac->word_size = dmaengine_cfg->src_addr_width;
-		} else {
-			sdmac->per_address = dmaengine_cfg->dst_addr;
-			sdmac->watermark_level = dmaengine_cfg->dst_maxburst *
-						dmaengine_cfg->dst_addr_width;
-			sdmac->word_size = dmaengine_cfg->dst_addr_width;
-		}
-		sdmac->direction = dmaengine_cfg->direction;
-		return sdma_config_channel(sdmac);
+		return sdma_config_channel(sdmac, dmaengine_cfg);
 	default:
 		return -ENOSYS;
 	}
-- 
2.1.4


  parent reply	other threads:[~2015-06-15 16:19 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-15 16:18 [PATCH 00/10] imx-sdma cleanup Joshua Clayton
2015-06-15 16:18 ` Joshua Clayton
2015-06-15 16:18 ` [PATCH 01/10] dma: imx-sdma: constify local structs Joshua Clayton
2015-06-15 16:18   ` Joshua Clayton
2015-06-15 16:18 ` [PATCH 02/10] dma: imx-sdma: pass sdma engine into functions Joshua Clayton
2015-06-15 16:18   ` Joshua Clayton
2015-06-15 16:18 ` [PATCH 03/10] dma: imx-sdma: use a container_of function Joshua Clayton
2015-06-15 16:18   ` Joshua Clayton
2015-06-15 16:18 ` [PATCH 04/10] dma: sdma-imx set dma script address directly Joshua Clayton
2015-06-15 16:18   ` Joshua Clayton
2015-06-15 16:19 ` [PATCH 05/10] dma: sdma-imx: print an error when context load fails Joshua Clayton
2015-06-15 16:19   ` Joshua Clayton
2015-06-15 16:19 ` Joshua Clayton [this message]
2015-06-15 16:19   ` [PATCH 06/10] dma: imx-sdma: config in sdma_config_channel() Joshua Clayton
2015-06-15 16:19 ` [PATCH 07/10] dma: imx-sdma: validate word size when set Joshua Clayton
2015-06-15 16:19   ` Joshua Clayton
2015-06-15 16:19 ` [PATCH 08/10] dma: imx-sdma: extract common sdma prep code Joshua Clayton
2015-06-15 16:19   ` Joshua Clayton
2015-06-15 16:19 ` [PATCH 09/10] dma: imx-sdma: use a for loop Joshua Clayton
2015-06-15 16:19   ` Joshua Clayton
2015-06-16 14:57 ` [PATCH 00/10] imx-sdma cleanup Joshua Clayton
2015-06-16 14:57   ` Joshua Clayton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1434385144-4432-7-git-send-email-stillcompiling@gmail.com \
    --to=stillcompiling@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.