From 5b1646a8eceff0a4ff06f309abb6e7f43f99a498 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 14:13:14 +0100 Subject: [ALSA] Remove xxx_t typedefs: OPL3 Modules: OPL3,Raw OPL FM Remove xxx_t typedefs from the OPL3 driver Signed-off-by: Takashi Iwai --- sound/drivers/opl3/opl3_midi.c | 70 +++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'sound/drivers/opl3/opl3_midi.c') diff --git a/sound/drivers/opl3/opl3_midi.c b/sound/drivers/opl3/opl3_midi.c index 93d674070b7..48c480e050c 100644 --- a/sound/drivers/opl3/opl3_midi.c +++ b/sound/drivers/opl3/opl3_midi.c @@ -60,7 +60,7 @@ static char opl3_volume_table[128] = }; void snd_opl3_calc_volume(unsigned char *volbyte, int vel, - snd_midi_channel_t *chan) + struct snd_midi_channel *chan) { int oldvol, newvol, n; int volume; @@ -93,7 +93,7 @@ static short opl3_note_table[16] = }; static void snd_opl3_calc_pitch(unsigned char *fnum, unsigned char *blocknum, - int note, snd_midi_channel_t *chan) + int note, struct snd_midi_channel *chan) { int block = ((note / 12) & 0x07) - 1; int idx = (note % 12) + 2; @@ -121,7 +121,7 @@ static void snd_opl3_calc_pitch(unsigned char *fnum, unsigned char *blocknum, #ifdef DEBUG_ALLOC -static void debug_alloc(opl3_t *opl3, char *s, int voice) { +static void debug_alloc(struct snd_opl3 *opl3, char *s, int voice) { int i; char *str = "x.24"; @@ -135,12 +135,12 @@ static void debug_alloc(opl3_t *opl3, char *s, int voice) { /* * Get a FM voice (channel) to play a note on. */ -static int opl3_get_voice(opl3_t *opl3, int instr_4op, - snd_midi_channel_t *chan) { +static int opl3_get_voice(struct snd_opl3 *opl3, int instr_4op, + struct snd_midi_channel *chan) { int chan_4op_1; /* first voice for 4op instrument */ int chan_4op_2; /* second voice for 4op instrument */ - snd_opl3_voice_t *vp, *vp2; + struct snd_opl3_voice *vp, *vp2; unsigned int voice_time; int i; @@ -237,13 +237,13 @@ static int opl3_get_voice(opl3_t *opl3, int instr_4op, void snd_opl3_timer_func(unsigned long data) { - opl3_t *opl3 = (opl3_t *)data; + struct snd_opl3 *opl3 = (struct snd_opl3 *)data; int again = 0; int i; spin_lock(&opl3->sys_timer_lock); for (i = 0; i < opl3->max_voices; i++) { - snd_opl3_voice_t *vp = &opl3->voices[i]; + struct snd_opl3_voice *vp = &opl3->voices[i]; if (vp->state > 0 && vp->note_off_check) { if (vp->note_off == jiffies) snd_opl3_note_off(opl3, vp->note, 0, vp->chan); @@ -263,7 +263,7 @@ void snd_opl3_timer_func(unsigned long data) /* * Start system timer */ -static void snd_opl3_start_timer(opl3_t *opl3) +static void snd_opl3_start_timer(struct snd_opl3 *opl3) { unsigned long flags; spin_lock_irqsave(&opl3->sys_timer_lock, flags); @@ -285,15 +285,15 @@ static int snd_opl3_oss_map[MAX_OPL3_VOICES] = { /* * Start a note. */ -void snd_opl3_note_on(void *p, int note, int vel, snd_midi_channel_t *chan) +void snd_opl3_note_on(void *p, int note, int vel, struct snd_midi_channel *chan) { - opl3_t *opl3; - snd_seq_instr_t wanted; - snd_seq_kinstr_t *kinstr; + struct snd_opl3 *opl3; + struct snd_seq_instr wanted; + struct snd_seq_kinstr *kinstr; int instr_4op; int voice; - snd_opl3_voice_t *vp, *vp2; + struct snd_opl3_voice *vp, *vp2; unsigned short connect_mask; unsigned char connection; unsigned char vol_op[4]; @@ -310,7 +310,7 @@ void snd_opl3_note_on(void *p, int note, int vel, snd_midi_channel_t *chan) unsigned char fnum, blocknum; int i; - fm_instrument_t *fm; + struct fm_instrument *fm; unsigned long flags; opl3 = p; @@ -615,13 +615,13 @@ void snd_opl3_note_on(void *p, int note, int vel, snd_midi_channel_t *chan) spin_unlock_irqrestore(&opl3->voice_lock, flags); } -static void snd_opl3_kill_voice(opl3_t *opl3, int voice) +static void snd_opl3_kill_voice(struct snd_opl3 *opl3, int voice) { unsigned short reg_side; unsigned char voice_offset; unsigned short opl3_reg; - snd_opl3_voice_t *vp, *vp2; + struct snd_opl3_voice *vp, *vp2; snd_assert(voice < MAX_OPL3_VOICES, return); @@ -663,12 +663,12 @@ static void snd_opl3_kill_voice(opl3_t *opl3, int voice) /* * Release a note in response to a midi note off. */ -void snd_opl3_note_off(void *p, int note, int vel, snd_midi_channel_t *chan) +void snd_opl3_note_off(void *p, int note, int vel, struct snd_midi_channel *chan) { - opl3_t *opl3; + struct snd_opl3 *opl3; int voice; - snd_opl3_voice_t *vp; + struct snd_opl3_voice *vp; unsigned long flags; @@ -708,9 +708,9 @@ void snd_opl3_note_off(void *p, int note, int vel, snd_midi_channel_t *chan) /* * key pressure change */ -void snd_opl3_key_press(void *p, int note, int vel, snd_midi_channel_t *chan) +void snd_opl3_key_press(void *p, int note, int vel, struct snd_midi_channel *chan) { - opl3_t *opl3; + struct snd_opl3 *opl3; opl3 = p; #ifdef DEBUG_MIDI @@ -722,9 +722,9 @@ void snd_opl3_key_press(void *p, int note, int vel, snd_midi_channel_t *chan) /* * terminate note */ -void snd_opl3_terminate_note(void *p, int note, snd_midi_channel_t *chan) +void snd_opl3_terminate_note(void *p, int note, struct snd_midi_channel *chan) { - opl3_t *opl3; + struct snd_opl3 *opl3; opl3 = p; #ifdef DEBUG_MIDI @@ -733,7 +733,7 @@ void snd_opl3_terminate_note(void *p, int note, snd_midi_channel_t *chan) #endif } -static void snd_opl3_update_pitch(opl3_t *opl3, int voice) +static void snd_opl3_update_pitch(struct snd_opl3 *opl3, int voice) { unsigned short reg_side; unsigned char voice_offset; @@ -741,7 +741,7 @@ static void snd_opl3_update_pitch(opl3_t *opl3, int voice) unsigned char fnum, blocknum; - snd_opl3_voice_t *vp; + struct snd_opl3_voice *vp; snd_assert(voice < MAX_OPL3_VOICES, return); @@ -780,10 +780,10 @@ static void snd_opl3_update_pitch(opl3_t *opl3, int voice) /* * Update voice pitch controller */ -static void snd_opl3_pitch_ctrl(opl3_t *opl3, snd_midi_channel_t *chan) +static void snd_opl3_pitch_ctrl(struct snd_opl3 *opl3, struct snd_midi_channel *chan) { int voice; - snd_opl3_voice_t *vp; + struct snd_opl3_voice *vp; unsigned long flags; @@ -810,9 +810,9 @@ static void snd_opl3_pitch_ctrl(opl3_t *opl3, snd_midi_channel_t *chan) * Deal with a controler type event. This includes all types of * control events, not just the midi controllers */ -void snd_opl3_control(void *p, int type, snd_midi_channel_t *chan) +void snd_opl3_control(void *p, int type, struct snd_midi_channel *chan) { - opl3_t *opl3; + struct snd_opl3 *opl3; opl3 = p; #ifdef DEBUG_MIDI @@ -846,10 +846,10 @@ void snd_opl3_control(void *p, int type, snd_midi_channel_t *chan) /* * NRPN events */ -void snd_opl3_nrpn(void *p, snd_midi_channel_t *chan, - snd_midi_channel_set_t *chset) +void snd_opl3_nrpn(void *p, struct snd_midi_channel *chan, + struct snd_midi_channel_set *chset) { - opl3_t *opl3; + struct snd_opl3 *opl3; opl3 = p; #ifdef DEBUG_MIDI @@ -862,9 +862,9 @@ void snd_opl3_nrpn(void *p, snd_midi_channel_t *chan, * receive sysex */ void snd_opl3_sysex(void *p, unsigned char *buf, int len, - int parsed, snd_midi_channel_set_t *chset) + int parsed, struct snd_midi_channel_set *chset) { - opl3_t *opl3; + struct snd_opl3 *opl3; opl3 = p; #ifdef DEBUG_MIDI -- cgit v1.2.3-70-g09d2 From b32425ac93370e1ba5556110e662f896b2e143b3 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 18 Nov 2005 18:52:14 +0100 Subject: [ALSA] Fix possible races in timer callbacks Fix possible races in timer callbacks. Signed-off-by: Takashi Iwai --- sound/core/timer.c | 5 +++-- sound/drivers/dummy.c | 10 +++++----- sound/drivers/mpu401/mpu401_uart.c | 5 +++-- sound/drivers/opl3/opl3_midi.c | 5 +++-- sound/pci/korg1212/korg1212.c | 5 +++-- sound/synth/emux/emux_synth.c | 5 +++-- 6 files changed, 20 insertions(+), 15 deletions(-) (limited to 'sound/drivers/opl3/opl3_midi.c') diff --git a/sound/core/timer.c b/sound/core/timer.c index 74637cef6d2..6aad411dd7b 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -662,12 +662,13 @@ void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left) struct snd_timer_instance *ti, *ts; unsigned long resolution, ticks; struct list_head *p, *q, *n, *ack_list_head; + unsigned long flags; int use_tasklet = 0; if (timer == NULL) return; - spin_lock(&timer->lock); + spin_lock_irqsave(&timer->lock, flags); /* remember the current resolution */ if (timer->hw.c_resolution) @@ -752,7 +753,7 @@ void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left) /* do we have any slow callbacks? */ use_tasklet = !list_empty(&timer->sack_list_head); - spin_unlock(&timer->lock); + spin_unlock_irqrestore(&timer->lock, flags); if (use_tasklet) tasklet_hi_schedule(&timer->task_queue); diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index a276f7c8036..18611757174 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c @@ -231,8 +231,9 @@ static int snd_card_dummy_pcm_prepare(struct snd_pcm_substream *substream) static void snd_card_dummy_pcm_timer_function(unsigned long data) { struct snd_dummy_pcm *dpcm = (struct snd_dummy_pcm *)data; + unsigned long flags; - spin_lock(&dpcm->lock); + spin_lock_irqsave(&dpcm->lock, flags); dpcm->timer.expires = 1 + jiffies; add_timer(&dpcm->timer); dpcm->pcm_irq_pos += dpcm->pcm_jiffie; @@ -240,11 +241,10 @@ static void snd_card_dummy_pcm_timer_function(unsigned long data) dpcm->pcm_buf_pos %= dpcm->pcm_size; if (dpcm->pcm_irq_pos >= dpcm->pcm_count) { dpcm->pcm_irq_pos %= dpcm->pcm_count; - spin_unlock(&dpcm->lock); + spin_unlock_irqrestore(&dpcm->lock, flags); snd_pcm_period_elapsed(dpcm->substream); - spin_lock(&dpcm->lock); - } - spin_unlock(&dpcm->lock); + } else + spin_unlock_irqrestore(&dpcm->lock, flags); } static snd_pcm_uframes_t snd_card_dummy_pcm_pointer(struct snd_pcm_substream *substream) diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c index ee67b522d25..8687ae3c66b 100644 --- a/sound/drivers/mpu401/mpu401_uart.c +++ b/sound/drivers/mpu401/mpu401_uart.c @@ -133,12 +133,13 @@ irqreturn_t snd_mpu401_uart_interrupt(int irq, void *dev_id, struct pt_regs *reg static void snd_mpu401_uart_timer(unsigned long data) { struct snd_mpu401 *mpu = (struct snd_mpu401 *)data; + unsigned long flags; - spin_lock(&mpu->timer_lock); + spin_lock_irqsave(&mpu->timer_lock, flags); /*mpu->mode |= MPU401_MODE_TIMER;*/ mpu->timer.expires = 1 + jiffies; add_timer(&mpu->timer); - spin_unlock(&mpu->timer_lock); + spin_unlock_irqrestore(&mpu->timer_lock, flags); if (mpu->rmidi) _snd_mpu401_uart_interrupt(mpu); } diff --git a/sound/drivers/opl3/opl3_midi.c b/sound/drivers/opl3/opl3_midi.c index 48c480e050c..1b6f227af37 100644 --- a/sound/drivers/opl3/opl3_midi.c +++ b/sound/drivers/opl3/opl3_midi.c @@ -238,10 +238,11 @@ void snd_opl3_timer_func(unsigned long data) { struct snd_opl3 *opl3 = (struct snd_opl3 *)data; + unsigned long flags; int again = 0; int i; - spin_lock(&opl3->sys_timer_lock); + spin_lock_irqsave(&opl3->sys_timer_lock, flags); for (i = 0; i < opl3->max_voices; i++) { struct snd_opl3_voice *vp = &opl3->voices[i]; if (vp->state > 0 && vp->note_off_check) { @@ -257,7 +258,7 @@ void snd_opl3_timer_func(unsigned long data) } else { opl3->sys_timer_status = 0; } - spin_unlock(&opl3->sys_timer_lock); + spin_unlock_irqrestore(&opl3->sys_timer_lock, flags); } /* diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index a8a6a5c41a7..4eddb512c12 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -609,8 +609,9 @@ static void snd_korg1212_SendStopAndWait(struct snd_korg1212 *korg1212) static void snd_korg1212_timer_func(unsigned long data) { struct snd_korg1212 *korg1212 = (struct snd_korg1212 *) data; + unsigned long flags; - spin_lock(&korg1212->lock); + spin_lock_irqsave(&korg1212->lock, flags); if (korg1212->sharedBufferPtr->cardCommand == 0) { /* ack'ed */ korg1212->stop_pending_cnt = 0; @@ -632,7 +633,7 @@ static void snd_korg1212_timer_func(unsigned long data) stateName[korg1212->cardState]); } } - spin_unlock(&korg1212->lock); + spin_unlock_irqrestore(&korg1212->lock, flags); } static int snd_korg1212_TurnOnIdleMonitor(struct snd_korg1212 *korg1212) diff --git a/sound/synth/emux/emux_synth.c b/sound/synth/emux/emux_synth.c index c387a83a655..24705d15ebd 100644 --- a/sound/synth/emux/emux_synth.c +++ b/sound/synth/emux/emux_synth.c @@ -205,9 +205,10 @@ void snd_emux_timer_callback(unsigned long data) { struct snd_emux *emu = (struct snd_emux *) data; struct snd_emux_voice *vp; + unsigned long flags; int ch, do_again = 0; - spin_lock(&emu->voice_lock); + spin_lock_irqsave(&emu->voice_lock, flags); for (ch = 0; ch < emu->max_voices; ch++) { vp = &emu->voices[ch]; if (vp->state == SNDRV_EMUX_ST_PENDING) { @@ -225,7 +226,7 @@ void snd_emux_timer_callback(unsigned long data) emu->timer_active = 1; } else emu->timer_active = 0; - spin_unlock(&emu->voice_lock); + spin_unlock_irqrestore(&emu->voice_lock, flags); } /* -- cgit v1.2.3-70-g09d2