linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Alexandru Ardelean <aardelean@deviqon.com>
Cc: linux-iio <linux-iio@vger.kernel.org>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: Re: [PATCH 7/8] iio: adc: ti-adc108s102: Use devm managed functions for all of probe()
Date: Sat, 22 May 2021 19:29:21 +0100	[thread overview]
Message-ID: <20210522192921.10361b8b@jic23-huawei> (raw)
In-Reply-To: <CAASAkoZxvz05Q3ep4uQH=Zh7xehZPPSRmC=y+xP18MAdsymjSw@mail.gmail.com>

On Mon, 17 May 2021 10:37:31 +0300
Alexandru Ardelean <aardelean@deviqon.com> wrote:

> On Mon, 17 May 2021 at 10:31, Alexandru Ardelean <aardelean@deviqon.com> wrote:
> >
> > On Sun, 16 May 2021 at 20:26, Jonathan Cameron <jic23@kernel.org> wrote:  
> > >
> > > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > >
> > > Simplifies error handling and lets us drop remove() entirely.
> > >  
> >  
> 
> // Removed Bogdan's email; it's not working;
> Apologies to return on this.
> This note can be disregarded, but this patch could do a direct return
> for devm_iio_device_register().
> It doesn't make much sense to print a failure there as that can be
> also viewed via some broader kernel logging.
> But it's also fine to leave it.

Whilst I agree in the sense I would never have put it there in the first place
myself, I wanted this series to be one with no visible changes so
I'd rather leave it in place.

Thanks,

Jonathan
> 
> > Reviewed-by: Alexandru Ardelean <aardelean@deviqon.com>
> >
> >  
> > > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > > Cc: Bogdan Pricop <bogdan.pricop@emutex.com>
> > > ---
> > >  drivers/iio/adc/ti-adc108s102.c | 45 +++++++++++----------------------
> > >  1 file changed, 15 insertions(+), 30 deletions(-)
> > >
> > > diff --git a/drivers/iio/adc/ti-adc108s102.c b/drivers/iio/adc/ti-adc108s102.c
> > > index 183b2245e89b..db902aef2abe 100644
> > > --- a/drivers/iio/adc/ti-adc108s102.c
> > > +++ b/drivers/iio/adc/ti-adc108s102.c
> > > @@ -215,6 +215,11 @@ static const struct iio_info adc108s102_info = {
> > >         .update_scan_mode       = &adc108s102_update_scan_mode,
> > >  };
> > >
> > > +static void adc108s102_reg_disable(void *reg)
> > > +{
> > > +       regulator_disable(reg);
> > > +}
> > > +
> > >  static int adc108s102_probe(struct spi_device *spi)
> > >  {
> > >         struct adc108s102_state *st;
> > > @@ -239,6 +244,10 @@ static int adc108s102_probe(struct spi_device *spi)
> > >                         dev_err(&spi->dev, "Cannot enable vref regulator\n");
> > >                         return ret;
> > >                 }
> > > +               ret = devm_add_action_or_reset(&spi->dev, adc108s102_reg_disable,
> > > +                                              st->reg);
> > > +               if (ret)
> > > +                       return ret;
> > >
> > >                 ret = regulator_get_voltage(st->reg);
> > >                 if (ret < 0) {
> > > @@ -249,7 +258,6 @@ static int adc108s102_probe(struct spi_device *spi)
> > >                 st->va_millivolt = ret / 1000;
> > >         }
> > >
> > > -       spi_set_drvdata(spi, indio_dev);
> > >         st->spi = spi;
> > >
> > >         indio_dev->name = spi->modalias;
> > > @@ -266,40 +274,18 @@ static int adc108s102_probe(struct spi_device *spi)
> > >         spi_message_init_with_transfers(&st->scan_single_msg,
> > >                                         &st->scan_single_xfer, 1);
> > >
> > > -       ret = iio_triggered_buffer_setup(indio_dev, NULL,
> > > -                                        &adc108s102_trigger_handler, NULL);
> > > +       ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, NULL,
> > > +                                             &adc108s102_trigger_handler,
> > > +                                             NULL);
> > >         if (ret)
> > > -               goto error_disable_reg;
> > > +               return ret;
> > >
> > > -       ret = iio_device_register(indio_dev);
> > > -       if (ret) {
> > > +       ret = devm_iio_device_register(&spi->dev, indio_dev);
> > > +       if (ret)
> > >                 dev_err(&spi->dev, "Failed to register IIO device\n");
> > > -               goto error_cleanup_triggered_buffer;
> > > -       }
> > > -       return 0;
> > > -
> > > -error_cleanup_triggered_buffer:
> > > -       iio_triggered_buffer_cleanup(indio_dev);
> > > -
> > > -error_disable_reg:
> > > -       regulator_disable(st->reg);
> > > -
> > >         return ret;
> > >  }
> > >
> > > -static int adc108s102_remove(struct spi_device *spi)
> > > -{
> > > -       struct iio_dev *indio_dev = spi_get_drvdata(spi);
> > > -       struct adc108s102_state *st = iio_priv(indio_dev);
> > > -
> > > -       iio_device_unregister(indio_dev);
> > > -       iio_triggered_buffer_cleanup(indio_dev);
> > > -
> > > -       regulator_disable(st->reg);
> > > -
> > > -       return 0;
> > > -}
> > > -
> > >  static const struct of_device_id adc108s102_of_match[] = {
> > >         { .compatible = "ti,adc108s102" },
> > >         { }
> > > @@ -327,7 +313,6 @@ static struct spi_driver adc108s102_driver = {
> > >                 .acpi_match_table = ACPI_PTR(adc108s102_acpi_ids),
> > >         },
> > >         .probe          = adc108s102_probe,
> > > -       .remove         = adc108s102_remove,
> > >         .id_table       = adc108s102_id,
> > >  };
> > >  module_spi_driver(adc108s102_driver);
> > > --
> > > 2.31.1
> > >  


  reply	other threads:[~2021-05-22 18:28 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-16 17:25 [PATCH 0/8] iio: adc: Maxim and TI ADC driver cleanups Jonathan Cameron
2021-05-16 17:25 ` [PATCH 1/8] iio: adc: max11100: Use get_unaligned_be16() rather than opencoding Jonathan Cameron
2021-05-17  6:59   ` Alexandru Ardelean
2021-05-16 17:25 ` [PATCH 2/8] iio: adc: max11100: Use devm_ functions for rest of probe() Jonathan Cameron
2021-05-17  7:08   ` Alexandru Ardelean
2021-05-17  7:22     ` Alexandru Ardelean
2021-05-16 17:25 ` [PATCH 3/8] iio: adc: max1118: Use devm_ managed functions for all of probe Jonathan Cameron
2021-05-17  7:18   ` Alexandru Ardelean
2021-05-16 17:25 ` [PATCH 4/8] iio: adc: max1118: Avoid jumping back and forth between spi and iio structures Jonathan Cameron
2021-05-17  7:24   ` Alexandru Ardelean
2021-05-16 17:25 ` [PATCH 5/8] iio: adc: ti-adc081c: Use devm managed functions for all of probe() Jonathan Cameron
2021-05-17  7:26   ` Alexandru Ardelean
2021-05-16 17:25 ` [PATCH 6/8] iio: adc: ti-adc0832: " Jonathan Cameron
2021-05-17  7:28   ` Alexandru Ardelean
2021-05-16 17:25 ` [PATCH 7/8] iio: adc: ti-adc108s102: " Jonathan Cameron
2021-05-17  7:31   ` Alexandru Ardelean
2021-05-17  7:37     ` Alexandru Ardelean
2021-05-22 18:29       ` Jonathan Cameron [this message]
2021-05-16 17:25 ` [PATCH 8/8] iio: adc: ti-adc161s626: Use devm managed functions for all of probe Jonathan Cameron
2021-05-16 20:04   ` Matt Ranostay
2021-05-17  7:35   ` Alexandru Ardelean
2021-05-22 18:31 ` [PATCH 0/8] iio: adc: Maxim and TI ADC driver cleanups 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=20210522192921.10361b8b@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=aardelean@deviqon.com \
    --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;
as well as URLs for NNTP newsgroup(s).