Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ricardo Rivera-Matos" <rriveram@opensource.cirrus.com>
Cc: conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v4 2/2] ASoC: cs35l45: Adds support for SYNC bus
Date: Fri, 21 Aug 2026 22:49:14 +0000	[thread overview]
Message-ID: <20260821224915.37A2E1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260821-sound-for-next-cs35l45-sync-v4-v4-2-20d3a07c3b8d@opensource.cirrus.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Spurious ALSA event generation in `cs35l45_sync_en_put` due to unnormalized boolean comparison.
--

--- Patch [2]: [PATCH v4 2/2] ASoC: cs35l45: Adds support for SYNC bus ---
commit 7447f2ac68a757cce556917899f132a9bfc50231
Author: Ricardo Rivera-Matos <rriveram@opensource.cirrus.com>

ASoC: cs35l45: Adds support for SYNC bus

Adds support for the multidevice synchronization (SYNC) bus. Initial support
only includes software (SW) data packets.

> diff --git a/sound/soc/codecs/cs35l45.c b/sound/soc/codecs/cs35l45.c
> index a032bb23b4ac7..2d6360bc555b3 100644
> --- a/sound/soc/codecs/cs35l45.c
> +++ b/sound/soc/codecs/cs35l45.c
[ ... ]
> @@ -195,6 +196,46 @@ static int cs35l45_activate_ctl(struct snd_soc_component *component,
>  	return 0;
>  }
[ ... ]
> +static int cs35l45_sync_en_put(struct snd_kcontrol *kcontrol,
> +				      struct snd_ctl_elem_value *ucontrol)
> +{
> +	struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
> +	struct cs35l45_private *cs35l45 =
> +			snd_soc_component_get_drvdata(component);
> +	struct snd_soc_dapm_context *dapm =
> +			snd_soc_component_to_dapm(component);
> +
> +	snd_soc_dapm_mutex_lock(dapm);
> +
> +	if (ucontrol->value.integer.value[0] == cs35l45->sync_en) {

[Severity: Medium]
Will this comparison cause spurious ALSA events if userspace writes a non-zero,
non-one value? 

Since cs35l45->sync_en is a bool, if userspace writes a value like 2, the
comparison (2 == 1) evaluates to false. This bypasses the short-circuit check.

> +		snd_soc_dapm_mutex_unlock(dapm);
> +		return 0;
> +	}
> +
> +	if ((bool)ucontrol->value.integer.value[0])
> +		regmap_set_bits(cs35l45->regmap, CS35L45_BLOCK_ENABLES2, CS35L45_SYNC_EN_MASK);
> +	else
> +		regmap_clear_bits(cs35l45->regmap, CS35L45_BLOCK_ENABLES2, CS35L45_SYNC_EN_MASK);
> +
> +	cs35l45->sync_en = ucontrol->value.integer.value[0];

When the unnormalized value is later assigned to the bool, it normalizes to 1. 
The function then returns 1, incorrectly generating a state change notification
even though the logical state didn't change.

Should the input value be normalized to a boolean before comparing and
assigning?

> +
> +	snd_soc_dapm_mutex_unlock(dapm);
> +
> +	return 1;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260821-sound-for-next-cs35l45-sync-v4-v4-0-20d3a07c3b8d@opensource.cirrus.com?part=2

      reply	other threads:[~2026-08-21 22:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-21 22:41 [PATCH v4 0/2] Introduces MDSYNC support for CS35L45 Ricardo Rivera-Matos
2026-08-21 22:41 ` [PATCH v4 1/2] ASoC: dt-bindings: cs35l45: Adds SYNC properties Ricardo Rivera-Matos
2026-08-27 12:31   ` Krzysztof Kozlowski
2026-08-21 22:41 ` [PATCH v4 2/2] ASoC: cs35l45: Adds support for SYNC bus Ricardo Rivera-Matos
2026-08-21 22:49   ` sashiko-bot [this message]

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=20260821224915.37A2E1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=rriveram@opensource.cirrus.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox