From c696be60d96532f777d01ee753af0af54ec31240 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 14 Jun 2011 14:37:06 +0200 Subject: [PATCH] --- yaml --- r: 257615 b: refs/heads/master c: b3c705aa9e9147a30009bdf6ba853aa7fe138e58 h: refs/heads/master i: 257613: 7c2b371034c8e9409e3fe54e58451062e7b2eb0f 257611: 555dda4b7e53f5a9a6dce20d601978d46748018e 257607: 79b5a4b28365344c6e446ab305a34ce66b77bd97 257599: 72a2f78b6737463dac011156f297582afe1d4e25 v: v3 --- [refs] | 2 +- trunk/include/sound/rawmidi.h | 4 +++- trunk/sound/core/rawmidi.c | 37 +++++++++++------------------------ 3 files changed, 15 insertions(+), 28 deletions(-) diff --git a/[refs] b/[refs] index e3796acba921..6ded4974c79f 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 30bdee0259093e114c711943902c834e5c3326c5 +refs/heads/master: b3c705aa9e9147a30009bdf6ba853aa7fe138e58 diff --git a/trunk/include/sound/rawmidi.h b/trunk/include/sound/rawmidi.h index 2480e7d10dcf..6b14359d9fed 100644 --- a/trunk/include/sound/rawmidi.h +++ b/trunk/include/sound/rawmidi.h @@ -27,6 +27,7 @@ #include #include #include +#include #if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE) #include "seq_device.h" @@ -63,6 +64,7 @@ struct snd_rawmidi_global_ops { }; struct snd_rawmidi_runtime { + struct snd_rawmidi_substream *substream; unsigned int drain: 1, /* drain stage */ oss: 1; /* OSS compatible mode */ /* midi stream buffer */ @@ -79,7 +81,7 @@ struct snd_rawmidi_runtime { /* event handler (new bytes, input only) */ void (*event)(struct snd_rawmidi_substream *substream); /* defers calls to event [input] or ops->trigger [output] */ - struct tasklet_struct tasklet; + struct work_struct event_work; /* private data */ void *private_data; void (*private_free)(struct snd_rawmidi_substream *substream); diff --git a/trunk/sound/core/rawmidi.c b/trunk/sound/core/rawmidi.c index cbbed0db9e56..0757f542999d 100644 --- a/trunk/sound/core/rawmidi.c +++ b/trunk/sound/core/rawmidi.c @@ -92,16 +92,12 @@ static inline int snd_rawmidi_ready_append(struct snd_rawmidi_substream *substre (!substream->append || runtime->avail >= count); } -static void snd_rawmidi_input_event_tasklet(unsigned long data) +static void snd_rawmidi_input_event_work(struct work_struct *work) { - struct snd_rawmidi_substream *substream = (struct snd_rawmidi_substream *)data; - substream->runtime->event(substream); -} - -static void snd_rawmidi_output_trigger_tasklet(unsigned long data) -{ - struct snd_rawmidi_substream *substream = (struct snd_rawmidi_substream *)data; - substream->ops->trigger(substream, 1); + struct snd_rawmidi_runtime *runtime = + container_of(work, struct snd_rawmidi_runtime, event_work); + if (runtime->event) + runtime->event(runtime->substream); } static int snd_rawmidi_runtime_create(struct snd_rawmidi_substream *substream) @@ -110,16 +106,10 @@ static int snd_rawmidi_runtime_create(struct snd_rawmidi_substream *substream) if ((runtime = kzalloc(sizeof(*runtime), GFP_KERNEL)) == NULL) return -ENOMEM; + runtime->substream = substream; spin_lock_init(&runtime->lock); init_waitqueue_head(&runtime->sleep); - if (substream->stream == SNDRV_RAWMIDI_STREAM_INPUT) - tasklet_init(&runtime->tasklet, - snd_rawmidi_input_event_tasklet, - (unsigned long)substream); - else - tasklet_init(&runtime->tasklet, - snd_rawmidi_output_trigger_tasklet, - (unsigned long)substream); + INIT_WORK(&runtime->event_work, snd_rawmidi_input_event_work); runtime->event = NULL; runtime->buffer_size = PAGE_SIZE; runtime->avail_min = 1; @@ -150,12 +140,7 @@ static inline void snd_rawmidi_output_trigger(struct snd_rawmidi_substream *subs { if (!substream->opened) return; - if (up) { - tasklet_schedule(&substream->runtime->tasklet); - } else { - tasklet_kill(&substream->runtime->tasklet); - substream->ops->trigger(substream, 0); - } + substream->ops->trigger(substream, up); } static void snd_rawmidi_input_trigger(struct snd_rawmidi_substream *substream, int up) @@ -163,8 +148,8 @@ static void snd_rawmidi_input_trigger(struct snd_rawmidi_substream *substream, i if (!substream->opened) return; substream->ops->trigger(substream, up); - if (!up && substream->runtime->event) - tasklet_kill(&substream->runtime->tasklet); + if (!up) + cancel_work_sync(&substream->runtime->event_work); } int snd_rawmidi_drop_output(struct snd_rawmidi_substream *substream) @@ -926,7 +911,7 @@ int snd_rawmidi_receive(struct snd_rawmidi_substream *substream, } if (result > 0) { if (runtime->event) - tasklet_schedule(&runtime->tasklet); + schedule_work(&runtime->event_work); else if (snd_rawmidi_ready(substream)) wake_up(&runtime->sleep); }