Commit 5c79b1f8 authored by Takashi Iwai's avatar Takashi Iwai Committed by Jaroslav Kysela

[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: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarJaroslav Kysela <perex@suse.cz>
parent 314634bc
...@@ -520,38 +520,36 @@ static void azx_update_rirb(struct azx *chip) ...@@ -520,38 +520,36 @@ static void azx_update_rirb(struct azx *chip)
static unsigned int azx_rirb_get_response(struct hda_codec *codec) static unsigned int azx_rirb_get_response(struct hda_codec *codec)
{ {
struct azx *chip = codec->bus->private_data; 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) { if (chip->polling_mode) {
spin_lock_irq(&chip->reg_lock); spin_lock_irq(&chip->reg_lock);
azx_update_rirb(chip); azx_update_rirb(chip);
spin_unlock_irq(&chip->reg_lock); spin_unlock_irq(&chip->reg_lock);
} }
if (! chip->rirb.cmds) if (! chip->rirb.cmds)
break; return chip->rirb.res; /* the last value */
if (! --timeout) { schedule_timeout_interruptible(1);
if (! chip->polling_mode) { } while (time_after_eq(timeout, jiffies));
snd_printk(KERN_WARNING "hda_intel: "
"azx_get_response timeout, " if (!chip->polling_mode) {
"switching to polling mode...\n"); snd_printk(KERN_WARNING "hda_intel: azx_get_response timeout, "
chip->polling_mode = 1; "switching to polling mode...\n");
timeout = 50; chip->polling_mode = 1;
continue; goto again;
}
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 */
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;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment