linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Chuhong Yuan <hslester96@gmail.com>
Cc: Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org
Subject: Re: [PATCH] iio: adc: max1027: Use device-managed APIs
Date: Sun, 11 Aug 2019 11:15:37 +0100	[thread overview]
Message-ID: <20190811111537.1356663f@archlinux> (raw)
In-Reply-To: <20190808142646.29567-1-hslester96@gmail.com>


+CC linux-iio

On Thu,  8 Aug 2019 22:26:46 +0800
Chuhong Yuan <hslester96@gmail.com> wrote:

> Use device-managed APIs to simplify the code.
> 
> Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
Also one minor comment inline.  I would have picked this up and
made that change but given it didn't go to the linux-iio, please
do a v2 scrapping the debug print and hence remove.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/max1027.c | 30 +++++++-----------------------
>  1 file changed, 7 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c
> index da84adfdb819..f1b90c544b82 100644
> --- a/drivers/iio/adc/max1027.c
> +++ b/drivers/iio/adc/max1027.c
> @@ -427,8 +427,9 @@ static int max1027_probe(struct spi_device *spi)
>  		return -ENOMEM;
>  	}
>  
> -	ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time,
> -					 &max1027_trigger_handler, NULL);
> +	ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev,
> +					&iio_pollfunc_store_time,
> +					&max1027_trigger_handler, NULL);
>  	if (ret < 0) {
>  		dev_err(&indio_dev->dev, "Failed to setup buffer\n");
>  		return ret;
> @@ -439,7 +440,7 @@ static int max1027_probe(struct spi_device *spi)
>  	if (st->trig == NULL) {
>  		ret = -ENOMEM;
>  		dev_err(&indio_dev->dev, "Failed to allocate iio trigger\n");
> -		goto fail_trigger_alloc;
> +		return ret;
>  	}
>  
>  	st->trig->ops = &max1027_trigger_ops;
> @@ -454,7 +455,7 @@ static int max1027_probe(struct spi_device *spi)
>  					spi->dev.driver->name, st->trig);
>  	if (ret < 0) {
>  		dev_err(&indio_dev->dev, "Failed to allocate IRQ.\n");
> -		goto fail_dev_register;
> +		return ret;
>  	}
>  
>  	/* Disable averaging */
> @@ -462,33 +463,16 @@ static int max1027_probe(struct spi_device *spi)
>  	ret = spi_write(st->spi, &st->reg, 1);
>  	if (ret < 0) {
>  		dev_err(&indio_dev->dev, "Failed to configure averaging register\n");
> -		goto fail_dev_register;
> -	}
> -
> -	ret = iio_device_register(indio_dev);
> -	if (ret < 0) {
> -		dev_err(&indio_dev->dev, "Failed to register iio device\n");
> -		goto fail_dev_register;
> +		return ret;
>  	}
>  
> -	return 0;
> -
> -fail_dev_register:
> -fail_trigger_alloc:
> -	iio_triggered_buffer_cleanup(indio_dev);
> -
> -	return ret;
> +	return devm_iio_device_register(&spi->dev, indio_dev);
>  }
>  
>  static int max1027_remove(struct spi_device *spi)
>  {
> -	struct iio_dev *indio_dev = spi_get_drvdata(spi);
> -
>  	pr_debug("%s: remove(spi = 0x%p)\n", __func__, spi);

That's not a message we need to keep.  Hence can get rid of remove entirely.

>  
> -	iio_device_unregister(indio_dev);
> -	iio_triggered_buffer_cleanup(indio_dev);
> -
>  	return 0;
>  }
>  


           reply	other threads:[~2019-08-11 10:15 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <20190808142646.29567-1-hslester96@gmail.com>]

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=20190811111537.1356663f@archlinux \
    --to=jic23@kernel.org \
    --cc=hslester96@gmail.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /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).