diff options
author | Simon Trimmer <simont@opensource.cirrus.com> | 2021-09-13 19:00:45 +0300 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2021-09-27 15:00:31 +0300 |
commit | df6c505c129a114da783ae82b9f0b4d2d4691c91 (patch) | |
tree | 3b051a85324b326fc5571ffed39ca417ffe8bb1a /sound/soc/codecs/wm_adsp.c | |
parent | 04ae08596737c4d3872dfb6e617c918d9ecf073e (diff) | |
download | linux-df6c505c129a114da783ae82b9f0b4d2d4691c91.tar.xz |
ASoC: wm_adsp: Cancel ongoing work when removing controls
Removes wm_adsp_ctl_work and integrates the work_struct into
wm_coeff_ctl so it may be referenced.
Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210913160057.103842-5-simont@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs/wm_adsp.c')
-rw-r--r-- | sound/soc/codecs/wm_adsp.c | 34 |
1 files changed, 9 insertions, 25 deletions
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index 9c3d4b96fd7c..c1b5ea3b5718 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c @@ -613,6 +613,7 @@ struct wm_coeff_ctl { struct soc_bytes_ext bytes_ext; unsigned int flags; unsigned int type; + struct work_struct work; }; static const char *wm_adsp_mem_region_name(unsigned int type) @@ -1240,12 +1241,6 @@ static int wm_coeff_get_acked(struct snd_kcontrol *kcontrol, return 0; } -struct wmfw_ctl_work { - struct wm_adsp *dsp; - struct wm_coeff_ctl *ctl; - struct work_struct work; -}; - static unsigned int wmfw_convert_flags(unsigned int in, unsigned int len) { unsigned int out, rd, wr, vol; @@ -1394,16 +1389,17 @@ static void wm_adsp_signal_event_controls(struct wm_adsp *dsp, static void wm_adsp_ctl_work(struct work_struct *work) { - struct wmfw_ctl_work *ctl_work = container_of(work, - struct wmfw_ctl_work, - work); + struct wm_coeff_ctl *ctl = container_of(work, + struct wm_coeff_ctl, + work); - wmfw_add_ctl(ctl_work->dsp, ctl_work->ctl); - kfree(ctl_work); + wmfw_add_ctl(ctl->dsp, ctl); } static void wm_adsp_free_ctl_blk(struct wm_coeff_ctl *ctl) { + cancel_work_sync(&ctl->work); + kfree(ctl->cache); kfree(ctl->name); kfree(ctl->subname); @@ -1417,7 +1413,6 @@ static int wm_adsp_create_control(struct wm_adsp *dsp, unsigned int flags, unsigned int type) { struct wm_coeff_ctl *ctl; - struct wmfw_ctl_work *ctl_work; char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; const char *region_name; int ret; @@ -1513,22 +1508,11 @@ static int wm_adsp_create_control(struct wm_adsp *dsp, if (flags & WMFW_CTL_FLAG_SYS) return 0; - ctl_work = kzalloc(sizeof(*ctl_work), GFP_KERNEL); - if (!ctl_work) { - ret = -ENOMEM; - goto err_list_del; - } - - ctl_work->dsp = dsp; - ctl_work->ctl = ctl; - INIT_WORK(&ctl_work->work, wm_adsp_ctl_work); - schedule_work(&ctl_work->work); + INIT_WORK(&ctl->work, wm_adsp_ctl_work); + schedule_work(&ctl->work); return 0; -err_list_del: - list_del(&ctl->list); - kfree(ctl->cache); err_ctl_subname: kfree(ctl->subname); err_ctl_name: |