From: Alexandru Ardelean <ardeleanalex@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: linux-iio <linux-iio@vger.kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
alexandru.tachici@analog.com,
Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: Re: [PATCH 3/3] iio: adc: ad7124: Use devm_ managed calls for all of probe() + drop remove()
Date: Sun, 9 May 2021 10:30:05 +0300 [thread overview]
Message-ID: <CA+U=DsrC74AjA6VeJAA+C2=LWZ6FttLSKLt5mOJGMouTb45NrA@mail.gmail.com> (raw)
In-Reply-To: <20210508182319.488551-4-jic23@kernel.org>
On Sat, May 8, 2021 at 9:24 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> As not many steps were not already devm_ managed, use
> devm_add_action_or_reset() to handle the rest.
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Cc: Alexandru Ardelean <ardeleanalex@gmail.com>
double Cc: tag here
One minor thought about maybe removing the log spam.
Other than that:
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
> ---
> drivers/iio/adc/ad7124.c | 53 ++++++++++++++++++----------------------
> 1 file changed, 24 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c
> index 9c2401c5848e..deb166d2b645 100644
> --- a/drivers/iio/adc/ad7124.c
> +++ b/drivers/iio/adc/ad7124.c
> @@ -719,6 +719,16 @@ static void ad7124_reg_disable(void *r)
> regulator_disable(r);
> }
>
> +static void ad7124_clk_disable(void *c)
> +{
> + clk_disable_unprepare(c);
> +}
> +
> +static void ad7124_buffer_cleanup(void *idev)
> +{
> + ad_sd_cleanup_buffer_and_trigger(idev);
We never seem to have done a devm_ version for ad_sd_setup_buffer_and_trigger().
> +}
> +
> static int ad7124_probe(struct spi_device *spi)
> {
> const struct ad7124_chip_info *info;
> @@ -740,8 +750,6 @@ static int ad7124_probe(struct spi_device *spi)
>
> ad_sd_init(&st->sd, indio_dev, spi, &ad7124_sigma_delta_info);
>
> - spi_set_drvdata(spi, indio_dev);
> -
> indio_dev->name = st->chip_info->name;
> indio_dev->modes = INDIO_DIRECT_MODE;
> indio_dev->info = &ad7124_info;
> @@ -779,48 +787,36 @@ static int ad7124_probe(struct spi_device *spi)
> if (ret < 0)
> return ret;
>
> + ret = devm_add_action_or_reset(&spi->dev, ad7124_clk_disable, st->mclk);
> + if (ret)
> + return ret;
> +
> ret = ad7124_soft_reset(st);
> if (ret < 0)
> - goto error_clk_disable_unprepare;
> + return ret;
>
> ret = ad7124_check_chip_id(st);
> if (ret)
> - goto error_clk_disable_unprepare;
> + return ret;
>
> ret = ad7124_setup(st);
> if (ret < 0)
> - goto error_clk_disable_unprepare;
> + return ret;
>
> ret = ad_sd_setup_buffer_and_trigger(indio_dev);
> if (ret < 0)
> - goto error_clk_disable_unprepare;
> -
> - ret = iio_device_register(indio_dev);
> - if (ret < 0) {
> - dev_err(&spi->dev, "Failed to register iio device\n");
> - goto error_remove_trigger;
> - }
> + return ret;
>
> - return 0;
> + ret = devm_add_action_or_reset(&spi->dev, ad7124_buffer_cleanup, indio_dev);
> + if (ret)
> + return ret;
>
> -error_remove_trigger:
> - ad_sd_cleanup_buffer_and_trigger(indio_dev);
> -error_clk_disable_unprepare:
> - clk_disable_unprepare(st->mclk);
> + ret = devm_iio_device_register(&spi->dev, indio_dev);
> + if (ret)
> + dev_err(&spi->dev, "Failed to register iio device\n");
I guess Andy may come along and suggest that we remove this log spam
and just do a direct return.
Which would sound like a reasonable idea.
>
> return ret;
> -}
>
> -static int ad7124_remove(struct spi_device *spi)
> -{
> - struct iio_dev *indio_dev = spi_get_drvdata(spi);
> - struct ad7124_state *st = iio_priv(indio_dev);
> -
> - iio_device_unregister(indio_dev);
> - ad_sd_cleanup_buffer_and_trigger(indio_dev);
> - clk_disable_unprepare(st->mclk);
> -
> - return 0;
> }
>
> static const struct of_device_id ad7124_of_match[] = {
> @@ -838,7 +834,6 @@ static struct spi_driver ad71124_driver = {
> .of_match_table = ad7124_of_match,
> },
> .probe = ad7124_probe,
> - .remove = ad7124_remove,
> };
> module_spi_driver(ad71124_driver);
>
> --
> 2.31.1
>
next prev parent reply other threads:[~2021-05-09 7:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-08 18:23 [PATCH 0/3] iio: adc: ad7124: Fixes and devm_ for all of probe Jonathan Cameron
2021-05-08 18:23 ` [PATCH 1/3] iio: adc: ad7124: Fix missbalanced regulator enable / disable on error Jonathan Cameron
2021-05-09 7:20 ` Alexandru Ardelean
2021-05-08 18:23 ` [PATCH 2/3] iio: adc: ad7124: Fix potential overflow due to non sequential channel numbers Jonathan Cameron
2021-05-09 7:22 ` Alexandru Ardelean
2021-05-08 18:23 ` [PATCH 3/3] iio: adc: ad7124: Use devm_ managed calls for all of probe() + drop remove() Jonathan Cameron
2021-05-09 7:30 ` Alexandru Ardelean [this message]
2021-05-09 7:31 ` [PATCH 0/3] iio: adc: ad7124: Fixes and devm_ for all of probe Alexandru Ardelean
2021-05-09 9:35 ` 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='CA+U=DsrC74AjA6VeJAA+C2=LWZ6FttLSKLt5mOJGMouTb45NrA@mail.gmail.com' \
--to=ardeleanalex@gmail.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=alexandru.tachici@analog.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;
as well as URLs for NNTP newsgroup(s).