Skip to contentSkip to conversation

ALSA: wavefront: Convert timers to use timer_setup()

PATCH Applied Kees Cook 2 participants 3 messages Oct 24, 2017 Sound

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 ALSA: wavefront: 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.

Cc Jaroslav Kysela <[email protected]>
Cc Takashi Iwai <[email protected]>
Cc Takashi Sakamoto <[email protected]>
---
 include/sound/snd_wavefront.h        |  1 +
 sound/isa/wavefront/wavefront_midi.c | 10 +++++-----
 2 files changed, 6 insertions(+), 5 deletions(-)
include/sound/snd_wavefront.h +1 -0
index cd0bab1ef6f1..fcd770fdcda5 100644
@@ -28,6 +28,7 @@ struct _snd_wavefront_midi {
 	struct snd_rawmidi_substream	 *substream_output[2];
 	struct snd_rawmidi_substream	 *substream_input[2];
 	struct timer_list	 timer;
+	snd_wavefront_card_t	 *timer_card;
         spinlock_t               open;
         spinlock_t               virtual;     /* protects isvirtual */
 };
sound/isa/wavefront/wavefront_midi.c +5 -5
index 2aa05f3aaa38..556b14738970 100644
@@ -349,10 +349,10 @@ static void snd_wavefront_midi_input_trigger(struct snd_rawmidi_substream *subst
 	spin_unlock_irqrestore (&midi->virtual, flags);
 }
 
-static void snd_wavefront_midi_output_timer(unsigned long data)
+static void snd_wavefront_midi_output_timer(struct timer_list *t)
 {
-	snd_wavefront_card_t *card = (snd_wavefront_card_t *)data;
-	snd_wavefront_midi_t *midi = &card->wavefront.midi;
+	snd_wavefront_midi_t *midi = from_timer(midi, t, timer);
+	snd_wavefront_card_t *card = midi->timer_card;
 	unsigned long flags;
 	
 	spin_lock_irqsave (&midi->virtual, flags);
@@ -383,9 +383,9 @@ static void snd_wavefront_midi_output_trigger(struct snd_rawmidi_substream *subs
 	if (up) {
 		if ((midi->mode[mpu] & MPU401_MODE_OUTPUT_TRIGGER) == 0) {
 			if (!midi->istimer) {
-				setup_timer(&midi->timer,
+				timer_setup(&midi->timer,
 					    snd_wavefront_midi_output_timer,
-					    (unsigned long) substream->rmidi->card->private_data);
+					    0);
 				mod_timer(&midi->timer, 1 + jiffies);
 			}
 			midi->istimer++;
Signature · 6 lines
2.7.4


-- 
Kees Cook
Pixel Security
Applied
#1 lore raw
Quoted 10 lines · Kees Cook

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.

Cc Jaroslav Kysela <[email protected]>
Cc Takashi Iwai <[email protected]>
Cc Takashi Sakamoto <[email protected]>

Thanks, applied.

I guess we may deduce the card pointer from substream_output[], but this approach will be simpler in the end.

Takashi

author
#2 lore raw
Quoted 13 lines · Takashi Iwai
Quoted 10 lines · Kees Cook

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.

Cc Jaroslav Kysela <[email protected]>
Cc Takashi Iwai <[email protected]>
Cc Takashi Sakamoto <[email protected]>
Quoted 4 lines

Thanks, applied.

I guess we may deduce the card pointer from substream_output[], but this approach will be simpler in the end.

Yeah, I looked at that as an option, and I couldn't tell if the lifetime might change out from under the timer, so I opted for an explicit pointer since that's no worse than what the old struct timer_list did anyway. :)

Thanks!

-Kees

Signature · 2 lines
Kees Cook
Pixel Security