Skip to contentSkip to conversation

ALSA: ASoC: davinci-mcasp: clean ip davinci_hw_common_param()

PATCH Applied Daniel Mack 4 participants 5 messages Mar 8, 2013 – Mar 12, 2013

Subsystems (2)

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: ASoC: davinci-mcasp: clean ip davinci_hw_common_param()

As pointed of by Vaibhav, commit 2952b27e2 ("ASoC: davinci-mcasp:
Add support for multichannel playback") duplicated the logic of counting the active serializers. That can be avoided by shifting the code around a bit.

Also, drop two unused defines introduced by the same commit.

Cc Michal Bachraty <[email protected]>
Cc Vaibhav Bedia <[email protected]>
---
 sound/soc/davinci/davinci-mcasp.c | 34 +++++++++++-----------------------
 1 file changed, 11 insertions(+), 23 deletions(-)
sound/soc/davinci/davinci-mcasp.c +11 -23
index b386cad..8a9c0ee 100644
@@ -237,8 +237,6 @@
 #define RXSTATE		BIT(5)
 #define SRMOD_MASK	3
 #define SRMOD_INACTIVE	0
-#define SRMOD_TX	1
-#define SRMOD_RX	2
 
 /*
  * DAVINCI_MCASP_LBCTL_REG - Loop Back Control Register Bits
@@ -691,27 +689,6 @@ static int davinci_hw_common_param(struct davinci_audio_dev *dev, int stream,
 	}
 
 	for (i = 0; i < dev->num_serializer; i++) {
-		if (dev->serial_dir[i] == TX_MODE)
-			tx_ser++;
-		if (dev->serial_dir[i] == RX_MODE)
-			rx_ser++;
-	}
-
-	if (stream == SNDRV_PCM_STREAM_PLAYBACK)
-		ser = tx_ser;
-	else
-		ser = rx_ser;
-
-	if (ser < max_active_serializers) {
-		dev_warn(dev->dev, "stream has more channels (%d) than are "
-			"enabled in mcasp (%d)\n", channels, ser * slots);
-		return -EINVAL;
-	}
-
-	tx_ser = 0;
-	rx_ser = 0;
-
-	for (i = 0; i < dev->num_serializer; i++) {
 		mcasp_set_bits(dev->base + DAVINCI_MCASP_XRSRCTL_REG(i),
 					dev->serial_dir[i]);
 		if (dev->serial_dir[i] == TX_MODE &&
@@ -730,6 +707,17 @@ static int davinci_hw_common_param(struct davinci_audio_dev *dev, int stream,
 		}
 	}
 
+	if (stream == SNDRV_PCM_STREAM_PLAYBACK)
+		ser = tx_ser;
+	else
+		ser = rx_ser;
+
+	if (ser < max_active_serializers) {
+		dev_warn(dev->dev, "stream has more channels (%d) than are "
+			"enabled in mcasp (%d)\n", channels, ser * slots);
+		return -EINVAL;
+	}
+
 	if (dev->txnumevt && stream == SNDRV_PCM_STREAM_PLAYBACK) {
 		if (dev->txnumevt * tx_ser > 64)
 			dev->txnumevt = 1;
Signature · 1 line
1.8.1.4
#1 lore raw
Quoted 63 lines · On Friday, March 08, 2013 14:19:38 Daniel Mack wrote:

As pointed of by Vaibhav, commit 2952b27e2 ("ASoC: davinci-mcasp:
Add support for multichannel playback") duplicated the logic of counting the active serializers. That can be avoided by shifting the code around a bit.

Also, drop two unused defines introduced by the same commit.

Cc Michal Bachraty <[email protected]>
Cc Vaibhav Bedia <[email protected]>
---
 sound/soc/davinci/davinci-mcasp.c | 34 +++++++++++-----------------------
 1 file changed, 11 insertions(+), 23 deletions(-)
(quoted diff) +0 -0

b/sound/soc/davinci/davinci-mcasp.c index b386cad..8a9c0ee 100644

sound/soc/davinci/davinci-mcasp.c +4 -23
@@ -237,8 +237,6 @@
 #define RXSTATE		BIT(5)
 #define SRMOD_MASK	3
 #define SRMOD_INACTIVE	0
-#define SRMOD_TX	1
-#define SRMOD_RX	2
 
 /*
  * DAVINCI_MCASP_LBCTL_REG - Loop Back Control Register Bits
@@ -691,27 +689,6 @@ static int davinci_hw_common_param(struct
 davinci_audio_dev *dev, int stream, }
 
 	for (i = 0; i < dev->num_serializer; i++) {
-		if (dev->serial_dir[i] == TX_MODE)
-			tx_ser++;
-		if (dev->serial_dir[i] == RX_MODE)
-			rx_ser++;
-	}
-
-	if (stream == SNDRV_PCM_STREAM_PLAYBACK)
-		ser = tx_ser;
-	else
-		ser = rx_ser;
-
-	if (ser < max_active_serializers) {
-		dev_warn(dev->dev, "stream has more channels (%d) than are "
-			"enabled in mcasp (%d)\n", channels, ser * slots);
-		return -EINVAL;
-	}
-
-	tx_ser = 0;
-	rx_ser = 0;
-
-	for (i = 0; i < dev->num_serializer; i++) {
 		mcasp_set_bits(dev->base + DAVINCI_MCASP_XRSRCTL_REG(i),
 					dev->serial_dir[i]);
 		if (dev->serial_dir[i] == TX_MODE &&
@@ -730,6 +707,17 @@ static int davinci_hw_common_param(struct
 davinci_audio_dev *dev, int stream, }
 	}
 
+	if (stream == SNDRV_PCM_STREAM_PLAYBACK)
+		ser = tx_ser;
+	else
+		ser = rx_ser;

sound/soc/davinci/davinci-mcasp.c static int davinci_hw_common_param(struct · line 723

Quoted 10 lines
sound/soc/davinci/davinci-mcasp.c +7 -0
+
+	if (ser < max_active_serializers) {
+		dev_warn(dev->dev, "stream has more channels (%d) than are "
+			"enabled in mcasp (%d)\n", channels, ser * slots);
+		return -EINVAL;
+	}
+
 	if (dev->txnumevt && stream == SNDRV_PCM_STREAM_PLAYBACK) {
 		if (dev->txnumevt * tx_ser > 64)
 			dev->txnumevt = 1;

It works fine. Code is also ok.

Michal

Acked-by on v1 1/1
#2 lore raw
In reply to Daniel Mack
Quoted 7 lines · Daniel Mack

As pointed of by Vaibhav, commit 2952b27e2 ("ASoC: davinci-mcasp:
Add support for multichannel playback") duplicated the logic of counting the active serializers. That can be avoided by shifting the code around a bit.

Also, drop two unused defines introduced by the same commit.

s/clean ip/clean up/ in the $subject.

Other than that, this looks fine to me.

#3 lore raw
Quoted 6 lines · Vaibhav
Quoted 5 lines · Daniel Mack

As pointed of by Vaibhav, commit 2952b27e2 ("ASoC: davinci-mcasp:
Add support for multichannel playback") duplicated the logic of counting the active serializers. That can be avoided by shifting the code around a bit.

Quoted 9 lines
Quoted 2 lines

Also, drop two unused defines introduced by the same commit.

s/clean ip/clean up/ in the $subject.

Other than that, this looks fine to me.

Thanks! Mark - you want me to resend with the fixed subject line or can you do it when commiting?

Daniel

Applied
#4 lore raw
In reply to Daniel Mack
Quoted 4 lines · Daniel Mack

As pointed of by Vaibhav, commit 2952b27e2 ("ASoC: davinci-mcasp:
Add support for multichannel playback") duplicated the logic of counting the active serializers. That can be avoided by shifting the code around a bit.

Applied, thanks.