From: "Mark Brown" <broonie@kernel.org>
To: "Srinivas Kandagatla" <srinivas.kandagatla@linaro.org>
Cc: "devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
"spapothi@codeaurora.org" <spapothi@codeaurora.org>,
"lgirdwood@gmail.com" <lgirdwood@gmail.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"vkoul@kernel.org" <vkoul@kernel.org>,
"pierre-louis.bossart@linux.intel.com"
<pierre-louis.bossart@linux.intel.com>
Subject: Re: [alsa-devel] [PATCH v7 2/2] ASoC: codecs: add wsa881x amplifier support
Date: Wed, 9 Oct 2019 17:35:35 +0100 [thread overview]
Message-ID: <20191009163535.GK2036@sirena.org.uk> (raw)
Message-ID: <20191009163535.SqEPv--MMBhlTBPRSDPuCuEICK5dFdKikd8oYrbCPIs@z> (raw)
In-Reply-To: <20191009085108.4950-3-srinivas.kandagatla@linaro.org>
On Wed, Oct 09, 2019 at 09:51:08AM +0100, Srinivas Kandagatla wrote:
> +static const u8 wsa881x_reg_readable[WSA881X_CACHE_SIZE] = {
> +static bool wsa881x_readable_register(struct device *dev, unsigned int reg)
> +{
> + return wsa881x_reg_readable[reg];
u
There's no bounds check and that array size is not...
> +static struct regmap_config wsa881x_regmap_config = {
> + .reg_bits = 32,
> + .val_bits = 8,
> + .cache_type = REGCACHE_RBTREE,
> + .reg_defaults = wsa881x_defaults,
> + .num_reg_defaults = ARRAY_SIZE(wsa881x_defaults),
> + .max_register = WSA881X_MAX_REGISTER,
...what regmap has as max_register. Uusually you'd render as a
switch statement (as you did for volatile) and let the compiler
figure out a sensible way to do the lookup.
> +static void wsa881x_init(struct wsa881x_priv *wsa881x)
> +{
> + struct regmap *rm = wsa881x->regmap;
> + unsigned int val = 0;
> +
> + regmap_read(rm, WSA881X_CHIP_ID1, &wsa881x->version);
> + regcache_cache_only(rm, true);
> + regmap_multi_reg_write(rm, wsa881x_rev_2_0,
> + ARRAY_SIZE(wsa881x_rev_2_0));
> + regcache_cache_only(rm, false);
This looks broken, what is it supposed to be doing? It looks
like it should be a register patch but it's not documented.
> +static const struct snd_kcontrol_new wsa881x_snd_controls[] = {
> + SOC_ENUM("Smart Boost Level", smart_boost_lvl_enum),
> + WSA881X_PA_GAIN_TLV("PA Gain", WSA881X_SPKR_DRV_GAIN,
> + 4, 0xC, 1, pa_gain),
As covered in control-names.rst all volume controls should end in
Volume.
> +static void wsa881x_clk_ctrl(struct snd_soc_component *comp, bool enable)
> +{
> + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(comp);
> +
> + mutex_lock(&wsa881x->res_lock);
What is this lock supposed to be protecting? As far as I can
tell this function is the only place it is used and this function
has exactly one caller which itself has only one caller which is
a DAPM widget and hence needs no locking. It looks awfully like
it should just be a widget itself, or inlined into the single
caller.
> +static void wsa881x_bandgap_ctrl(struct snd_soc_component *comp, bool enable)
> +{
> + struct wsa881x_priv *wsa881x = snd_soc_component_get_drvdata(comp);
Similarly here.
> +static int32_t wsa881x_resource_acquire(struct snd_soc_component *comp,
> + bool enable)
> +{
> + wsa881x_clk_ctrl(comp, enable);
> + wsa881x_bandgap_ctrl(comp, enable);
> +
> + return 0;
> +}
There's no corresponding disables.
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
next prev parent reply other threads:[~2019-10-13 0:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-09 8:51 [alsa-devel] [PATCH v7 0/2] ASoC: codecs: Add WSA881x Smart Speaker amplifier support Srinivas Kandagatla
2019-10-09 8:51 ` [alsa-devel] [PATCH v7 1/2] dt-bindings: ASoC: Add WSA881x bindings Srinivas Kandagatla
2019-10-09 8:51 ` [alsa-devel] [PATCH v7 2/2] ASoC: codecs: add wsa881x amplifier support Srinivas Kandagatla
2019-10-09 16:35 ` Mark Brown [this message]
2019-10-09 16:35 ` Mark Brown
2019-10-10 9:28 ` Srinivas Kandagatla
2019-10-10 13:23 ` Mark Brown
2019-10-10 13:38 ` Srinivas Kandagatla
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=20191009163535.GK2036@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=pierre-louis.bossart@linux.intel.com \
--cc=spapothi@codeaurora.org \
--cc=srinivas.kandagatla@linaro.org \
--cc=vkoul@kernel.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).