diff options
author | Takashi Iwai <tiwai@suse.de> | 2006-09-21 13:34:13 +0200 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-09-23 10:48:06 +0200 |
commit | 5c79b1f887f8edcd399baa164b66a1c08566c994 (patch) | |
tree | e47d2cc5e2bea91c56d001833d960edbdf1f9371 /sound | |
parent | 314634bc81325dcfeb31ed138647d428b1f26cbf (diff) | |
download | linux-stable-5c79b1f887f8edcd399baa164b66a1c08566c994.tar.gz linux-stable-5c79b1f887f8edcd399baa164b66a1c08566c994.tar.bz2 linux-stable-5c79b1f887f8edcd399baa164b66a1c08566c994.zip |
[ALSA] hda-intel - A slight cleanup of timeout check in azx_get_response()
A slight cleanup of timeout check in azx_get_response() to check
jiffies for HZ-independent timeout.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/pci/hda/hda_intel.c | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 4d2df771112e..e9d4cb4d07e1 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -520,38 +520,36 @@ static void azx_update_rirb(struct azx *chip) static unsigned int azx_rirb_get_response(struct hda_codec *codec) { struct azx *chip = codec->bus->private_data; - int timeout = 50; + unsigned long timeout; - for (;;) { + again: + timeout = jiffies + msecs_to_jiffies(1000); + do { if (chip->polling_mode) { spin_lock_irq(&chip->reg_lock); azx_update_rirb(chip); spin_unlock_irq(&chip->reg_lock); } if (! chip->rirb.cmds) - break; - if (! --timeout) { - if (! chip->polling_mode) { - snd_printk(KERN_WARNING "hda_intel: " - "azx_get_response timeout, " - "switching to polling mode...\n"); - chip->polling_mode = 1; - timeout = 50; - continue; - } - snd_printk(KERN_ERR - "hda_intel: azx_get_response timeout, " - "switching to single_cmd mode...\n"); - chip->rirb.rp = azx_readb(chip, RIRBWP); - chip->rirb.cmds = 0; - /* switch to single_cmd mode */ - chip->single_cmd = 1; - azx_free_cmd_io(chip); - return -1; - } - msleep(1); + return chip->rirb.res; /* the last value */ + schedule_timeout_interruptible(1); + } while (time_after_eq(timeout, jiffies)); + + if (!chip->polling_mode) { + snd_printk(KERN_WARNING "hda_intel: azx_get_response timeout, " + "switching to polling mode...\n"); + chip->polling_mode = 1; + goto again; } - return chip->rirb.res; /* the last value */ + + snd_printk(KERN_ERR "hda_intel: azx_get_response timeout, " + "switching to single_cmd mode...\n"); + chip->rirb.rp = azx_readb(chip, RIRBWP); + chip->rirb.cmds = 0; + /* switch to single_cmd mode */ + chip->single_cmd = 1; + azx_free_cmd_io(chip); + return -1; } /* |