]> err.no Git - linux-2.6/commitdiff
[ALSA] hda-intel - Make azx_get_response() a bit more robust
authorTakashi Iwai <tiwai@suse.de>
Fri, 18 Jan 2008 14:32:32 +0000 (15:32 +0100)
committerJaroslav Kysela <perex@perex.cz>
Thu, 31 Jan 2008 16:30:05 +0000 (17:30 +0100)
In azx_[rirb_]get_response(), the timeout is checked at the end of the loop.
It's better to be checked just after the check of the RIRB index to avoid
a bogus error with a too long msleep().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
sound/pci/hda/hda_intel.c

index fe07bdff60d015064463dc020573e384446c3143..be5cbbcb6ec3e2a79dadc91299d2bd65519616c1 100644 (file)
@@ -551,7 +551,7 @@ static unsigned int azx_rirb_get_response(struct hda_codec *codec)
 
  again:
        timeout = jiffies + msecs_to_jiffies(1000);
-       do {
+       for (;;) {
                if (chip->polling_mode) {
                        spin_lock_irq(&chip->reg_lock);
                        azx_update_rirb(chip);
@@ -559,13 +559,15 @@ static unsigned int azx_rirb_get_response(struct hda_codec *codec)
                }
                if (!chip->rirb.cmds)
                        return chip->rirb.res; /* the last value */
+               if (time_after(jiffies, timeout))
+                       break;
                if (codec->bus->needs_damn_long_delay)
                        msleep(2); /* temporary workaround */
                else {
                        udelay(10);
                        cond_resched();
                }
-       } while (time_after_eq(timeout, jiffies));
+       }
 
        if (chip->msi) {
                snd_printk(KERN_WARNING "hda_intel: No response from codec, "