Skip to content

Commit d522bb6

Browse files
keestiwai
authored andcommitted
ALSA: sh: aica: 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. This requires adding a pointer to hold the timer's target substream, as there won't be a way to pass this in the future. Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent 9e66317 commit d522bb6

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

sound/sh/aica.c

+9-11
Original file line numberDiff line numberDiff line change
@@ -299,14 +299,14 @@ static void run_spu_dma(struct work_struct *work)
299299
}
300300
}
301301

302-
static void aica_period_elapsed(unsigned long timer_var)
302+
static void aica_period_elapsed(struct timer_list *t)
303303
{
304+
struct snd_card_aica *dreamcastcard = from_timer(dreamcastcard,
305+
t, timer);
306+
struct snd_pcm_substream *substream = dreamcastcard->timer_substream;
304307
/*timer function - so cannot sleep */
305308
int play_period;
306309
struct snd_pcm_runtime *runtime;
307-
struct snd_pcm_substream *substream;
308-
struct snd_card_aica *dreamcastcard;
309-
substream = (struct snd_pcm_substream *) timer_var;
310310
runtime = substream->runtime;
311311
dreamcastcard = substream->pcm->private_data;
312312
/* Have we played out an additional period? */
@@ -336,12 +336,12 @@ static void spu_begin_dma(struct snd_pcm_substream *substream)
336336
/*get the queue to do the work */
337337
schedule_work(&(dreamcastcard->spu_dma_work));
338338
/* Timer may already be running */
339-
if (unlikely(dreamcastcard->timer.data)) {
339+
if (unlikely(dreamcastcard->timer_substream)) {
340340
mod_timer(&dreamcastcard->timer, jiffies + 4);
341341
return;
342342
}
343-
setup_timer(&dreamcastcard->timer, aica_period_elapsed,
344-
(unsigned long) substream);
343+
timer_setup(&dreamcastcard->timer, aica_period_elapsed, 0);
344+
dreamcastcard->timer_substream = substream;
345345
mod_timer(&dreamcastcard->timer, jiffies + 4);
346346
}
347347

@@ -379,7 +379,7 @@ static int snd_aicapcm_pcm_close(struct snd_pcm_substream
379379
{
380380
struct snd_card_aica *dreamcastcard = substream->pcm->private_data;
381381
flush_work(&(dreamcastcard->spu_dma_work));
382-
if (dreamcastcard->timer.data)
382+
if (dreamcastcard->timer_substream)
383383
del_timer(&dreamcastcard->timer);
384384
kfree(dreamcastcard->channel);
385385
spu_disable();
@@ -600,7 +600,7 @@ static int snd_aica_probe(struct platform_device *devptr)
600600
{
601601
int err;
602602
struct snd_card_aica *dreamcastcard;
603-
dreamcastcard = kmalloc(sizeof(struct snd_card_aica), GFP_KERNEL);
603+
dreamcastcard = kzalloc(sizeof(struct snd_card_aica), GFP_KERNEL);
604604
if (unlikely(!dreamcastcard))
605605
return -ENOMEM;
606606
err = snd_card_new(&devptr->dev, index, SND_AICA_DRIVER,
@@ -619,8 +619,6 @@ static int snd_aica_probe(struct platform_device *devptr)
619619
err = snd_aicapcmchip(dreamcastcard, 0);
620620
if (unlikely(err < 0))
621621
goto freedreamcast;
622-
dreamcastcard->timer.data = 0;
623-
dreamcastcard->channel = NULL;
624622
/* Add basic controls */
625623
err = add_aicamixer_controls(dreamcastcard);
626624
if (unlikely(err < 0))

0 commit comments

Comments
 (0)