From: Johan Hovold <johan@kernel.org>
To: Michael Trimarchi <michael@amarulasolutions.com>
Cc: Johan Hovold <johan@kernel.org>,
Jacob Siverskog <jacob@teenage.engineering>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>,
"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/3] ASoC: pcm179x: Add I2C interface driver
Date: Wed, 20 Jan 2016 18:26:37 +0100 [thread overview]
Message-ID: <20160120172637.GF18739@localhost> (raw)
In-Reply-To: <CAOf5uwkSL91v4Trdp-QgarngHehY=Mj3Ur+Z21V7FEJ-mmqb1g@mail.gmail.com>
On Wed, Jan 20, 2016 at 05:58:26AM +0100, Michael Trimarchi wrote:
> Hi
>
> On Tue, Jan 19, 2016 at 2:51 PM, Johan Hovold <johan@kernel.org> wrote:
> > On Tue, Jan 19, 2016 at 11:50:35AM +0100, Michael Trimarchi wrote:
> >> Hi Jacob
> >>
> >> On Tue, Jan 19, 2016 at 11:29 AM, Jacob Siverskog
> >> <jacob@teenage.engineering> wrote:
> >> > The PCM179x family supports both SPI and I2C. This patch adds support
> >> > for the I2C interface.
> >> >
> >> > Reviewed-by: Johan Hovold <johan@kernel.org>
> >> > Signed-off-by: Jacob Siverskog <jacob@teenage.engineering>
> >> > ---
> >
> >> > +static int pcm179x_i2c_probe(struct i2c_client *client,
> >> > + const struct i2c_device_id *id)
> >> > +{
> >> > + struct pcm179x_private *pcm179x;
> >> > + int ret;
> >> > +
> >> > + pcm179x = devm_kzalloc(&client->dev, sizeof(struct pcm179x_private),
> >> > + GFP_KERNEL);
> >> > + if (!pcm179x)
> >> > + return -ENOMEM;
> >> > +
> >> > + i2c_set_clientdata(client, pcm179x);
> >> > +
> >> > + pcm179x->dev = &client->dev;
> >> > +
> >> > + pcm179x->regmap = devm_regmap_init_i2c(client, &pcm179x_regmap_config);
> >> > + if (IS_ERR(pcm179x->regmap)) {
> >> > + ret = PTR_ERR(pcm179x->regmap);
> >> > + dev_err(&client->dev, "Failed to register regmap: %d\n", ret);
> >> > + return ret;
> >> > + }
> >> > +
> >>
> >> sound/soc/codecs/adau1781-spi.c
> >>
> >> I like more how was done here for private data and codec data. What do
> >> you think?
> >
> > Why do you prefer that?
> >
> > Having a common_exit() to clean up whatever was done in common_init()
> > seems like a better design than open-coding this in both of the i2c and
> > spi drivers (if that's what you were referring to).
> >
>
> private data can be allocated in common code and you can pass the
> regmap in the common init.
> As I can understand in that way more common code is shared between i2c
> and spi and make much
> more clean and easy. I had a look very quick but I think that this was
> the key point of that example
You're right, and this seems to be how the other codec drivers do this
(unlike mfd for example). Some have a shared remove function, while most
call snd_soc_unregister_codec from the driver's remove callback, which
was what I found a bit odd as registration was done by the common init
code.
Thanks,
Johan
next prev parent reply other threads:[~2016-01-20 17:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-19 10:29 [PATCH v2 0/3] ASoC: pcm179x: Add I2C support, declare support for continuous rates Jacob Siverskog
2016-01-19 10:29 ` [PATCH v2 1/3] ASoC: pcm179x: Split into core and SPI parts Jacob Siverskog
2016-01-19 10:29 ` Jacob Siverskog
2016-01-19 10:29 ` [PATCH v2 2/3] ASoC: pcm179x: Add I2C interface driver Jacob Siverskog
2016-01-19 10:29 ` Jacob Siverskog
2016-01-19 10:50 ` Michael Trimarchi
2016-01-19 13:51 ` Johan Hovold
2016-01-20 4:58 ` Michael Trimarchi
2016-01-20 4:58 ` Michael Trimarchi
2016-01-20 17:26 ` Johan Hovold [this message]
2016-01-19 10:29 ` [PATCH v2 3/3] ASoC: pcm179x: Support continuous rates Jacob Siverskog
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=20160120172637.GF18739@localhost \
--to=johan@kernel.org \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=jacob@teenage.engineering \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=michael@amarulasolutions.com \
--cc=perex@perex.cz \
--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 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.