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: aloop: Replace tasklet with work

The tasklet is an old API that should be deprecated, usually can be
converted to another decent API. In aloop driver, a tasklet is still
used for offloading the timer event task. It can be achieved
gracefully with a work queued, too.

This patch replaces the tasklet usage in aloop driver with a simple
work.

Link: https://lore.kernel.org/r/20200903104131.21097-6-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>

+11 -12
+11 -12
sound/drivers/aloop.c
··· 110 110 struct { 111 111 int stream; 112 112 struct snd_timer_id id; 113 - struct tasklet_struct event_tasklet; 113 + struct work_struct event_work; 114 114 struct snd_timer_instance *instance; 115 115 } snd_timer; 116 116 }; ··· 309 309 */ 310 310 snd_timer_close(cable->snd_timer.instance); 311 311 312 - /* wait till drain tasklet has finished if requested */ 313 - tasklet_kill(&cable->snd_timer.event_tasklet); 312 + /* wait till drain work has finished if requested */ 313 + cancel_work_sync(&cable->snd_timer.event_work); 314 314 315 315 snd_timer_instance_free(cable->snd_timer.instance); 316 316 memset(&cable->snd_timer, 0, sizeof(cable->snd_timer)); ··· 794 794 resolution); 795 795 } 796 796 797 - static void loopback_snd_timer_tasklet(unsigned long arg) 797 + static void loopback_snd_timer_work(struct work_struct *work) 798 798 { 799 - struct snd_timer_instance *timeri = (struct snd_timer_instance *)arg; 800 - struct loopback_cable *cable = timeri->callback_data; 799 + struct loopback_cable *cable; 801 800 801 + cable = container_of(work, struct loopback_cable, snd_timer.event_work); 802 802 loopback_snd_timer_period_elapsed(cable, SNDRV_TIMER_EVENT_MSTOP, 0); 803 803 } 804 804 ··· 828 828 * state the streaming will be aborted by the usual timeout. It 829 829 * should not be aborted here because may be the timer sound 830 830 * card does only a recovery and the timer is back soon. 831 - * This tasklet triggers loopback_snd_timer_tasklet() 831 + * This work triggers loopback_snd_timer_work() 832 832 */ 833 - tasklet_schedule(&cable->snd_timer.event_tasklet); 833 + schedule_work(&cable->snd_timer.event_work); 834 834 } 835 835 } 836 836 ··· 1124 1124 err = -ENOMEM; 1125 1125 goto exit; 1126 1126 } 1127 - /* The callback has to be called from another tasklet. If 1127 + /* The callback has to be called from another work. If 1128 1128 * SNDRV_TIMER_IFLG_FAST is specified it will be called from the 1129 1129 * snd_pcm_period_elapsed() call of the selected sound card. 1130 1130 * snd_pcm_period_elapsed() helds snd_pcm_stream_lock_irqsave(). ··· 1137 1137 timeri->callback_data = (void *)cable; 1138 1138 timeri->ccallback = loopback_snd_timer_event; 1139 1139 1140 - /* initialise a tasklet used for draining */ 1141 - tasklet_init(&cable->snd_timer.event_tasklet, 1142 - loopback_snd_timer_tasklet, (unsigned long)timeri); 1140 + /* initialise a work used for draining */ 1141 + INIT_WORK(&cable->snd_timer.event_work, loopback_snd_timer_work); 1143 1142 1144 1143 /* The mutex loopback->cable_lock is kept locked. 1145 1144 * Therefore snd_timer_open() cannot be called a second time