lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 20 Jan 2016 05:58:26 +0100
From:	Michael Trimarchi <michael@...rulasolutions.com>
To:	Johan Hovold <johan@...nel.org>
Cc:	Jacob Siverskog <jacob@...nage.engineering>,
	Liam Girdwood <lgirdwood@...il.com>,
	Mark Brown <broonie@...nel.org>,
	Jaroslav Kysela <perex@...ex.cz>,
	Takashi Iwai <tiwai@...e.com>,
	"alsa-devel@...a-project.org" <alsa-devel@...a-project.org>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 2/3] ASoC: pcm179x: Add I2C interface driver

Hi

On Tue, Jan 19, 2016 at 2:51 PM, Johan Hovold <johan@...nel.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@...nage.engineering> wrote:
>> > The PCM179x family supports both SPI and I2C. This patch adds support
>> > for the I2C interface.
>> >
>> > Reviewed-by: Johan Hovold <johan@...nel.org>
>> > Signed-off-by: Jacob Siverskog <jacob@...nage.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               |

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ