diff options
Diffstat (limited to 'sound/pci/oxygen/oxygen_io.c')
-rw-r--r-- | sound/pci/oxygen/oxygen_io.c | 24 |
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); | |||
85 | 85 | ||
86 | static int oxygen_ac97_wait(struct oxygen *chip, unsigned int mask) | 86 | static int oxygen_ac97_wait(struct oxygen *chip, unsigned int mask) |
87 | { | 87 | { |
88 | unsigned long timeout = jiffies + msecs_to_jiffies(1); | 88 | u8 status = 0; |
89 | do { | 89 | |
90 | udelay(5); | 90 | /* |
91 | cond_resched(); | 91 | * Reading the status register also clears the bits, so we have to save |
92 | if (oxygen_read8(chip, OXYGEN_AC97_INTERRUPT_STATUS) & mask) | 92 | * the read bits in status. |
93 | return 0; | 93 | */ |
94 | } while (time_after_eq(timeout, jiffies)); | 94 | wait_event_timeout(chip->ac97_waitqueue, |
95 | return -EIO; | 95 | ({ status |= oxygen_read8(chip, OXYGEN_AC97_INTERRUPT_STATUS); |
96 | status & mask; }), | ||
97 | msecs_to_jiffies(1) + 1); | ||
98 | /* | ||
99 | * Check even after a timeout because this function should not require | ||
100 | * the AC'97 interrupt to be enabled. | ||
101 | */ | ||
102 | status |= oxygen_read8(chip, OXYGEN_AC97_INTERRUPT_STATUS); | ||
103 | return status & mask ? 0 : -EIO; | ||
96 | } | 104 | } |
97 | 105 | ||
98 | /* | 106 | /* |