Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+7 -6
+7 -6
sound/usb/midi.c
··· 142 142 unsigned int active_urbs; 143 143 unsigned int drain_urbs; 144 144 int max_transfer; /* size of urb buffer */ 145 - struct tasklet_struct tasklet; 145 + struct work_struct work; 146 146 unsigned int next_urb; 147 147 spinlock_t buffer_lock; 148 148 ··· 344 344 spin_unlock_irqrestore(&ep->buffer_lock, flags); 345 345 } 346 346 347 - static void snd_usbmidi_out_tasklet(struct tasklet_struct *t) 347 + static void snd_usbmidi_out_work(struct work_struct *work) 348 348 { 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); 350 351 351 352 snd_usbmidi_do_output(ep); 352 353 } ··· 1178 1177 snd_rawmidi_proceed(substream); 1179 1178 return; 1180 1179 } 1181 - tasklet_schedule(&port->ep->tasklet); 1180 + queue_work(system_highpri_wq, &port->ep->work); 1182 1181 } 1183 1182 } 1184 1183 ··· 1441 1440 } 1442 1441 1443 1442 spin_lock_init(&ep->buffer_lock); 1444 - tasklet_setup(&ep->tasklet, snd_usbmidi_out_tasklet); 1443 + INIT_WORK(&ep->work, snd_usbmidi_out_work); 1445 1444 init_waitqueue_head(&ep->drain_wait); 1446 1445 1447 1446 for (i = 0; i < 0x10; ++i) ··· 1504 1503 for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) { 1505 1504 struct snd_usb_midi_endpoint *ep = &umidi->endpoints[i]; 1506 1505 if (ep->out) 1507 - tasklet_kill(&ep->out->tasklet); 1506 + cancel_work_sync(&ep->out->work); 1508 1507 if (ep->out) { 1509 1508 for (j = 0; j < OUTPUT_URBS; ++j) 1510 1509 usb_kill_urb(ep->out->urbs[j].urb);