ASoC: davinci-mcasp: clean up davinci_hw_common_param()
authorDaniel Mack <zonque@gmail.com>
Fri, 8 Mar 2013 13:19:38 +0000 (14:19 +0100)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 12 Mar 2013 19:03:53 +0000 (19:03 +0000)
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.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Acked-by: Vaibhav Bedia <vaibhav.bedia@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/davinci/davinci-mcasp.c

index 5cd85a87957912219f9c43c8565c39f94d98d486..46c9705cec095eda6faf5be5755baed439038f59 100644 (file)
 #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
@@ -686,27 +684,6 @@ static int davinci_hw_common_param(struct davinci_audio_dev *dev, int stream,
                                RXDATADMADIS);
        }
 
-       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]);
@@ -726,6 +703,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;