From: Mark Brown <broonie@kernel.org>
To: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
Cc: lgirdwood@gmail.com, robh+dt@kernel.org,
krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org,
perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/3] ASoC: Add ESS ES9218P codec driver
Date: Mon, 15 May 2023 19:49:47 +0900 [thread overview]
Message-ID: <ZGIOSwDduR+Ihe4p@finisterre.sirena.org.uk> (raw)
In-Reply-To: <20230515074021.31257-1-aidanmacdonald.0x0@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1693 bytes --]
On Mon, May 15, 2023 at 08:40:19AM +0100, Aidan MacDonald wrote:
> +++ b/sound/soc/codecs/ess-es9218p.c
> @@ -0,0 +1,805 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2022-2023 Aidan MacDonald
> + */
Please make the entire comment a C++ one so things look more
intentional.
> +enum es9218p_supply_id {
> + ES9218P_SUPPLY_AVDD,
> + ES9218P_SUPPLY_VCCA,
> + ES9218P_SUPPLY_AVCC3V3,
> + ES9218P_SUPPLY_AVCC1V8,
> + ES9218P_NUM_SUPPLIES
> +};
> +
> +static const char * const es9218p_supply_names[ES9218P_NUM_SUPPLIES] = {
> + "avdd",
> + "vcca",
> + "avcc3v3",
> + "avcc1v8",
> +};
These could easily get out of sync, it would be better to explicitly
assign the names to the slots identified by the constants
[ES9218P_SUPPLY_VCCA] = "vcca",
for example.
> +static int es9218p_wide_write(struct regmap *regmap, unsigned int reg,
> + int count, unsigned int value)
> +{
> + u8 data[4];
> + int i;
> +
> + for (i = 0; i < count; i++) {
> + data[i] = value & 0xff;
> + value >>= 8;
> + }
This needs a bounds check to make sure we don't overflow data.
> +static int outlevel_put(struct snd_kcontrol *kcontrol,
> + struct snd_ctl_elem_value *ucontrol)
> +{
> + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
> + struct es9218p_priv *priv = snd_soc_component_get_drvdata(component);
> +
> + priv->output_2v = ucontrol->value.enumerated.item[0];
> + es9218p_update_amp_mode(component);
> + return 1;
> +}
Running the mixer-test selftest on a card with this driver will report
that the driver generates spurious events when there is no change in
value and doesn't validate input. Similar issues apply to the other
enums.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2023-05-15 10:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-15 7:40 Aidan MacDonald
2023-05-15 7:40 ` [PATCH v2 2/3] dt-bindings: vendor-prefixes: Add ESS Technology vendor prefix Aidan MacDonald
2023-05-15 7:40 ` [PATCH v2 3/3] ASoC: dt-bindings: Add ESS ES9218P codec Aidan MacDonald
2023-05-15 12:03 ` Krzysztof Kozlowski
2023-05-15 10:49 ` Mark Brown [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=ZGIOSwDduR+Ihe4p@finisterre.sirena.org.uk \
--to=broonie@kernel.org \
--cc=aidanmacdonald.0x0@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=robh+dt@kernel.org \
--cc=tiwai@suse.com \
/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
all inboxes | Powered by JetHome®