From: sashiko-bot@kernel.org
To: "James Calligeros" <jcalligeros99@gmail.com>
Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v4 06/22] ASoC: ops: Introduce 'soc_set_enum_kctl'
Date: Tue, 03 Nov 2026 08:06:51 +0000 [thread overview]
Message-ID: <sashiko-outbox-194797@kernel.org> (raw)
In-Reply-To: <20261103-macaudio-v4-6-637484efe46d@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] ASoC: ops: return value mismatch with kernel-doc in snd_soc_set_enum_kctl()
- [Low] ASoC: ops: commit subject names static helper instead of snd_soc_set_enum_kctl()
--
commit 2c9f602d361cf2e55c7e8d05183ffda527ff209d
Author: Martin Povišer <povik+lin@cutebit.org>
ASoC: ops: Introduce 'soc_set_enum_kctl'
This commit introduces snd_soc_set_enum_kctl() and its internal helper
soc_set_enum_kctl() so machine drivers can set enumerated ALSA controls to a
desired string value, such as during fixup_controls.
> ASoC: ops: Introduce 'soc_set_enum_kctl'
>
> The new function is to be used to set enumerated controls to desired
> values. It is something a machine driver may call in fixup_controls.
>
> Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
> Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
[Severity: Low]
Should the commit subject refer to snd_soc_set_enum_kctl instead of
soc_set_enum_kctl?
In sound/soc/soc-ops.c, soc_set_enum_kctl() is a file-local static helper,
whereas snd_soc_set_enum_kctl() is the exported function declared in
include/sound/soc.h for machine drivers to call in fixup_controls.
> diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c
> index 1d60e290e40e4..1cd7f1caefe4d 100644
> --- a/sound/soc/soc-ops.c
> +++ b/sound/soc/soc-ops.c
> @@ -505,6 +505,73 @@ int snd_soc_ctl_activate(struct snd_soc_card *card,
> }
> EXPORT_SYMBOL_GPL(snd_soc_ctl_activate);
>
> +static int soc_set_enum_kctl(struct snd_kcontrol *kctl, const char *value)
> +{
[ ... ]
> + for (i = 0; i < info->count; i++)
> + evalue->value.enumerated.item[i] = sel;
> +
> + return kctl->put(kctl, evalue);
> +}
> +
> +/**
> + * snd_soc_set_enum_kctl - Set enumerated control matching a name
> + *
> + * @card: where to look for the controls
> + * @name: name
> + * @value: string value to set the controls to
> + *
> + * Return 0 on success, else error.
> + */
> +int snd_soc_set_enum_kctl(struct snd_soc_card *card,
> + const char *name, const char *value)
> +{
> + struct snd_kcontrol *kctl;
> +
> + kctl = snd_soc_card_get_kcontrol(card, name);
> + if (!kctl) {
> + dev_dbg(card->dev, "Tried to set unknown control '%s' to '%s'\n", name, value);
> + return -EINVAL;
> + }
> +
> + return soc_set_enum_kctl(kctl, value);
> +}
[Severity: Medium]
Does snd_soc_set_enum_kctl() return 1 instead of 0 when the control value is
updated, contradicting its kernel-doc comment?
When snd_soc_set_enum_kctl() calls soc_set_enum_kctl() to change an
enumerated control to a value different from its current state,
soc_set_enum_kctl() directly returns the result of kctl->put(kctl, evalue).
In ALSA and ASoC, snd_kcontrol_put_t callbacks such as
snd_soc_put_enum_double() and snd_soc_dapm_put_enum_double() return 1 when
the control value changes, 0 when it is unchanged, and a negative error code
on failure. Any caller checking for a non-zero return value based on the
documented contract would treat a changed control value as an error.
In the same file, snd_soc_clip_to_platform_max() normalizes the kctl->put()
return value to 0:
sound/soc/soc-ops.c:snd_soc_clip_to_platform_max() {
...
ret = kctl->put(kctl, uctl);
if (ret < 0)
return ret;
return 0;
}
whereas snd_soc_ctl_activate() documents the tri-state return value with a
colon after Return as expected by kernel-doc:
* Return: 0 if unchanged, 1 if changed, or a negative error code on failure.
Should soc_set_enum_kctl() clamp non-negative returns from kctl->put() to 0,
or should the kernel-doc Return: section for snd_soc_set_enum_kctl() document
that it returns 0 if unchanged, 1 if changed, or a negative error code on
failure?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261103-macaudio-v4-0-637484efe46d@gmail.com?part=6
next prev parent reply other threads:[~2026-11-03 8:06 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 7:39 [PATCH v4 00/22] Add speaker and headset jack support for Apple Silicon Macs James Calligeros
2026-11-03 7:39 ` [PATCH v4 01/22] ASoC: dt-bindings: cs42l84: Allow referenced dai-common properties James Calligeros
2026-11-03 7:53 ` sashiko-bot
2026-11-04 10:48 ` Krzysztof Kozlowski
2026-11-04 10:59 ` James Calligeros
2026-11-03 7:39 ` [PATCH v4 02/22] ASoC: dt-bindings: cs42l42: " James Calligeros
2026-11-03 7:51 ` sashiko-bot
2026-11-04 10:49 ` Krzysztof Kozlowski
2026-11-04 10:52 ` Krzysztof Kozlowski
2026-11-04 10:58 ` James Calligeros
2026-11-04 11:04 ` Krzysztof Kozlowski
2026-11-03 7:39 ` [PATCH v4 03/22] ASoC: dt-bindings: tdm-slot: Allow indexed TDM idle properties James Calligeros
2026-11-03 7:39 ` [PATCH v4 04/22] ASoC: dt-bindings: Add binding for Apple Silicon Mac audio James Calligeros
2026-11-03 7:58 ` sashiko-bot
2026-11-03 7:39 ` [PATCH v4 05/22] ASoC: ops: Introduce 'snd_soc_ctl_activate' James Calligeros
2026-11-03 7:39 ` [PATCH v4 06/22] ASoC: ops: Introduce 'soc_set_enum_kctl' James Calligeros
2026-11-03 8:06 ` sashiko-bot [this message]
2026-11-03 7:39 ` [PATCH v4 07/22] ASoC: card: Let 'fixup_controls' return errors James Calligeros
2026-11-03 7:39 ` [PATCH v4 08/22] ASoC: tas2770: Add compatible for TAS5770L James Calligeros
2026-11-03 7:39 ` [PATCH v4 09/22] ASoC: apple: Add macaudio machine driver James Calligeros
2026-11-03 8:28 ` sashiko-bot
2026-11-03 7:39 ` [PATCH v4 10/22] arm64: dts: apple: t8103-jxxx: Add regulators for CS42L83 power supply James Calligeros
2026-11-03 7:39 ` [PATCH v4 11/22] arm64: dts: apple: t8103-j274: Add speaker/headset jack nodes James Calligeros
2026-11-03 8:15 ` sashiko-bot
2026-11-03 7:40 ` [PATCH v4 12/22] arm64: dts: apple: t8103-j313: " James Calligeros
2026-11-03 8:36 ` sashiko-bot
2026-11-03 7:40 ` [PATCH v4 13/22] arm64: dts: apple: t8103-j293: " James Calligeros
2026-11-03 8:52 ` sashiko-bot
2026-11-03 7:40 ` [PATCH v4 14/22] arm64: dts: apple: t8103-j45x: Add headset " James Calligeros
2026-11-03 7:40 ` [PATCH v4 15/22] arm64: dts: apple: t8112-j413: Add speaker/headset " James Calligeros
2026-11-03 7:40 ` [PATCH v4 16/22] arm64: dts: apple: t8112-j415: " James Calligeros
2026-11-03 7:40 ` [PATCH v4 17/22] arm64: dts: apple: t8112-j473: " James Calligeros
2026-11-03 7:40 ` [PATCH v4 18/22] arm64: dts: apple: t8112-j493: " James Calligeros
2026-11-03 7:40 ` [PATCH v4 19/22] arm64: dts: apple: t600x-j31x: " James Calligeros
2026-11-03 7:40 ` [PATCH v4 20/22] arm64: dts: apple: t600x-j375: " James Calligeros
2026-11-03 7:40 ` [PATCH v4 21/22] arm64: dts: apple: t602x-j41x: " James Calligeros
2026-11-03 7:40 ` [PATCH v4 22/22] arm64: dts: apple: t602x-j47x: " James Calligeros
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-194797@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jcalligeros99@gmail.com \
--cc=linux-sound@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.