]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/sparc/cs4231.c
ALSA: Kill snd_assert() in other places
[linux-2.6-omap-h63xx.git] / sound / sparc / cs4231.c
index 4f515a64e03f2c4491e24e9027931afd61c01581..791d2fb821d17b40495a1cdfc127016752ba6790 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/io.h>
 
 
-#include <sound/driver.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/info.h>
@@ -400,69 +399,44 @@ static void snd_cs4231_mce_up(struct snd_cs4231 *chip)
 
 static void snd_cs4231_mce_down(struct snd_cs4231 *chip)
 {
-       unsigned long flags;
-       int timeout;
+       unsigned long flags, timeout;
+       int reg;
 
-       spin_lock_irqsave(&chip->lock, flags);
        snd_cs4231_busy_wait(chip);
+       spin_lock_irqsave(&chip->lock, flags);
 #ifdef CONFIG_SND_DEBUG
        if (__cs4231_readb(chip, CS4231U(chip, REGSEL)) & CS4231_INIT)
                snd_printdd("mce_down [%p] - auto calibration time out (0)\n",
                            CS4231U(chip, REGSEL));
 #endif
        chip->mce_bit &= ~CS4231_MCE;
-       timeout = __cs4231_readb(chip, CS4231U(chip, REGSEL));
-       __cs4231_writeb(chip, chip->mce_bit | (timeout & 0x1f),
+       reg = __cs4231_readb(chip, CS4231U(chip, REGSEL));
+       __cs4231_writeb(chip, chip->mce_bit | (reg & 0x1f),
                        CS4231U(chip, REGSEL));
-       if (timeout == 0x80)
-               snd_printdd("mce_down [%p]: serious init problem - "
-                           "codec still busy\n",
-                           chip->port);
-       if ((timeout & CS4231_MCE) == 0) {
+       if (reg == 0x80)
+               snd_printdd("mce_down [%p]: serious init problem "
+                           "- codec still busy\n", chip->port);
+       if ((reg & CS4231_MCE) == 0) {
                spin_unlock_irqrestore(&chip->lock, flags);
                return;
        }
-       snd_cs4231_busy_wait(chip);
-
-       /* calibration process */
 
-       snd_cs4231_ready(chip);
-       snd_cs4231_ready(chip);
-       timeout = snd_cs4231_in(chip, CS4231_TEST_INIT);
-       if ((timeout & CS4231_CALIB_IN_PROGRESS) == 0) {
-               snd_printd("cs4231_mce_down - auto calibration time out (1)\n");
+       /*
+        * Wait for auto-calibration (AC) process to finish, i.e. ACI to go low.
+        */
+       timeout = jiffies + msecs_to_jiffies(250);
+       do {
                spin_unlock_irqrestore(&chip->lock, flags);
-               return;
-       }
-
-       /* in 10ms increments, check condition, up to 250ms */
-       timeout = 25;
-       while (snd_cs4231_in(chip, CS4231_TEST_INIT) &
-               CS4231_CALIB_IN_PROGRESS) {
-
-               spin_unlock_irqrestore(&chip->lock, flags);
-               if (--timeout < 0) {
-                       snd_printk("mce_down - "
-                                  "auto calibration time out (2)\n");
-                       return;
-               }
-               msleep(10);
-               spin_lock_irqsave(&chip->lock, flags);
-       }
-
-       /* in 10ms increments, check condition, up to 100ms */
-       timeout = 10;
-       while (__cs4231_readb(chip, CS4231U(chip, REGSEL)) & CS4231_INIT) {
-               spin_unlock_irqrestore(&chip->lock, flags);
-               if (--timeout < 0) {
-                       snd_printk("mce_down - "
-                                  "auto calibration time out (3)\n");
-                       return;
-               }
-               msleep(10);
+               msleep(1);
                spin_lock_irqsave(&chip->lock, flags);
-       }
+               reg = snd_cs4231_in(chip, CS4231_TEST_INIT);
+               reg &= CS4231_CALIB_IN_PROGRESS;
+       } while (reg && time_before(jiffies, timeout));
        spin_unlock_irqrestore(&chip->lock, flags);
+
+       if (reg)
+               snd_printk(KERN_ERR
+                          "mce_down - auto calibration time out (2)\n");
 }
 
 static void snd_cs4231_advance_dma(struct cs4231_dma_control *dma_cont,
@@ -1586,7 +1560,8 @@ static int __init snd_cs4231_mixer(struct snd_card *card)
        struct snd_cs4231 *chip = card->private_data;
        int err, idx;
 
-       snd_assert(chip != NULL && chip->pcm != NULL, return -EINVAL);
+       if (snd_BUG_ON(!chip || !chip->pcm))
+               return -EINVAL;
 
        strcpy(card->mixername, chip->pcm->name);