[RESEND PATCH v1 5/6] staging: greybus: audio: Add helper APIs for dynamic audio modules
Dan Carpenter
dan.carpenter at oracle.com
Tue Jun 2 14:44:39 CEST 2020
On Tue, Jun 02, 2020 at 10:51:14AM +0530, Vaibhav Agarwal wrote:
> +static int gbaudio_remove_controls(struct snd_card *card, struct device *dev,
> + const struct snd_kcontrol_new *controls,
> + int num_controls, const char *prefix)
> +{
> + int i, err;
> +
> + for (i = 0; i < num_controls; i++) {
> + const struct snd_kcontrol_new *control = &controls[i];
> + struct snd_ctl_elem_id id;
> + struct snd_kcontrol *kctl;
> +
> + if (prefix)
> + snprintf(id.name, sizeof(id.name), "%s %s", prefix,
> + control->name);
> + else
> + strlcpy(id.name, control->name, sizeof(id.name));
> + id.numid = 0;
> + id.iface = control->iface;
> + id.device = control->device;
> + id.subdevice = control->subdevice;
> + id.index = control->index;
> + kctl = snd_ctl_find_id(card, &id);
> + if (!kctl) {
> + dev_err(dev, "%d: Failed to find %s\n", err,
> + control->name);
> + return -ENOENT;
I feel like this should be a continue instead of a return.
> + }
> + err = snd_ctl_remove(card, kctl);
> + if (err < 0) {
> + dev_err(dev, "%d: Failed to remove %s\n", err,
> + control->name);
> + return err;
Probably here as well. The caller doesn't actually check for errors.
> + }
> + }
> + return 0;
> +}
More information about the Alsa-devel
mailing list