aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/ac97/ac97_codec.c
diff options
context:
space:
mode:
authorNishanth Aravamudan <nacc@us.ibm.com>2005-07-09 04:13:22 -0400
committerJaroslav Kysela <perex@suse.cz>2005-07-28 06:22:13 -0400
commitef21ca24faf28df6d06939e77d5032a313490289 (patch)
tree1c6c719f4671b803f1288eb8cdca18587ec2eb62 /sound/pci/ac97/ac97_codec.c
parent072c01194df6e4843582d09380b780987f642d6d (diff)
[ALSA] sound/pci: fix-up sleeping paths
ENS1370/1+ driver,ES1968 driver,Intel8x0 driver,VIA82xx driver VIA82xx-modem driver,AC97 Codec,ALI5451 driver,CS46xx driver MIXART driver,RME HDSP driver,Trident driver,YMFPCI driver Description: Fix-up sleeping in sound/pci. These changes fall under the following two categories: 1) Replace schedule_timeout() with msleep() to guarantee the task delays as expected. This also involved replacing/removing custom sleep functions. 2) Do not assume jiffies will only increment by one if you request a 1 jiffy sleep, i.e. use time_after/time_before in while loops. Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/pci/ac97/ac97_codec.c')
-rw-r--r--sound/pci/ac97/ac97_codec.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index 0677d41239a9..94cd989cff20 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -2227,6 +2227,7 @@ void snd_ac97_restore_iec958(ac97_t *ac97)
2227void snd_ac97_resume(ac97_t *ac97) 2227void snd_ac97_resume(ac97_t *ac97)
2228{ 2228{
2229 int i; 2229 int i;
2230 unsigned long end_time;
2230 2231
2231 if (ac97->bus->ops->reset) { 2232 if (ac97->bus->ops->reset) {
2232 ac97->bus->ops->reset(ac97); 2233 ac97->bus->ops->reset(ac97);
@@ -2244,26 +2245,26 @@ void snd_ac97_resume(ac97_t *ac97)
2244 snd_ac97_write(ac97, AC97_POWERDOWN, ac97->regs[AC97_POWERDOWN]); 2245 snd_ac97_write(ac97, AC97_POWERDOWN, ac97->regs[AC97_POWERDOWN]);
2245 if (ac97_is_audio(ac97)) { 2246 if (ac97_is_audio(ac97)) {
2246 ac97->bus->ops->write(ac97, AC97_MASTER, 0x8101); 2247 ac97->bus->ops->write(ac97, AC97_MASTER, 0x8101);
2247 for (i = HZ/10; i >= 0; i--) { 2248 end_time = jiffies + msecs_to_jiffies(100);
2249 do {
2248 if (snd_ac97_read(ac97, AC97_MASTER) == 0x8101) 2250 if (snd_ac97_read(ac97, AC97_MASTER) == 0x8101)
2249 break; 2251 break;
2250 set_current_state(TASK_UNINTERRUPTIBLE); 2252 set_current_state(TASK_UNINTERRUPTIBLE);
2251 schedule_timeout(1); 2253 schedule_timeout(1);
2252 } 2254 } while (time_after_eq(end_time, jiffies));
2253 /* FIXME: extra delay */ 2255 /* FIXME: extra delay */
2254 ac97->bus->ops->write(ac97, AC97_MASTER, 0x8000); 2256 ac97->bus->ops->write(ac97, AC97_MASTER, 0x8000);
2255 if (snd_ac97_read(ac97, AC97_MASTER) != 0x8000) { 2257 if (snd_ac97_read(ac97, AC97_MASTER) != 0x8000)
2256 set_current_state(TASK_UNINTERRUPTIBLE); 2258 msleep(250);
2257 schedule_timeout(HZ/4);
2258 }
2259 } else { 2259 } else {
2260 for (i = HZ/10; i >= 0; i--) { 2260 end_time = jiffies + msecs_to_jiffies(100);
2261 do {
2261 unsigned short val = snd_ac97_read(ac97, AC97_EXTENDED_MID); 2262 unsigned short val = snd_ac97_read(ac97, AC97_EXTENDED_MID);
2262 if (val != 0xffff && (val & 1) != 0) 2263 if (val != 0xffff && (val & 1) != 0)
2263 break; 2264 break;
2264 set_current_state(TASK_UNINTERRUPTIBLE); 2265 set_current_state(TASK_UNINTERRUPTIBLE);
2265 schedule_timeout(1); 2266 schedule_timeout(1);
2266 } 2267 } while (time_after_eq(end_time, jiffies));
2267 } 2268 }
2268__reset_ready: 2269__reset_ready:
2269 2270