All of lore.kernel.org
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 7/9] DMA: PL08x: cleanup selection of buswidth
Date: Tue, 05 Jul 2011 14:12:51 +0100	[thread overview]
Message-ID: <E1Qe5Qp-0005Na-Rt@rmk-PC.arm.linux.org.uk> (raw)
In-Reply-To: <20110705131030.GE8286@n2100.arm.linux.org.uk>

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 drivers/dma/amba-pl08x.c |   34 +++++++++++++++++++---------------
 1 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c
index cb17d92..985bc29 100644
--- a/drivers/dma/amba-pl08x.c
+++ b/drivers/dma/amba-pl08x.c
@@ -1105,13 +1105,26 @@ static u32 pl08x_cctl(u32 cctl)
 	return cctl | PL080_CONTROL_PROT_SYS;
 }
 
+static u32 pl08x_width(enum dma_slave_buswidth width)
+{
+	switch (width) {
+	case DMA_SLAVE_BUSWIDTH_1_BYTE:
+		return PL08X_WIDTH_8BIT;
+	case DMA_SLAVE_BUSWIDTH_2_BYTES:
+		return PL08X_WIDTH_16BIT;
+	case DMA_SLAVE_BUSWIDTH_4_BYTES:
+		return PL08X_WIDTH_32BIT;
+	}
+	return ~0;
+}
+
 static int dma_set_runtime_config(struct dma_chan *chan,
 				  struct dma_slave_config *config)
 {
 	struct pl08x_dma_chan *plchan = to_pl08x_chan(chan);
 	struct pl08x_driver_data *pl08x = plchan->host;
 	enum dma_slave_buswidth addr_width;
-	u32 maxburst;
+	u32 width, maxburst;
 	u32 cctl = 0;
 	int i;
 
@@ -1132,25 +1145,16 @@ static int dma_set_runtime_config(struct dma_chan *chan,
 		return -EINVAL;
 	}
 
-	switch (addr_width) {
-	case DMA_SLAVE_BUSWIDTH_1_BYTE:
-		cctl |= (PL080_WIDTH_8BIT << PL080_CONTROL_SWIDTH_SHIFT) |
-			(PL080_WIDTH_8BIT << PL080_CONTROL_DWIDTH_SHIFT);
-		break;
-	case DMA_SLAVE_BUSWIDTH_2_BYTES:
-		cctl |= (PL080_WIDTH_16BIT << PL080_CONTROL_SWIDTH_SHIFT) |
-			(PL080_WIDTH_16BIT << PL080_CONTROL_DWIDTH_SHIFT);
-		break;
-	case DMA_SLAVE_BUSWIDTH_4_BYTES:
-		cctl |= (PL080_WIDTH_32BIT << PL080_CONTROL_SWIDTH_SHIFT) |
-			(PL080_WIDTH_32BIT << PL080_CONTROL_DWIDTH_SHIFT);
-		break;
-	default:
+	width = pl08x_width(addr_width);
+	if (width == ~0) {
 		dev_err(&pl08x->adev->dev,
 			"bad runtime_config: alien address width\n");
 		return -EINVAL;
 	}
 
+	cctl |= width << PL080_CONTROL_SWIDTH_SHIFT;
+	cctl |= width << PL080_CONTROL_DWIDTH_SHIFT;
+
 	/*
 	 * Now decide on a maxburst:
 	 * If this channel will only request single transfers, set this
-- 
1.7.4.4

  parent reply	other threads:[~2011-07-05 13:12 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-05 13:10 [PATCH 0/9] PL08x further cleanups Russell King - ARM Linux
2011-07-05 13:10 ` [PATCH 1/9] DMA: PL08x: remove unused constants Russell King - ARM Linux
2011-07-05 13:11 ` [PATCH 2/9] DMA: PL08x: select LLI bus only once per LLI setup Russell King - ARM Linux
2011-07-05 13:11 ` [PATCH 3/9] DMA: PL08x: clean up LLI debugging Russell King - ARM Linux
2011-07-05 13:11 ` [PATCH 4/9] DMA: PL08x: separately store source/destination slave address Russell King - ARM Linux
2011-07-05 13:12 ` [PATCH 5/9] DMA: PL08x: separately store source/destination cctl Russell King - ARM Linux
2011-07-05 13:12 ` [PATCH 6/9] DMA: PL08x: constify plchan->cd and plat->slave_channels Russell King - ARM Linux
2011-07-05 13:12 ` Russell King - ARM Linux [this message]
2011-07-05 13:13 ` [PATCH 8/9] DMA: PL08x: avoid recalculating cctl at each prepare Russell King - ARM Linux
2011-07-05 13:13 ` [PATCH 9/9] DMA: PL08x: cleanup selection of burst size Russell King - ARM Linux
2011-07-07 19:51 ` [PATCH 0/9] PL08x further cleanups Linus Walleij
2011-07-13 23:05 ` Koul, Vinod
2011-07-21 16:08   ` Russell King - ARM Linux
2011-07-21 16:11     ` [PATCH 1/9] DMA: PL08x: remove unused constants Russell King - ARM Linux
2011-07-21 16:11     ` [PATCH 2/9] DMA: PL08x: select LLI bus only once per LLI setup Russell King - ARM Linux
2011-07-21 16:12     ` [PATCH 3/9] DMA: PL08x: clean up LLI debugging Russell King - ARM Linux
2011-07-21 16:12     ` [PATCH 4/9] DMA: PL08x: separately store source/destination slave address Russell King - ARM Linux
2011-07-21 16:12     ` [PATCH 5/9] DMA: PL08x: separately store source/destination cctl Russell King - ARM Linux
2011-07-21 16:13     ` [PATCH 6/9] DMA: PL08x: constify plchan->cd and plat->slave_channels Russell King - ARM Linux
2011-07-21 16:13     ` [PATCH 7/9] DMA: PL08x: cleanup selection of buswidth Russell King - ARM Linux
2011-07-21 16:13     ` [PATCH 8/9] DMA: PL08x: avoid recalculating cctl at each prepare Russell King - ARM Linux
2011-07-21 16:14     ` [PATCH 9/9] DMA: PL08x: cleanup selection of burst size Russell King - ARM Linux
2011-07-25 13:38     ` [PATCH 0/9] PL08x further cleanups Vinod Koul
2011-07-25 13:43       ` Russell King - ARM Linux
2011-07-25 13:51         ` Vinod Koul
2011-07-25 14:22           ` Russell King - ARM Linux
2011-07-25 14:38             ` Vinod Koul
2011-07-25 13:51         ` Vinod Koul

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=E1Qe5Qp-0005Na-Rt@rmk-PC.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --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.