devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: robh@kernel.org, devicetree@vger.kernel.org, perex@perex.cz,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	lgirdwood@gmail.com
Subject: Re: [PATCH v8 6/9] ASoC: codecs: wcd938x: add basic controls
Date: Tue, 8 Jun 2021 14:59:33 +0100	[thread overview]
Message-ID: <20210608135933.GE4200@sirena.org.uk> (raw)
In-Reply-To: <20210601113158.16085-7-srinivas.kandagatla@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 1367 bytes --]

On Tue, Jun 01, 2021 at 12:31:55PM +0100, Srinivas Kandagatla wrote:

> +static int wcd938x_rx_hph_mode_put(struct snd_kcontrol *kcontrol,
> +				   struct snd_ctl_elem_value *ucontrol)
> +{
> +	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
> +	struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);
> +
> +	wcd938x->hph_mode = ucontrol->value.enumerated.item[0];
> +
> +	return 0;
> +}

_put() should return true if it made a change, the same bug is present
in a lot of other drivers too.

> +static const struct snd_kcontrol_new wcd9380_snd_controls[] = {
> +	SOC_ENUM_EXT("RX HPH Mode", rx_hph_mode_mux_enum_wcd9380,
> +		     wcd938x_rx_hph_mode_get, wcd938x_rx_hph_mode_put),
> +	SOC_ENUM_EXT("TX0 MODE", tx_mode_mux_enum_wcd9380[0],
> +		     wcd938x_tx_mode_get, wcd938x_tx_mode_put),
> +	SOC_ENUM_EXT("TX1 MODE", tx_mode_mux_enum_wcd9380[1],
> +		     wcd938x_tx_mode_get, wcd938x_tx_mode_put),
> +	SOC_ENUM_EXT("TX2 MODE", tx_mode_mux_enum_wcd9380[2],
> +		     wcd938x_tx_mode_get, wcd938x_tx_mode_put),
> +	SOC_ENUM_EXT("TX3 MODE", tx_mode_mux_enum_wcd9380[3],
> +		     wcd938x_tx_mode_get, wcd938x_tx_mode_put),
> +};

Please don't use this pattern of indexing into arrays by absolute
number, it's error prone and hard to read.  Just declare static
variables for the enums and reference them individually.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2021-06-08 13:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-01 11:31 [PATCH v8 0/9] ASoC: codecs: add wcd938x support Srinivas Kandagatla
2021-06-01 11:31 ` [PATCH v8 1/9] ASoC: dt-bindings: wcd938x: add bindings for wcd938x Srinivas Kandagatla
2021-06-01 11:31 ` [PATCH v8 2/9] ASoC: codecs: wcd-clsh: add new version support Srinivas Kandagatla
2021-06-01 11:31 ` [PATCH v8 3/9] ASoC: codecs: wcd938x: add basic driver Srinivas Kandagatla
2021-06-08 14:12   ` Mark Brown
2021-06-08 15:20     ` Srinivas Kandagatla
2021-06-01 11:31 ` [PATCH v8 4/9] ASoC: dt-bindings: wcd938x-sdw: add bindings for wcd938x-sdw Srinivas Kandagatla
2021-06-01 11:31 ` [PATCH v8 5/9] ASoC: codecs: wcd938x-sdw: add SoundWire driver Srinivas Kandagatla
2021-06-01 11:31 ` [PATCH v8 6/9] ASoC: codecs: wcd938x: add basic controls Srinivas Kandagatla
2021-06-08 13:59   ` Mark Brown [this message]
2021-06-08 15:20     ` Srinivas Kandagatla
2021-06-01 11:31 ` [PATCH v8 7/9] ASoC: codecs: wcd938x: add playback dapm widgets Srinivas Kandagatla
2021-06-01 11:31 ` [PATCH v8 8/9] ASoC: codecs: wcd938x: add capture " Srinivas Kandagatla
2021-06-01 11:31 ` [PATCH v8 9/9] ASoC: codecs: wcd938x: add audio routing Srinivas Kandagatla
2021-06-14 19:53 ` [PATCH v8 0/9] ASoC: codecs: add wcd938x support Mark Brown

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=20210608135933.GE4200@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=robh@kernel.org \
    --cc=srinivas.kandagatla@linaro.org \
    /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;
as well as URLs for NNTP newsgroup(s).