Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1312266

Re: [PATCH v2 2/3] ASoC: pcm179x: Add I2C interface driver

From Johan Hovold <johan@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH v2 2/3] ASoC: pcm179x: Add I2C interface driver
Date 2016-01-19 15:00 +0100
Message-ID <qSEZc-bz-17@gated-at.bofh.it> (permalink)
References <qSBRE-6uw-5@gated-at.bofh.it> <qSBRE-6uw-11@gated-at.bofh.it> <qSCb1-6Bn-37@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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).

> > +       return pcm179x_common_init(pcm179x);
> > +}
> > +
> > +static int pcm179x_i2c_remove(struct i2c_client *client)
> > +{
> > +       return pcm179x_common_exit(i2c_get_clientdata(client));
> > +}

Thanks,
Johan

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 0/3] ASoC: pcm179x: Add I2C support, declare support for continuous rates Jacob Siverskog <jacob@teenage.engineering> - 2016-01-19 11:40 +0100
  [PATCH v2 2/3] ASoC: pcm179x: Add I2C interface driver Jacob Siverskog <jacob@teenage.engineering> - 2016-01-19 11:40 +0100
    Re: [PATCH v2 2/3] ASoC: pcm179x: Add I2C interface driver Michael Trimarchi <michael@amarulasolutions.com> - 2016-01-19 12:00 +0100
      Re: [PATCH v2 2/3] ASoC: pcm179x: Add I2C interface driver Johan Hovold <johan@kernel.org> - 2016-01-19 15:00 +0100
        Re: [PATCH v2 2/3] ASoC: pcm179x: Add I2C interface driver Michael Trimarchi <michael@amarulasolutions.com> - 2016-01-20 06:00 +0100
          Re: [PATCH v2 2/3] ASoC: pcm179x: Add I2C interface driver Johan Hovold <johan@kernel.org> - 2016-01-20 18:30 +0100
  [PATCH v2 1/3] ASoC: pcm179x: Split into core and SPI parts Jacob Siverskog <jacob@teenage.engineering> - 2016-01-19 11:40 +0100
  [PATCH v2 3/3] ASoC: pcm179x: Support continuous rates Jacob Siverskog <jacob@teenage.engineering> - 2016-01-19 11:40 +0100

csiph-web