Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: alsa-devel@alsa-project.org, Liam Girdwood <lgirdwood@gmail.com>
Subject: Re: [PATCH 2/2] ASoC: Add ADAU1977 driver
Date: Mon, 3 Feb 2014 18:40:26 +0000	[thread overview]
Message-ID: <20140203184026.GL22609@sirena.org.uk> (raw)
In-Reply-To: <1391439428-3198-2-git-send-email-lars@metafoo.de>


[-- Attachment #1.1: Type: text/plain, Size: 2716 bytes --]

On Mon, Feb 03, 2014 at 03:57:08PM +0100, Lars-Peter Clausen wrote:
> This patch adds support for the ADAU1977, ADAU1978 and ADAU1979 audio CODEC
> devices. They are a family of 4-channel differntial input audio ADC devices.
> They can be connected to either a SPI or I2C bus.

To avoid tedious iteration of the driver for the DT bindings it's
generally helpful to submit the DT bindings as a separate patch.

>  sound/soc/codecs/adau1977-i2c.c        |  58 ++
>  sound/soc/codecs/adau1977-spi.c        |  73 +++

This isn't the general style, if we want to do that we should be
converting all the other drivers.

> +config SND_SOC_ADAU1977
> +	tristate
> +
> +config SND_SOC_ADAU1977_I2C
> +	tristate
> +	select SND_SOC_ADAU1977
> +
> +config SND_SOC_ADAU1977_SPI
> +	tristate
> +	select SND_SOC_ADAU1977
> +

Please make these user visible if OF is in use.

> +static struct i2c_driver adau1977_i2c_driver = {
> +	.driver = {
> +		.name = "adau1977",
> +		.owner = THIS_MODULE,
> +	},
> +	.probe = adau1977_i2c_probe,
> +	.remove = adau1977_i2c_remove,
> +	.id_table = adau1977_i2c_ids,
> +};

You should have explicit OF IDs.

> +	if (rate >= 8000 && rate <= 12000)
> +		ctrl0 = ADAU1977_SAI_CTRL0_FS_8000_12000;
> +	else if (rate >= 16000 && rate <= 24000)
> +		ctrl0 = ADAU1977_SAI_CTRL0_FS_16000_24000;
> +	else if (rate >= 32000 && rate <= 48000)
> +		ctrl0 = ADAU1977_SAI_CTRL0_FS_32000_48000;
> +	else if (rate >= 64000 && rate <= 96000)
> +		ctrl0 = ADAU1977_SAI_CTRL0_FS_64000_96000;
> +	else if (rate >= 128000 && rate <= 192000)
> +		ctrl0 = ADAU1977_SAI_CTRL0_FS_128000_192000;
> +	else
> +		return -EINVAL;

There's a couple of these rate range if trees - how about a lookup in an
array?

> +	if (!enable) {
> +		ret = regmap_update_bits(adau1977->regmap, ADAU1977_REG_POWER,
> +			ADAU1977_POWER_PWUP, 0);
> +		regcache_mark_dirty(adau1977->regmap);
> +	} else {
> +		ret = regulator_enable(adau1977->avdd_reg);
> +		if (ret)
> +			return ret;
> +		if (adau1977->dvdd_reg) {
> +			ret = regulator_enable(adau1977->dvdd_reg);
> +			if (ret)
> +				goto err_disable_avdd;
> +		}
> +	}
> +
> +	if (adau1977->reset_gpio)
> +		gpiod_set_value(adau1977->reset_gpio, enable);

_cansleep().

I'm not sure all this enable/disable logic within the function is
helping clarity here.  There seems to be no meaningful sharing between
the two branches, separate functions for power up and power down is
probably going to be clearer.

> +static int adau1977_mute(struct snd_soc_dai *dai, int mute, int stream)
> +{
> +	struct adau1977 *adau1977 = snd_soc_codec_get_drvdata(dai->codec);
> +	unsigned int val;
> +
> +	if (stream == SNDRV_PCM_STREAM_PLAYBACK)
> +		return 0;

Why would this ever be called for an ADC?

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



  reply	other threads:[~2014-02-03 18:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-03 14:57 [PATCH 1/2] devicetree: Add devicetree bindings documentation for the ADAU1977 Lars-Peter Clausen
2014-02-03 14:57 ` [PATCH 2/2] ASoC: Add ADAU1977 driver Lars-Peter Clausen
2014-02-03 18:40   ` Mark Brown [this message]
2014-02-04 11:16     ` Lars-Peter Clausen
2014-02-04 12:12       ` Mark Brown
2014-02-04 13:31         ` Lars-Peter Clausen
2014-02-04 14:10           ` Mark Brown
     [not found] ` <1391439428-3198-1-git-send-email-lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2014-02-03 15:15   ` [PATCH 1/2] devicetree: Add devicetree bindings documentation for the ADAU1977 Geert Uytterhoeven
     [not found]     ` <CAMuHMdVQGZE+1YuWCnJefzy08kb6vNmRN8k+1-K82BubOBAOxQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-02-04 11:48       ` Lars-Peter Clausen

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=20140203184026.GL22609@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=lars@metafoo.de \
    --cc=lgirdwood@gmail.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