summaryrefslogtreecommitdiff
path: root/sound/pci/oxygen/oxygen_io.c
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2008-01-28 10:34:21 +0300
committerJaroslav Kysela <perex@perex.cz>2008-01-31 19:30:17 +0300
commit1e821dd2763c97df1a0a451e553d218cb8886cd7 (patch)
treec09376cd0e36251f1c83ec6bf4e52a7226db7811 /sound/pci/oxygen/oxygen_io.c
parent911b499af45e879ccf4b8db234278a7136d056c9 (diff)
downloadlinux-1e821dd2763c97df1a0a451e553d218cb8886cd7.tar.xz
[ALSA] oxygen: use AC97 interrupt
After an AC97 register read or write, use the AC97 interrupt instead of polling to wait for the access to be completed. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci/oxygen/oxygen_io.c')
-rw-r--r--sound/pci/oxygen/oxygen_io.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/sound/pci/oxygen/oxygen_io.c b/sound/pci/oxygen/oxygen_io.c
index d0cdce041dd8..74e23ef9c946 100644
--- a/sound/pci/oxygen/oxygen_io.c
+++ b/sound/pci/oxygen/oxygen_io.c
@@ -85,14 +85,22 @@ EXPORT_SYMBOL(oxygen_write32_masked);
static int oxygen_ac97_wait(struct oxygen *chip, unsigned int mask)
{
- unsigned long timeout = jiffies + msecs_to_jiffies(1);
- do {
- udelay(5);
- cond_resched();
- if (oxygen_read8(chip, OXYGEN_AC97_INTERRUPT_STATUS) & mask)
- return 0;
- } while (time_after_eq(timeout, jiffies));
- return -EIO;
+ u8 status = 0;
+
+ /*
+ * Reading the status register also clears the bits, so we have to save
+ * the read bits in status.
+ */
+ wait_event_timeout(chip->ac97_waitqueue,
+ ({ status |= oxygen_read8(chip, OXYGEN_AC97_INTERRUPT_STATUS);
+ status & mask; }),
+ msecs_to_jiffies(1) + 1);
+ /*
+ * Check even after a timeout because this function should not require
+ * the AC'97 interrupt to be enabled.
+ */
+ status |= oxygen_read8(chip, OXYGEN_AC97_INTERRUPT_STATUS);
+ return status & mask ? 0 : -EIO;
}
/*