From: Michael Trimarchi <michael@amarulasolutions.com>
To: Johan Hovold <johan@kernel.org>
Cc: "alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
LKML <linux-kernel@vger.kernel.org>,
Takashi Iwai <tiwai@suse.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Jacob Siverskog <jacob@teenage.engineering>,
Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH v2 2/3] ASoC: pcm179x: Add I2C interface driver
Date: Wed, 20 Jan 2016 05:58:26 +0100 [thread overview]
Message-ID: <CAOf5uwkSL91v4Trdp-QgarngHehY=Mj3Ur+Z21V7FEJ-mmqb1g@mail.gmail.com> (raw)
In-Reply-To: <20160119135103.GA12069@localhost>
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
Michael
>> > + return pcm179x_common_init(pcm179x);
>> > +}
>> > +
>> > +static int pcm179x_i2c_remove(struct i2c_client *client)
>> > +{
>> > + return pcm179x_common_exit(i2c_get_clientdata(client));
>> > +}
>
> Thanks,
> Johan
--
| Michael Nazzareno Trimarchi Amarula Solutions BV |
| COO - Founder Cruquiuskade 47 |
| +31(0)851119172 Amsterdam 1018 AM NL |
| [`as] http://www.amarulasolutions.com |
next prev parent reply other threads:[~2016-01-20 4:58 UTC|newest]
Thread overview: 8+ 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 ` [PATCH v2 2/3] ASoC: pcm179x: Add I2C interface driver Jacob Siverskog
2016-01-19 10:50 ` Michael Trimarchi
2016-01-19 13:51 ` Johan Hovold
2016-01-20 4:58 ` Michael Trimarchi [this message]
2016-01-20 17:26 ` Johan Hovold
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='CAOf5uwkSL91v4Trdp-QgarngHehY=Mj3Ur+Z21V7FEJ-mmqb1g@mail.gmail.com' \
--to=michael@amarulasolutions.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=jacob@teenage.engineering \
--cc=johan@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--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 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).