From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: Michael Williamson <michael.williamson@criticallink.com>
Cc: alsa-devel@alsa-project.org, lrg@ti.com
Subject: Re: [RFC PATCH 1/1] ASoC: dsd1791: Introduce driver for TI DSD1791 stereo codec
Date: Thu, 15 Dec 2011 15:16:22 +0800 [thread overview]
Message-ID: <20111215071621.GE24248@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1323906043-28408-2-git-send-email-michael.williamson@criticallink.com>
On Wed, Dec 14, 2011 at 06:40:43PM -0500, Michael Williamson wrote:
> +static int dsd1791_write(struct snd_soc_codec *codec, unsigned int reg,
> + unsigned int value)
> +{
> + struct dsd1791 *dsd1791 = snd_soc_codec_get_drvdata(codec);
> + u8 buffer[2];
> + int rc;
> +
> + buffer[0] = (reg & 0x7F);
> + buffer[1] = value & 0xFF;
> + rc = spi_write(dsd1791->spi, buffer, 2);
> + if (rc) {
> + dev_err(&dsd1791->spi->dev, "DSD1791 reg write error (%d)\n",
> + rc);
> + return -EIO;
> + }
> + return 0;
You shouldn't be open coding register I/O - this looks like a basic 8x8
register map so should work just fine with regmap (or the ASoC stuff but
new drivers should really use regmap).
> + case DSD1791_DAIFMT_I2S:
> + if (dsd1791->pcm_fmt == DSD1971_FORMAT_S16_LE)
> + fmt = DSD1791_FMT_16I2S;
> + else if (dsd1791->pcm_fmt == DSD1971_FORMAT_S24_LE)
> + fmt = DSD1791_FMT_24I2S;
> + else
> + return -EINVAL;
This should be a switch statement. You've got quite a few instances of
this pattern.
> + default:
> + dev_dbg(&dsd1791->spi->dev, "bad format\n");
codec->dev is easier.
> +static int dsd1791_set_sysclk(struct snd_soc_dai *codec_dai,
> + int clk_id, unsigned int freq, int dir)
> +{
> + struct snd_soc_codec *codec = codec_dai->codec;
> + struct dsd1791 *dsd1791 = snd_soc_codec_get_drvdata(codec);
> + dsd1791->mclk = freq;
> + return 0;
> +}
Implement this as a CODEC wide operation, it's simpler.
> +static const struct snd_kcontrol_new dsd1791_snd_controls[] = {
> +};
Remove empty variables and functions.
> + err = snd_soc_add_controls(codec, dsd1791_snd_controls,
> + ARRAY_SIZE(dsd1791_snd_controls));
If this were non-empty it should be registered via the CODEC structure.
> + dev_info(&spi->dev, "probing dsd1791 spi device\n");
This is just noise, remove it.
> + dsd1791 = kzalloc(sizeof *dsd1791, GFP_KERNEL);
> + if (!dsd1791)
> + return -ENOMEM;
devm_kzalloc().
> + } else
> + dev_info(&spi->dev, "SPI device initialized\n");
Again, too chatty.
> +static struct spi_driver dsd1791_spi = {
> + .driver = {
> + .name = "dsd1791-codec",
No -codec.
> +static int __init dsd1791_init(void)
> +{
> + spi_register_driver(&dsd1791_spi);
> +
> + return 0;
Return the error code from spi_register_driver().
next prev parent reply other threads:[~2011-12-15 7:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-14 23:40 [RFC PATCH 0/1] ASoC: dsd1791: Introduce driver for TI DSD1791 stereo codec Michael Williamson
2011-12-14 23:40 ` [RFC PATCH 1/1] " Michael Williamson
2011-12-15 6:58 ` Leon Romanovsky
2011-12-15 7:16 ` Mark Brown [this message]
2011-12-15 20:32 ` Michael Williamson
2011-12-16 12:53 ` Mark Brown
2011-12-15 8:57 ` Lars-Peter Clausen
2011-12-15 7:08 ` [RFC PATCH 0/1] " 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=20111215071621.GE24248@opensource.wolfsonmicro.com \
--to=broonie@opensource.wolfsonmicro.com \
--cc=alsa-devel@alsa-project.org \
--cc=lrg@ti.com \
--cc=michael.williamson@criticallink.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.