Commit fdfa3661 authored by Amadeusz Sławiński's avatar Amadeusz Sławiński Committed by Mark Brown

ASoC: topology: Unify kcontrol removal code

Functions removing bytes, enum and mixer kcontrols are identical. Unify
them under one function and use it to free associated kcontrols.
Reviewed-by: default avatarCezary Rojewski <cezary.rojewski@intel.com>
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: default avatarAmadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Link: https://lore.kernel.org/r/20230127231111.937721-11-amadeuszx.slawinski@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent d9b07b79
...@@ -350,41 +350,9 @@ static int soc_tplg_add_kcontrol(struct soc_tplg *tplg, ...@@ -350,41 +350,9 @@ static int soc_tplg_add_kcontrol(struct soc_tplg *tplg,
tplg->dev, k, comp->name_prefix, comp, kcontrol); tplg->dev, k, comp->name_prefix, comp, kcontrol);
} }
/* remove a mixer kcontrol */ /* remove kcontrol */
static void soc_tplg_remove_mixer(struct snd_soc_component *comp, static void soc_tplg_remove_kcontrol(struct snd_soc_component *comp, struct snd_soc_dobj *dobj,
struct snd_soc_dobj *dobj, int pass) int pass)
{
struct snd_card *card = comp->card->snd_card;
if (pass != SOC_TPLG_PASS_CONTROL)
return;
if (dobj->ops && dobj->ops->control_unload)
dobj->ops->control_unload(comp, dobj);
snd_ctl_remove(card, dobj->control.kcontrol);
list_del(&dobj->list);
}
/* remove an enum kcontrol */
static void soc_tplg_remove_enum(struct snd_soc_component *comp,
struct snd_soc_dobj *dobj, int pass)
{
struct snd_card *card = comp->card->snd_card;
if (pass != SOC_TPLG_PASS_CONTROL)
return;
if (dobj->ops && dobj->ops->control_unload)
dobj->ops->control_unload(comp, dobj);
snd_ctl_remove(card, dobj->control.kcontrol);
list_del(&dobj->list);
}
/* remove a byte kcontrol */
static void soc_tplg_remove_bytes(struct snd_soc_component *comp,
struct snd_soc_dobj *dobj, int pass)
{ {
struct snd_card *card = comp->card->snd_card; struct snd_card *card = comp->card->snd_card;
...@@ -2618,14 +2586,10 @@ int snd_soc_tplg_component_remove(struct snd_soc_component *comp) ...@@ -2618,14 +2586,10 @@ int snd_soc_tplg_component_remove(struct snd_soc_component *comp)
list) { list) {
switch (dobj->type) { switch (dobj->type) {
case SND_SOC_DOBJ_MIXER:
soc_tplg_remove_mixer(comp, dobj, pass);
break;
case SND_SOC_DOBJ_ENUM:
soc_tplg_remove_enum(comp, dobj, pass);
break;
case SND_SOC_DOBJ_BYTES: case SND_SOC_DOBJ_BYTES:
soc_tplg_remove_bytes(comp, dobj, pass); case SND_SOC_DOBJ_ENUM:
case SND_SOC_DOBJ_MIXER:
soc_tplg_remove_kcontrol(comp, dobj, pass);
break; break;
case SND_SOC_DOBJ_GRAPH: case SND_SOC_DOBJ_GRAPH:
soc_tplg_remove_route(comp, dobj, pass); soc_tplg_remove_route(comp, dobj, pass);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment