Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Alexandru Ardelean <ardeleanalex@gmail.com>
Cc: Rodolfo Giometti <giometti@enneenne.com>,
	Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	linux-iio <linux-iio@vger.kernel.org>
Subject: Re: [PATCH 1/1] iio adc: add driver for Texas Instruments TLA2528 adc
Date: Mon, 2 Aug 2021 17:08:58 +0100	[thread overview]
Message-ID: <20210802170858.0000531e@Huawei.com> (raw)
In-Reply-To: <CA+U=DsqHcrXWi5TF=6gsuU8f3muMThJG1BTNQXov1KWbsdGkFw@mail.gmail.com>


...

> > +
> > +static int tla2528_probe(struct i2c_client *client,
> > +                        const struct i2c_device_id *id)
> > +{
> > +       struct iio_dev *indio_dev;
> > +       struct tla2528_st *st;
> > +       int ret;
> > +
> > +       if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C |
> > +                                    I2C_FUNC_SMBUS_WRITE_BYTE))
> > +               return -EOPNOTSUPP;
> > +
> > +       indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st));
> > +       if (!indio_dev)
> > +               return -ENOMEM;
> > +
> > +       st = iio_priv(indio_dev);
> > +       i2c_set_clientdata(client, indio_dev);
> > +       st->client = client;
> > +
> > +       indio_dev->name = id->name;
> > +       indio_dev->info = &tla2528_info;
> > +       indio_dev->modes = INDIO_DIRECT_MODE;
> > +       indio_dev->channels = tla2528_channel;
> > +       indio_dev->num_channels = ARRAY_SIZE(tla2528_channel);
> > +
> > +       st->ref = devm_regulator_get(&client->dev, "vref");
> > +       if (IS_ERR(st->ref))
> > +               return PTR_ERR(st->ref);
> > +
> > +       ret = regulator_enable(st->ref);
> > +       if (ret < 0)
> > +               return ret;
> > +  
> 
> I was thinking about whether to mention this earlier.
> But, an idea, is to do:
> 
>         ret = devm_add_action_or_reset(&spi->dev, tla2528_reg_disable,
> st->vref);
>         if (ret)
>                 return ret;
> 
> Then the i2c_set_clientdata() call can be removed, and the
> tla2528_remove() hook as well.
> A simple example can be seen in drivers/iio/adc/ti-ads8344.c
> 
> I'm not insisting on it. Since the driver is simple enough.

I'd prefer this, because otherwise someone will come along and change
it later creating more patches for me to review :)

Jonathan


  parent reply	other threads:[~2021-08-02 16:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-02 13:04 [PATCH 0/1] V2 driver for Texas Instruments TLA2528 Rodolfo Giometti
2021-08-02 13:04 ` [PATCH 1/1] iio adc: add driver for Texas Instruments TLA2528 adc Rodolfo Giometti
2021-08-02 13:37   ` Alexandru Ardelean
2021-08-02 13:49     ` Alexandru Ardelean
2021-08-02 16:08     ` Jonathan Cameron [this message]
2021-08-02 16:29   ` Jonathan Cameron

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=20210802170858.0000531e@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=ardeleanalex@gmail.com \
    --cc=giometti@enneenne.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    /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