From 8433a509c0eb6bb1f33ce39c82c580b8901619ee Mon Sep 17 00:00:00 2001 From: Nishanth Aravamudan Date: Mon, 24 Oct 2005 15:02:37 +0200 Subject: [ALSA] Fix schedule_timeout usage Use schedule_timeout_{,un}interruptible() instead of set_current_state()/schedule_timeout() to reduce kernel size. Also use human-time conversion functions instead of hard-coded division to avoid rounding issues. Signed-off-by: Nishanth Aravamudan Signed-off-by: Andrew Morton Signed-off-by: Takashi Iwai --- sound/isa/ad1848/ad1848_lib.c | 6 ++---- sound/isa/gus/gus_pcm.c | 3 +-- sound/isa/sb/emu8000.c | 9 +++------ sound/isa/sb/emu8000_patch.c | 3 +-- sound/isa/sb/emu8000_pcm.c | 3 +-- sound/isa/sscape.c | 17 ++--------------- sound/isa/wavefront/wavefront_synth.c | 6 ++---- 7 files changed, 12 insertions(+), 35 deletions(-) (limited to 'sound/isa') diff --git a/sound/isa/ad1848/ad1848_lib.c b/sound/isa/ad1848/ad1848_lib.c index 744b65a35c9c..891bacc94f68 100644 --- a/sound/isa/ad1848/ad1848_lib.c +++ b/sound/isa/ad1848/ad1848_lib.c @@ -243,8 +243,7 @@ static void snd_ad1848_mce_down(ad1848_t *chip) snd_printk(KERN_ERR "mce_down - auto calibration time out (2)\n"); return; } - set_current_state(TASK_INTERRUPTIBLE); - time = schedule_timeout(time); + time = schedule_timeout_interruptible(time); spin_lock_irqsave(&chip->reg_lock, flags); } #if 0 @@ -257,8 +256,7 @@ static void snd_ad1848_mce_down(ad1848_t *chip) snd_printk(KERN_ERR "mce_down - auto calibration time out (3)\n"); return; } - set_current_state(TASK_INTERRUPTIBLE); - time = schedule_timeout(time); + time = schedule_timeout_interruptible(time); spin_lock_irqsave(&chip->reg_lock, flags); } spin_unlock_irqrestore(&chip->reg_lock, flags); diff --git a/sound/isa/gus/gus_pcm.c b/sound/isa/gus/gus_pcm.c index 720c0739c3a5..1cc89fb67bf2 100644 --- a/sound/isa/gus/gus_pcm.c +++ b/sound/isa/gus/gus_pcm.c @@ -333,8 +333,7 @@ static int snd_gf1_pcm_poke_block(snd_gus_card_t *gus, unsigned char *buf, } } if (count > 0 && !in_interrupt()) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); + schedule_timeout_interruptible(1); if (signal_pending(current)) return -EAGAIN; } diff --git a/sound/isa/sb/emu8000.c b/sound/isa/sb/emu8000.c index 95540f133199..b09c6575e01a 100644 --- a/sound/isa/sb/emu8000.c +++ b/sound/isa/sb/emu8000.c @@ -135,8 +135,7 @@ static void __init snd_emu8000_read_wait(emu8000_t *emu) { while ((EMU8000_SMALR_READ(emu) & 0x80000000) != 0) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); + schedule_timeout_interruptible(1); if (signal_pending(current)) break; } @@ -148,8 +147,7 @@ static void __init snd_emu8000_write_wait(emu8000_t *emu) { while ((EMU8000_SMALW_READ(emu) & 0x80000000) != 0) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); + schedule_timeout_interruptible(1); if (signal_pending(current)) break; } @@ -437,8 +435,7 @@ size_dram(emu8000_t *emu) for (i = 0; i < 10000; i++) { if ((EMU8000_SMALW_READ(emu) & 0x80000000) == 0) break; - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); + schedule_timeout_interruptible(1); if (signal_pending(current)) break; } diff --git a/sound/isa/sb/emu8000_patch.c b/sound/isa/sb/emu8000_patch.c index 26e693078cb3..2fea67e71c78 100644 --- a/sound/isa/sb/emu8000_patch.c +++ b/sound/isa/sb/emu8000_patch.c @@ -109,8 +109,7 @@ static void snd_emu8000_write_wait(emu8000_t *emu) { while ((EMU8000_SMALW_READ(emu) & 0x80000000) != 0) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); + schedule_timeout_interruptible(1); if (signal_pending(current)) break; } diff --git a/sound/isa/sb/emu8000_pcm.c b/sound/isa/sb/emu8000_pcm.c index 0209790dc4b5..b323beeeda15 100644 --- a/sound/isa/sb/emu8000_pcm.c +++ b/sound/isa/sb/emu8000_pcm.c @@ -117,8 +117,7 @@ snd_emu8000_write_wait(emu8000_t *emu, int can_schedule) { while ((EMU8000_SMALW_READ(emu) & 0x80000000) != 0) { if (can_schedule) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); + schedule_timeout_interruptible(1); if (signal_pending(current)) break; } diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c index 1036876146c4..11588067fa4f 100644 --- a/sound/isa/sscape.c +++ b/sound/isa/sscape.c @@ -342,19 +342,6 @@ static void soundscape_free(snd_card_t * c) free_dma(sscape->chip->dma1); } -/* - * Put this process into an idle wait-state for a certain number - * of "jiffies". The process can almost certainly be rescheduled - * while we're waiting, and so we must NOT be holding any spinlocks - * when we call this function. If we are then we risk DEADLOCK in - * SMP (Ha!) or pre-emptible kernels. - */ -static inline void sleep(long jiffs, int state) -{ - set_current_state(state); - schedule_timeout(jiffs); -} - /* * Tell the SoundScape to begin a DMA tranfer using the given channel. * All locking issues are left to the caller. @@ -392,7 +379,7 @@ static int obp_startup_ack(struct soundscape *s, unsigned timeout) unsigned long flags; unsigned char x; - sleep(1, TASK_INTERRUPTIBLE); + schedule_timeout_interruptible(1); spin_lock_irqsave(&s->lock, flags); x = inb(HOST_DATA_IO(s->io_base)); @@ -419,7 +406,7 @@ static int host_startup_ack(struct soundscape *s, unsigned timeout) unsigned long flags; unsigned char x; - sleep(1, TASK_INTERRUPTIBLE); + schedule_timeout_interruptible(1); spin_lock_irqsave(&s->lock, flags); x = inb(HOST_DATA_IO(s->io_base)); diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c index 0c3c951009d8..abd79b781412 100644 --- a/sound/isa/wavefront/wavefront_synth.c +++ b/sound/isa/wavefront/wavefront_synth.c @@ -275,8 +275,7 @@ static int wavefront_sleep (int limit) { - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(limit); + schedule_timeout_interruptible(limit); return signal_pending(current); } @@ -1788,8 +1787,7 @@ wavefront_should_cause_interrupt (snd_wavefront_t *dev, outb (val,port); spin_unlock_irq(&dev->irq_lock); while (1) { - set_current_state(TASK_INTERRUPTIBLE); - if ((timeout = schedule_timeout(timeout)) == 0) + if ((timeout = schedule_timeout_interruptible(timeout)) == 0) return; if (dev->irq_ok) return; -- cgit v1.2.3