Commit 6eca6914 authored by Takashi Iwai's avatar Takashi Iwai

staging: greybus: audio_helper: Use snd_ctl_remove_id()

Use the standard snd_ctl_remove_id() helper function instead of open
code.  This allows us to reduce the manual card->rwsem lock in the
caller side.
Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Johan Hovold <johan@kernel.org>
Cc: Alex Elder <elder@kernel.org>
Cc: greybus-dev@lists.linaro.org
Link: https://lore.kernel.org/r/20230718141304.1032-3-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent d4e99962
...@@ -149,7 +149,6 @@ static int gbaudio_remove_controls(struct snd_card *card, struct device *dev, ...@@ -149,7 +149,6 @@ static int gbaudio_remove_controls(struct snd_card *card, struct device *dev,
for (i = 0; i < num_controls; i++) { for (i = 0; i < num_controls; i++) {
const struct snd_kcontrol_new *control = &controls[i]; const struct snd_kcontrol_new *control = &controls[i];
struct snd_ctl_elem_id id; struct snd_ctl_elem_id id;
struct snd_kcontrol *kctl;
if (prefix) if (prefix)
snprintf(id.name, sizeof(id.name), "%s %s", prefix, snprintf(id.name, sizeof(id.name), "%s %s", prefix,
...@@ -161,17 +160,10 @@ static int gbaudio_remove_controls(struct snd_card *card, struct device *dev, ...@@ -161,17 +160,10 @@ static int gbaudio_remove_controls(struct snd_card *card, struct device *dev,
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(card, &id); err = snd_ctl_remove_id(card, &id);
if (!kctl) { if (err < 0)
dev_err(dev, "Failed to find %s\n", control->name);
continue;
}
err = snd_ctl_remove(card, kctl);
if (err < 0) {
dev_err(dev, "%d: Failed to remove %s\n", err, dev_err(dev, "%d: Failed to remove %s\n", err,
control->name); control->name);
continue;
}
} }
return 0; return 0;
} }
...@@ -181,11 +173,7 @@ int gbaudio_remove_component_controls(struct snd_soc_component *component, ...@@ -181,11 +173,7 @@ int gbaudio_remove_component_controls(struct snd_soc_component *component,
unsigned int num_controls) unsigned int num_controls)
{ {
struct snd_card *card = component->card->snd_card; struct snd_card *card = component->card->snd_card;
int err;
down_write(&card->controls_rwsem); return gbaudio_remove_controls(card, component->dev, controls,
err = gbaudio_remove_controls(card, component->dev, controls, num_controls, component->name_prefix);
num_controls, component->name_prefix);
up_write(&card->controls_rwsem);
return err;
} }
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