From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Frank Li <Frank.Li@nxp.com>
Cc: Haibo Chen <haibo.chen@nxp.com>,
Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
linux-iio@vger.kernel.org, imx@lists.linux.dev,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 1/2] iio: adc: vf610_adc: use devm_* and dev_err_probe() to simple code
Date: Thu, 7 Nov 2024 20:38:20 +0100 [thread overview]
Message-ID: <4bd12695-075d-474c-b720-d295cc6028ce@wanadoo.fr> (raw)
In-Reply-To: <20241107191842.3002319-1-Frank.Li@nxp.com>
Le 07/11/2024 à 20:18, Frank Li a écrit :
> Use devm_* and dev_err_probe() simplify probe function and remove
> vf610_adc_remove(). Change type of 'vref_uv' to int because
> regulator_get_voltage() return type is int.
>
> Reviewed-by: Haibo Chen <haibo.chen-3arQi8VN3Tc@public.gmane.org>
> Signed-off-by: Frank Li <Frank.Li-3arQi8VN3Tc@public.gmane.org>
> ---
> Change from v2 to v3
> - change vref_uv to int from u32 to fix below warning
> | Reported-by: kernel test robot <lkp-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202411070633.NIrO7Ert-lkp-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org/
> smatch warnings:
> drivers/iio/adc/vf610_adc.c:857 vf610_adc_probe() warn: unsigned 'info->vref_uv' is never less than zero.
>
> vim +857 drivers/iio/adc/vf610_adc.c
>
> Change from v1 to v2
> - add Haibo's review tag
> ---
> drivers/iio/adc/vf610_adc.c | 79 ++++++++++---------------------------
> 1 file changed, 20 insertions(+), 59 deletions(-)
>
> diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c
> index 4d83c12975c53..a6a0ada8a102f 100644
> --- a/drivers/iio/adc/vf610_adc.c
> +++ b/drivers/iio/adc/vf610_adc.c
> @@ -160,7 +160,7 @@ struct vf610_adc {
> /* lock to protect against multiple access to the device */
> struct mutex lock;
>
> - u32 vref_uv;
> + int vref_uv;
> u32 value;
> struct regulator *vref;
>
> @@ -823,10 +823,8 @@ static int vf610_adc_probe(struct platform_device *pdev)
> int ret;
>
> indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(struct vf610_adc));
> - if (!indio_dev) {
> - dev_err(&pdev->dev, "Failed allocating iio device\n");
> - return -ENOMEM;
> - }
> + if (!indio_dev)
> + return dev_err_probe(&pdev->dev, -ENOMEM, "Failed allocating iio device\n");
>
> info = iio_priv(indio_dev);
> info->dev = &pdev->dev;
> @@ -842,27 +840,22 @@ static int vf610_adc_probe(struct platform_device *pdev)
> ret = devm_request_irq(info->dev, irq,
> vf610_adc_isr, 0,
> dev_name(&pdev->dev), indio_dev);
> - if (ret < 0) {
> - dev_err(&pdev->dev, "failed requesting irq, irq = %d\n", irq);
> - return ret;
> - }
> + if (ret < 0)
> + dev_err_probe(&pdev->dev, ret, "failed requesting irq, irq = %d\n", irq);
missing return?
>
> - info->clk = devm_clk_get(&pdev->dev, "adc");
> - if (IS_ERR(info->clk)) {
> - dev_err(&pdev->dev, "failed getting clock, err = %ld\n",
> - PTR_ERR(info->clk));
> - return PTR_ERR(info->clk);
> - }
> + info->clk = devm_clk_get_enabled(&pdev->dev, "adc");
> + if (IS_ERR(info->clk))
> + return dev_err_probe(&pdev->dev, PTR_ERR(info->clk),
> + "failed getting clock, err = %ld\n",
> + PTR_ERR(info->clk));
No need to add an extra PTR_ERR(info->clk)
>
> info->vref = devm_regulator_get(&pdev->dev, "vref");
With the change to devm_regulator_get_enable_read_voltage(), is it still
needed?
CJ
> if (IS_ERR(info->vref))
> return PTR_ERR(info->vref);
>
> - ret = regulator_enable(info->vref);
> - if (ret)
> - return ret;
> -
> - info->vref_uv = regulator_get_voltage(info->vref);
> + info->vref_uv = devm_regulator_get_enable_read_voltage(&pdev->dev, "vref");
> + if (info->vref_uv < 0)
> + return info->vref_uv;
>
> device_property_read_u32_array(dev, "fsl,adck-max-frequency", info->max_adck_rate, 3);
>
...
next prev parent reply other threads:[~2024-11-07 19:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-07 19:18 [PATCH v3 1/2] iio: adc: vf610_adc: use devm_* and dev_err_probe() to simple code Frank Li
2024-11-07 19:18 ` [PATCH v3 2/2] iio: adc: vf610_adc: limit i.MX6SX's channel number to 4 Frank Li
2024-11-09 13:11 ` Jonathan Cameron
2024-11-07 19:38 ` Christophe JAILLET [this message]
2024-11-07 19:49 ` [PATCH v3 1/2] iio: adc: vf610_adc: use devm_* and dev_err_probe() to simple code Frank Li
2024-11-08 6:13 ` Christophe JAILLET
2024-11-08 19:12 ` Frank Li
2024-11-09 13:04 ` Jonathan Cameron
2024-11-09 13:07 ` 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=4bd12695-075d-474c-b720-d295cc6028ce@wanadoo.fr \
--to=christophe.jaillet@wanadoo.fr \
--cc=Frank.Li@nxp.com \
--cc=haibo.chen@nxp.com \
--cc=imx@lists.linux.dev \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@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