Commit d8b366c4 authored by Takashi Iwai's avatar Takashi Iwai

ASoC: atmel: mchp-pdmc: Use snd_ctl_remove_id()

Use the standard snd_ctl_remove_id() helper instead of open code for
removing a kctl.  This helps for avoiding possible races.
Reviewed-by: default avatarClaudiu Beznea <claudiu.beznea@tuxon.dev>
Acked-by: default avatarMark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230718141304.1032-4-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 6eca6914
...@@ -386,7 +386,6 @@ static int mchp_pdmc_open(struct snd_soc_component *component, ...@@ -386,7 +386,6 @@ static int mchp_pdmc_open(struct snd_soc_component *component,
for (i = 0; i < ARRAY_SIZE(mchp_pdmc_snd_controls); i++) { for (i = 0; i < ARRAY_SIZE(mchp_pdmc_snd_controls); i++) {
const struct snd_kcontrol_new *control = &mchp_pdmc_snd_controls[i]; const struct snd_kcontrol_new *control = &mchp_pdmc_snd_controls[i];
struct snd_ctl_elem_id id; struct snd_ctl_elem_id id;
struct snd_kcontrol *kctl;
int err; int err;
if (component->name_prefix) if (component->name_prefix)
...@@ -400,17 +399,10 @@ static int mchp_pdmc_open(struct snd_soc_component *component, ...@@ -400,17 +399,10 @@ static int mchp_pdmc_open(struct snd_soc_component *component,
id.device = control->device; id.device = control->device;
id.subdevice = control->subdevice; id.subdevice = control->subdevice;
id.index = control->index; id.index = control->index;
kctl = snd_ctl_find_id(component->card->snd_card, &id); err = snd_ctl_remove_id(component->card->snd_card, &id);
if (!kctl) { if (err < 0)
dev_err(component->dev, "Failed to find %s\n", control->name);
continue;
}
err = snd_ctl_remove(component->card->snd_card, kctl);
if (err < 0) {
dev_err(component->dev, "%d: Failed to remove %s\n", err, dev_err(component->dev, "%d: Failed to remove %s\n", err,
control->name); control->name);
continue;
}
} }
return 0; return 0;
......
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