Re: [PATCH v2 06/21] ASoC: ops: Introduce 'snd_soc_deactivate_kctl'
From: Cezary Rojewski
Date: Fri Oct 09 2026 - 04:23:43 EST
On 10/4/2026 8:03 AM, James Calligeros wrote:
> From: Martin Povišer <povik+lin@xxxxxxxxxxx>
>
> The new function can be used to deactivate controls. It is something
> a machine driver may call in fixup_controls.
> +/**
> + * snd_soc_deactivate_kctl - Activate/deactivate control matching a name
> + *
> + * @card: where to look for the controls
> + * @name: name
> + * @active: non-zero to activate, zero to deactivate
> + *
> + * Return 0 for success, else error.
> + */
> +int snd_soc_deactivate_kctl(struct snd_soc_card *card,
The name sounds weird with 'int active' in its parameter list. Either
pair of wrappers:
snd_soc_ctl_activate()
snd_soc_ctl_deactivate()
or something of snd_soc_ctl_set_status() sort. I see that sound/core
uses: snd_ctl_activate_id(). Perhaps snd_soc_ctl_activate() is winner
here by being cohesive with sound/core even with some confusion around
'int activate' part.
> + const char *name, int active)
> +{
> + struct snd_kcontrol *kctl;
> + int ret = -EINVAL;
> +
> + /* Sanity check for name */
> + if (unlikely(!name))
> + return -EINVAL;
Not a fan of unlikely() in not performance-critical code.
> +
> + kctl = snd_soc_card_get_kcontrol(card, name);
> +
> + if (kctl) {
> + ret = snd_ctl_activate_id(card->snd_card, &kctl->id, active);
> + if (ret < 0)
> + return ret;
The if-statement can be dropped.
> + } else {
> + dev_dbg(card->dev, "Tried to de/activate unknown control '%s'\n",
> + name);
One line.
> + }
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(snd_soc_deactivate_kctl);
> +