Skip to content

Commit

Permalink
ASoC: sh: Replace tasklet with work
Browse files Browse the repository at this point in the history
The tasklet is an old API that should be deprecated, usually can be
converted to another decent API.  In ASoC SH SIU driver, a tasklet is
still used for offloading the hardware reset function.  It can be
achieved gracefully with a work queued, too.

This patch replaces the tasklet usage in SH SIU driver with a simple
work.  The conversion is fairly straightforward.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20200903104749.21435-3-tiwai@suse.de
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Takashi Iwai authored and Mark Brown committed Sep 9, 2020
1 parent a3d1f93 commit d668e64
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion sound/soc/sh/siu.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ struct siu_info {
};

struct siu_stream {
struct tasklet_struct tasklet;
struct work_struct work;
struct snd_pcm_substream *substream;
snd_pcm_format_t format;
size_t buf_bytes;
Expand Down
21 changes: 11 additions & 10 deletions sound/soc/sh/siu_pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static int siu_pcm_stmwrite_start(struct siu_port *port_info)
siu_stream->rw_flg = RWF_STM_WT;

/* DMA transfer start */
tasklet_schedule(&siu_stream->tasklet);
queue_work(system_highpri_wq, &siu_stream->work);

return 0;
}
Expand All @@ -93,7 +93,7 @@ static void siu_dma_tx_complete(void *arg)
siu_stream->cur_period * siu_stream->period_bytes,
siu_stream->buf_bytes, siu_stream->cookie);

tasklet_schedule(&siu_stream->tasklet);
queue_work(system_highpri_wq, &siu_stream->work);

/* Notify alsa: a period is done */
snd_pcm_period_elapsed(siu_stream->substream);
Expand Down Expand Up @@ -198,9 +198,10 @@ static int siu_pcm_rd_set(struct siu_port *port_info,
return 0;
}

static void siu_io_tasklet(struct tasklet_struct *t)
static void siu_io_work(struct work_struct *work)
{
struct siu_stream *siu_stream = from_tasklet(siu_stream, t, tasklet);
struct siu_stream *siu_stream = container_of(work, struct siu_stream,
work);
struct snd_pcm_substream *substream = siu_stream->substream;
struct device *dev = substream->pcm->card->dev;
struct snd_pcm_runtime *rt = substream->runtime;
Expand Down Expand Up @@ -253,7 +254,7 @@ static int siu_pcm_stmread_start(struct siu_port *port_info)
/* during stmread flag set */
siu_stream->rw_flg = RWF_STM_RD;

tasklet_schedule(&siu_stream->tasklet);
queue_work(system_highpri_wq, &siu_stream->work);

return 0;
}
Expand Down Expand Up @@ -519,9 +520,9 @@ static int siu_pcm_new(struct snd_soc_component *component,

(*port_info)->pcm = pcm;

/* IO tasklets */
tasklet_setup(&(*port_info)->playback.tasklet, siu_io_tasklet);
tasklet_setup(&(*port_info)->capture.tasklet, siu_io_tasklet);
/* IO works */
INIT_WORK(&(*port_info)->playback.work, siu_io_work);
INIT_WORK(&(*port_info)->capture.work, siu_io_work);
}

dev_info(card->dev, "SuperH SIU driver initialized.\n");
Expand All @@ -534,8 +535,8 @@ static void siu_pcm_free(struct snd_soc_component *component,
struct platform_device *pdev = to_platform_device(pcm->card->dev);
struct siu_port *port_info = siu_ports[pdev->id];

tasklet_kill(&port_info->capture.tasklet);
tasklet_kill(&port_info->playback.tasklet);
cancel_work_sync(&port_info->capture.work);
cancel_work_sync(&port_info->playback.work);

siu_free_port(port_info);

Expand Down

0 comments on commit d668e64

Please sign in to comment.