From: Mark Brown <broonie@kernel.org>
To: Kevin Cernekee <cernekee@chromium.org>
Cc: lgirdwood@gmail.com, dgreid@chromium.org, abrestic@chromium.org,
olofj@chromium.org, alsa-devel@alsa-project.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] ASoC: tas571x: New driver for TI TAS571x power amplifiers
Date: Sat, 18 Apr 2015 12:36:32 +0100 [thread overview]
Message-ID: <20150418113632.GE26185@sirena.org.uk> (raw)
In-Reply-To: <1429134141-17924-2-git-send-email-cernekee@chromium.org>
[-- Attachment #1: Type: text/plain, Size: 3952 bytes --]
On Wed, Apr 15, 2015 at 02:42:20PM -0700, Kevin Cernekee wrote:
This looks mostly good but several things below, all of which should be
straightforward to fix.
> +static int tas571x_set_sysclk(struct snd_soc_dai *dai,
> + int clk_id, unsigned int freq, int dir)
> +{
> + /*
> + * TAS5717 datasheet pg 21: "The DAP can autodetect and set the
> + * internal clock-control logic to the appropriate settings for all
> + * supported clock rates as defined in the clock control register."
> + */
> + return 0;
> +}
Remove empty functions, at best they waste space at worst they break
things.
> + val += (clamp(params_width(params), 16, 24) >> 2) - 4;
Please write this more clearly or comment it (preferably the former),
it's hard to tell what it's supposed to do and therefore hard to tell if
it's doing it correctly.
> +static int tas571x_set_shutdown(struct tas571x_private *priv, bool is_shutdown)
> +{
> + return regmap_update_bits(priv->regmap, TAS571X_SYS_CTRL_2_REG,
> + TAS571X_SYS_CTRL_2_SDN_MASK,
> + is_shutdown ? TAS571X_SYS_CTRL_2_SDN_MASK : 0);
> +}
> + ret = tas571x_set_shutdown(priv, false);
> + if (ret)
> + return ret;
> + break;
> + case SND_SOC_BIAS_STANDBY:
> + ret = tas571x_set_shutdown(priv, true);
> + if (ret)
> + return ret;
This looks like it'd be clearer just as direct register updates, I'm not
sure a function to set a single bit is addinng much.
> + case SND_SOC_BIAS_OFF:
> + /* Note that this kills I2C accesses. */
> + assert_pdn = 1;
No, the GPIO set associated with it kills I2C access. I'd also expect
to see the regmap being marked cache only before we do this and a resync
of the register map when we power back up (assuming that is actually a
power down).
> +static const struct snd_kcontrol_new tas5711_controls[] = {
> + SOC_SINGLE_TLV("Master Volume",
> + TAS571X_MVOL_REG,
> + 0, 0xff, 1, tas5711_volume_tlv),
All these controls will be brokenn if the I2C access goes away.
> +static const struct snd_soc_codec_driver tas571x_codec = {
> + .set_bias_level = tas571x_set_bias_level,
> + .suspend_bias_off = true,
Why not idle_bias_off? It looks like power up takes no meaningful
time.
> +static int tas571x_register_size(struct tas571x_private *priv, unsigned int reg)
> +{
> + switch (reg) {
> + case TAS571X_MVOL_REG:
> + case TAS571X_CH1_VOL_REG:
> + case TAS571X_CH2_VOL_REG:
> + return priv->dev_id == TAS571X_ID_5711 ? 1 : 2;
Nest switch statements please, that way things work better if another
variant turns up.
> + /*
> + * This will fall back to the dummy regulator if nothing is specified
> + * in DT.
> + */
The driver doesn't care, it may not even be on a system using DT.
> + if (devm_regulator_bulk_get(dev, TAS571X_NUM_SUPPLIES,
> + priv->supplies)) {
> + dev_err(dev, "Failed to get supplies\n");
> + return -EINVAL;
> + }
Don't discard error codes from functions you call, log them and provide
them to calllers. The above is broken for probe deferral for example.
> + priv->pdn_gpio = devm_gpiod_get(dev, "pdn");
> + if (!IS_ERR(priv->pdn_gpio)) {
> + gpiod_direction_output(priv->pdn_gpio, 1);
> + } else if (PTR_ERR(priv->pdn_gpio) != -ENOENT &&
> + PTR_ERR(priv->pdn_gpio) != -ENOSYS) {
> + dev_warn(dev, "error requesting pdn_gpio: %ld\n",
> + PTR_ERR(priv->pdn_gpio));
> + }
This should at least be handling probe deferral, it's not clear why it
doesn't just error out in the cases where it gets an error. Similarly
for the reset GPIO.
> + /*
> + * The master volume defaults to 0x3ff (mute), but we ignore
> + * (zero) the LSB because the hardware step size is 0.125 dB
> + * and TLV_DB_SCALE_ITEM has a resolution of 0.01 dB.
> + */
> + if (regmap_write(priv->regmap, TAS571X_MVOL_REG, 0x3fe))
> + return -EIO;
I don't understand this - is the LSB a mute bit or sommething?
> +#ifndef _TAS571X_H
> +#define _TAS571X_H
> +
> +#include <sound/pcm.h>
Why is this needed in the header?
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2015-04-18 11:36 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-15 21:42 [PATCH 1/3] ASoC: tas571x: Add DT binding document Kevin Cernekee
2015-04-15 21:42 ` [PATCH 2/3] ASoC: tas571x: New driver for TI TAS571x power amplifiers Kevin Cernekee
2015-04-16 12:57 ` [alsa-devel] " Lars-Peter Clausen
2015-04-18 11:39 ` Mark Brown
2015-04-20 20:56 ` Kevin Cernekee
2015-04-20 21:14 ` Mark Brown
2015-04-18 11:36 ` Mark Brown [this message]
2015-04-18 16:16 ` Kevin Cernekee
2015-04-18 17:11 ` Mark Brown
2015-04-18 20:07 ` Kevin Cernekee
2015-04-20 12:21 ` Mark Brown
2015-04-20 15:12 ` Kevin Cernekee
2015-04-20 16:05 ` Andrew Bresticker
2015-04-20 20:14 ` Mark Brown
2015-04-24 0:47 ` Kevin Cernekee
2015-04-24 9:28 ` Mark Brown
2015-04-24 13:52 ` Kevin Cernekee
2015-04-24 16:50 ` Mark Brown
2015-04-15 21:42 ` [PATCH 3/3] MAINTAINERS: Add entry for tas571x ASoC codec driver Kevin Cernekee
2015-04-18 11:16 ` [PATCH 1/3] ASoC: tas571x: Add DT binding document Mark Brown
2015-04-20 21:16 ` Kevin Cernekee
2015-04-20 21:18 ` Kevin Cernekee
2015-04-20 22:03 ` Mark Brown
2015-04-20 22:48 ` Kevin Cernekee
2015-04-21 16:45 ` 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=20150418113632.GE26185@sirena.org.uk \
--to=broonie@kernel.org \
--cc=abrestic@chromium.org \
--cc=alsa-devel@alsa-project.org \
--cc=cernekee@chromium.org \
--cc=devicetree@vger.kernel.org \
--cc=dgreid@chromium.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=olofj@chromium.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
all inboxes | Powered by JetHome®