Skip to content

Commit c7d9efd

Browse files
committed
ALSA: usb-audio: Replace tasklet with work
The tasklet is an old API that should be deprecated, usually can be converted to another decent API. In USB-audio driver, a tasklet is still used in MIDI interface code for handling the output byte stream. It can be achieved gracefully with a work queued in the high-prio system workqueue. This patch replaces the tasklet usage in USB-audio driver with a simple work. Link: https://lore.kernel.org/r/20200903104131.21097-4-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent bf08359 commit c7d9efd

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

‎sound/usb/midi.c‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ struct snd_usb_midi_out_endpoint {
142142
unsigned int active_urbs;
143143
unsigned int drain_urbs;
144144
int max_transfer; /* size of urb buffer */
145-
struct tasklet_struct tasklet;
145+
struct work_struct work;
146146
unsigned int next_urb;
147147
spinlock_t buffer_lock;
148148

@@ -344,9 +344,10 @@ static void snd_usbmidi_do_output(struct snd_usb_midi_out_endpoint *ep)
344344
spin_unlock_irqrestore(&ep->buffer_lock, flags);
345345
}
346346

347-
static void snd_usbmidi_out_tasklet(struct tasklet_struct *t)
347+
static void snd_usbmidi_out_work(struct work_struct *work)
348348
{
349-
struct snd_usb_midi_out_endpoint *ep = from_tasklet(ep, t, tasklet);
349+
struct snd_usb_midi_out_endpoint *ep =
350+
container_of(work, struct snd_usb_midi_out_endpoint, work);
350351

351352
snd_usbmidi_do_output(ep);
352353
}
@@ -1177,7 +1178,7 @@ static void snd_usbmidi_output_trigger(struct snd_rawmidi_substream *substream,
11771178
snd_rawmidi_proceed(substream);
11781179
return;
11791180
}
1180-
tasklet_schedule(&port->ep->tasklet);
1181+
queue_work(system_highpri_wq, &port->ep->work);
11811182
}
11821183
}
11831184

@@ -1440,7 +1441,7 @@ static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi *umidi,
14401441
}
14411442

14421443
spin_lock_init(&ep->buffer_lock);
1443-
tasklet_setup(&ep->tasklet, snd_usbmidi_out_tasklet);
1444+
INIT_WORK(&ep->work, snd_usbmidi_out_work);
14441445
init_waitqueue_head(&ep->drain_wait);
14451446

14461447
for (i = 0; i < 0x10; ++i)
@@ -1503,7 +1504,7 @@ void snd_usbmidi_disconnect(struct list_head *p)
15031504
for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) {
15041505
struct snd_usb_midi_endpoint *ep = &umidi->endpoints[i];
15051506
if (ep->out)
1506-
tasklet_kill(&ep->out->tasklet);
1507+
cancel_work_sync(&ep->out->work);
15071508
if (ep->out) {
15081509
for (j = 0; j < OUTPUT_URBS; ++j)
15091510
usb_kill_urb(ep->out->urbs[j].urb);

0 commit comments

Comments
 (0)