From: Jonathan Cameron <jic23@kernel.org>
To: Chuhong Yuan <hslester96@gmail.com>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
Matt Ranostay <matt.ranostay@konsulko.com>
Subject: Re: [PATCH] iio: maxim_thermocouple: Use device-managed APIs
Date: Sat, 27 Jul 2019 14:51:26 +0100 [thread overview]
Message-ID: <20190727145126.07ea374d@archlinux> (raw)
In-Reply-To: <20190726104950.19171-1-hslester96@gmail.com>
On Fri, 26 Jul 2019 18:49:50 +0800
Chuhong Yuan <hslester96@gmail.com> wrote:
> Use device-managed APIs to simplify the code.
> The remove functions are redundant now and can
> be deleted.
>
> Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
+CC Matt as I think this is one of his.
I modified slightly and applied to the togreg branch of iio.git.
See inline for the change.
Thanks,
Jonathan
> ---
> drivers/iio/temperature/maxim_thermocouple.c | 23 ++++----------------
> 1 file changed, 4 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/iio/temperature/maxim_thermocouple.c b/drivers/iio/temperature/maxim_thermocouple.c
> index c613a64c017f..314b6e11e386 100644
> --- a/drivers/iio/temperature/maxim_thermocouple.c
> +++ b/drivers/iio/temperature/maxim_thermocouple.c
> @@ -230,29 +230,15 @@ static int maxim_thermocouple_probe(struct spi_device *spi)
> data->spi = spi;
> data->chip = chip;
>
> - ret = iio_triggered_buffer_setup(indio_dev, NULL,
> + ret = devm_iio_triggered_buffer_setup(&spi->dev,
> + indio_dev, NULL,
> maxim_thermocouple_trigger_handler, NULL);
> if (ret)
> return ret;
>
> - ret = iio_device_register(indio_dev);
> + ret = devm_iio_device_register(&spi->dev, indio_dev);
> if (ret)
> - goto error_unreg_buffer;
> -
> - return 0;
> -
> -error_unreg_buffer:
> - iio_triggered_buffer_cleanup(indio_dev);
> -
> - return ret;
> -}
> -
> -static int maxim_thermocouple_remove(struct spi_device *spi)
> -{
> - struct iio_dev *indio_dev = spi_get_drvdata(spi);
> -
> - iio_device_unregister(indio_dev);
> - iio_triggered_buffer_cleanup(indio_dev);
> + return ret;
Slight tweak. I'll do it whilst applying.
can just
return devm_iio_device_register(...) as same effect.
>
> return 0;
> }
> @@ -277,7 +263,6 @@ static struct spi_driver maxim_thermocouple_driver = {
> .of_match_table = maxim_thermocouple_of_match,
> },
> .probe = maxim_thermocouple_probe,
> - .remove = maxim_thermocouple_remove,
> .id_table = maxim_thermocouple_id,
> };
> module_spi_driver(maxim_thermocouple_driver);
prev parent reply other threads:[~2019-07-27 13:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-26 10:49 [PATCH] iio: maxim_thermocouple: Use device-managed APIs Chuhong Yuan
2019-07-27 13:51 ` Jonathan Cameron [this message]
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=20190727145126.07ea374d@archlinux \
--to=jic23@kernel.org \
--cc=hslester96@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matt.ranostay@konsulko.com \
/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).