소스 검색

ALSA: sb: Convert timers to use timer_setup()

In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

[Re-use the existing chip->midi_substream_output instead of assigning
 a new field to struct snd_sb -- tiwai]

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Kees Cook 7 년 전
부모
커밋
4f928246f0
2개의 변경된 파일8개의 추가작업 그리고 9개의 파일을 삭제
  1. 3 3
      sound/isa/sb/emu8000_pcm.c
  2. 5 6
      sound/isa/sb/sb8_midi.c

+ 3 - 3
sound/isa/sb/emu8000_pcm.c

@@ -193,9 +193,9 @@ static inline int emu8k_get_curpos(struct snd_emu8k_pcm *rec, int ch)
  * timer interrupt handler
  * timer interrupt handler
  * check the current position and update the period if necessary.
  * check the current position and update the period if necessary.
  */
  */
-static void emu8k_pcm_timer_func(unsigned long data)
+static void emu8k_pcm_timer_func(struct timer_list *t)
 {
 {
-	struct snd_emu8k_pcm *rec = (struct snd_emu8k_pcm *)data;
+	struct snd_emu8k_pcm *rec = from_timer(rec, t, timer);
 	int ptr, delta;
 	int ptr, delta;
 
 
 	spin_lock(&rec->timer_lock);
 	spin_lock(&rec->timer_lock);
@@ -241,7 +241,7 @@ static int emu8k_pcm_open(struct snd_pcm_substream *subs)
 	runtime->private_data = rec;
 	runtime->private_data = rec;
 
 
 	spin_lock_init(&rec->timer_lock);
 	spin_lock_init(&rec->timer_lock);
-	setup_timer(&rec->timer, emu8k_pcm_timer_func, (unsigned long)rec);
+	timer_setup(&rec->timer, emu8k_pcm_timer_func, 0);
 
 
 	runtime->hw = emu8k_pcm_hw;
 	runtime->hw = emu8k_pcm_hw;
 	runtime->hw.buffer_bytes_max = emu->mem_size - LOOP_BLANK_SIZE * 3;
 	runtime->hw.buffer_bytes_max = emu->mem_size - LOOP_BLANK_SIZE * 3;

+ 5 - 6
sound/isa/sb/sb8_midi.c

@@ -209,10 +209,10 @@ static void snd_sb8dsp_midi_output_write(struct snd_rawmidi_substream *substream
 	}
 	}
 }
 }
 
 
-static void snd_sb8dsp_midi_output_timer(unsigned long data)
+static void snd_sb8dsp_midi_output_timer(struct timer_list *t)
 {
 {
-	struct snd_rawmidi_substream *substream = (struct snd_rawmidi_substream *) data;
-	struct snd_sb * chip = substream->rmidi->private_data;
+	struct snd_sb *chip = from_timer(chip, t, midi_timer);
+	struct snd_rawmidi_substream *substream = chip->midi_substream_output;
 	unsigned long flags;
 	unsigned long flags;
 
 
 	spin_lock_irqsave(&chip->open_lock, flags);
 	spin_lock_irqsave(&chip->open_lock, flags);
@@ -230,9 +230,8 @@ static void snd_sb8dsp_midi_output_trigger(struct snd_rawmidi_substream *substre
 	spin_lock_irqsave(&chip->open_lock, flags);
 	spin_lock_irqsave(&chip->open_lock, flags);
 	if (up) {
 	if (up) {
 		if (!(chip->open & SB_OPEN_MIDI_OUTPUT_TRIGGER)) {
 		if (!(chip->open & SB_OPEN_MIDI_OUTPUT_TRIGGER)) {
-			setup_timer(&chip->midi_timer,
-				    snd_sb8dsp_midi_output_timer,
-				    (unsigned long) substream);
+			timer_setup(&chip->midi_timer,
+				    snd_sb8dsp_midi_output_timer, 0);
 			mod_timer(&chip->midi_timer, 1 + jiffies);
 			mod_timer(&chip->midi_timer, 1 + jiffies);
 			chip->open |= SB_OPEN_MIDI_OUTPUT_TRIGGER;
 			chip->open |= SB_OPEN_MIDI_OUTPUT_TRIGGER;
 		}
 		}