From: Jonathan Cameron <jic23@kernel.org>
To: Saalim Quadri <danascape@gmail.com>
Cc: lars@metafoo.de, Michael.Hennerich@analog.com,
gregkh@linuxfoundation.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev
Subject: Re: [PATCH] staging: iio: ad9832: Use devm_regulator_get_enable()
Date: Tue, 4 Mar 2025 14:35:11 +0000 [thread overview]
Message-ID: <20250304143511.1f5e8e70@jic23-huawei> (raw)
In-Reply-To: <20250303221427.30964-1-danascape@gmail.com>
On Tue, 4 Mar 2025 03:44:27 +0530
Saalim Quadri <danascape@gmail.com> wrote:
Hi Saalim,
Thanks for your patch - a few comments inline.
> Use devm_regulator_get_enable() to reduce boiler plate
> code.
Wrap patch descriptions to 75 chars.
>
> Signed-off-by: Saalim Quadri <danascape@gmail.com>
> ---
> drivers/staging/iio/frequency/ad9832.c | 37 +++-----------------------
> 1 file changed, 4 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/staging/iio/frequency/ad9832.c b/drivers/staging/iio/frequency/ad9832.c
> index 140ee4f9c137..a26d7caac131 100644
> --- a/drivers/staging/iio/frequency/ad9832.c
> +++ b/drivers/staging/iio/frequency/ad9832.c
> @@ -74,8 +74,6 @@
> /**
> * struct ad9832_state - driver instance specific data
> * @spi: spi_device
> - * @avdd: supply regulator for the analog section
> - * @dvdd: supply regulator for the digital section
> * @mclk: external master clock
> * @ctrl_fp: cached frequency/phase control word
> * @ctrl_ss: cached sync/selsrc control word
> @@ -94,8 +92,6 @@
>
> struct ad9832_state {
> struct spi_device *spi;
> - struct regulator *avdd;
> - struct regulator *dvdd;
> struct clk *mclk;
> unsigned short ctrl_fp;
> unsigned short ctrl_ss;
> @@ -297,11 +293,6 @@ static const struct iio_info ad9832_info = {
> .attrs = &ad9832_attribute_group,
> };
>
> -static void ad9832_reg_disable(void *reg)
> -{
> - regulator_disable(reg);
> -}
> -
> static int ad9832_probe(struct spi_device *spi)
> {
> struct ad9832_platform_data *pdata = dev_get_platdata(&spi->dev);
> @@ -320,33 +311,13 @@ static int ad9832_probe(struct spi_device *spi)
>
> st = iio_priv(indio_dev);
>
> - st->avdd = devm_regulator_get(&spi->dev, "avdd");
> - if (IS_ERR(st->avdd))
> - return PTR_ERR(st->avdd);
> -
> - ret = regulator_enable(st->avdd);
> - if (ret) {
> - dev_err(&spi->dev, "Failed to enable specified AVDD supply\n");
> - return ret;
> - }
> -
> - ret = devm_add_action_or_reset(&spi->dev, ad9832_reg_disable, st->avdd);
> + ret = devm_regulator_get_enable(&spi->dev, "avdd");
> if (ret)
> - return ret;
> -
> - st->dvdd = devm_regulator_get(&spi->dev, "dvdd");
> - if (IS_ERR(st->dvdd))
> - return PTR_ERR(st->dvdd);
> + return dev_err_probe(&spi->dev, ret, "failed to get AVDD voltage\n");
Please fix indentation. Should only be 1 tab more than if (ret)
>
> - ret = regulator_enable(st->dvdd);
> - if (ret) {
> - dev_err(&spi->dev, "Failed to enable specified DVDD supply\n");
> - return ret;
> - }
> -
> - ret = devm_add_action_or_reset(&spi->dev, ad9832_reg_disable, st->dvdd);
> + ret = devm_regulator_get_enable(&spi->dev, "dvdd");
> if (ret)
> - return ret;
> + return dev_err_probe(&spi->dev, ret, "Failed to enable specified DVDD supply\n");
As above.
>
> st->mclk = devm_clk_get_enabled(&spi->dev, "mclk");
> if (IS_ERR(st->mclk))
prev parent reply other threads:[~2025-03-04 14:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-03 22:14 [PATCH] staging: iio: ad9832: Use devm_regulator_get_enable() Saalim Quadri
2025-03-04 14:35 ` 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=20250304143511.1f5e8e70@jic23-huawei \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=danascape@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
/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