devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: AngeloGioacchino Del Regno  <angelogioacchino.delregno@collabora.com>
Cc: Shreeya Patel <shreeya.patel@collabora.com>,
	lars@metafoo.de, heiko@sntech.de, robh+dt@kernel.org,
	krzysztof.kozlowski+dt@linaro.org,
	sebastian.reichel@collabora.com, linux-iio@vger.kernel.org,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
	kernel@collabora.com, gustavo.padovan@collabora.com,
	serge.broslavsky@collabora.com
Subject: Re: [PATCH 5/7] iio: adc: rockchip_saradc: Use dev_err_probe
Date: Sat, 20 May 2023 16:49:35 +0100	[thread overview]
Message-ID: <20230520164935.70094206@jic23-huawei> (raw)
In-Reply-To: <d1955b9e-c719-9c7c-b1fd-f11fa97e44af@collabora.com>

On Wed, 17 May 2023 12:40:37 +0200
AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> wrote:

> Il 17/05/23 01:00, Shreeya Patel ha scritto:
> > Use dev_err_probe instead of dev_err in probe function,
> > which simplifies code a little bit and prints the error
> > code.
> > 
> > Signed-off-by: Shreeya Patel <shreeya.patel@collabora.com>
> > ---
> >   drivers/iio/adc/rockchip_saradc.c | 45 ++++++++++++++-----------------
> >   1 file changed, 20 insertions(+), 25 deletions(-)
> > 
> > diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c
> > index 5e1e8575bc76..a52021fd477d 100644
> > --- a/drivers/iio/adc/rockchip_saradc.c
> > +++ b/drivers/iio/adc/rockchip_saradc.c  
> 
> ..snip..
> 
> > @@ -494,23 +492,20 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
> >   	 * This may become user-configurable in the future.
> >   	 */
> >   	ret = clk_set_rate(info->clk, info->data->clk_rate);
> > -	if (ret < 0) {
> > -		dev_err(&pdev->dev, "failed to set adc clk rate, %d\n", ret);
> > -		return ret;
> > -	}
> > +	if (ret < 0)
> > +		return dev_err_probe(&pdev->dev, ret,
> > +				     "failed to set adc clk rate\n");
> >   
> >   	ret = regulator_enable(info->vref);
> > -	if (ret < 0) {
> > -		dev_err(&pdev->dev, "failed to enable vref regulator\n");
> > -		return ret;
> > -	}
> > +	if (ret < 0)
> > +		return dev_err_probe(&pdev->dev, ret,
> > +				     "failed to enable vref regulator\n");
> > +
> >   	ret = devm_add_action_or_reset(&pdev->dev,
> >   				       rockchip_saradc_regulator_disable, info);
> > -	if (ret) {
> > -		dev_err(&pdev->dev, "failed to register devm action, %d\n",
> > -			ret);
> > -		return ret;
> > -	}
> > +	if (ret)
> > +		return dev_err_probe(&pdev->dev, ret,
> > +				     "failed to register devm action\n");  
> 
> It's not your fault - and it's about a pre-existing issue, but there's that:
> you're returning an error if devm_add_action_or_reset() fails (which is highly
> unlikely), but you're leaving the regulator enabled!
Which regulator?  The _or_reset() part means that the callback is called if
the devm_add_action_or_reset is going to return an error.  So in the
path you talk about
rockchip_saradc_regulator_disable() is called and disables vref

> 
> As for how to proceed here, I would suggest to fix this issue in a separated
> commit (before the dev_err_probe() conversion); it'd look like...
> 
> 	if (ret) {
> 		regulator_disable(info->vref);
> 		dev_err( .... blurb );
> 		return ret;
> 	}
> 
> and after the conversion it'd look like...
> 
> 	if (ret) {
> 		regulator_disable(info->vref);
> 		return dev_err_probe( ... blurb );
> 	}
> 
> Cheers,
> Angelo
> 
> >   
> >   	ret = regulator_get_voltage(info->vref);
> >   	if (ret < 0)  
> 


  reply	other threads:[~2023-05-20 15:33 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-16 23:00 [PATCH 0/7] RK3588 ADC support Shreeya Patel
2023-05-16 23:00 ` [PATCH 1/7] iio: adc: rockchip_saradc: Add support for RK3588 Shreeya Patel
2023-05-17 10:32   ` AngeloGioacchino Del Regno
2023-05-20 15:57   ` Jonathan Cameron
2023-05-16 23:00 ` [PATCH 2/7] iio: adc: rockchip_saradc: Make use of devm_clk_get_enabled Shreeya Patel
2023-05-20 15:59   ` Jonathan Cameron
2023-05-16 23:00 ` [PATCH 3/7] iio: adc: rockchip_saradc: Use of_device_get_match_data Shreeya Patel
2023-05-17 10:34   ` AngeloGioacchino Del Regno
2023-05-16 23:00 ` [PATCH 4/7] iio: adc: rockchip_saradc: Match alignment with open parenthesis Shreeya Patel
2023-05-17 10:34   ` AngeloGioacchino Del Regno
2023-05-16 23:00 ` [PATCH 5/7] iio: adc: rockchip_saradc: Use dev_err_probe Shreeya Patel
2023-05-17 10:40   ` AngeloGioacchino Del Regno
2023-05-20 15:49     ` Jonathan Cameron [this message]
2023-05-16 23:00 ` [PATCH 6/7] arm64: dts: rockchip: Add DT node for ADC support in RK3588 Shreeya Patel
2023-05-17 10:41   ` AngeloGioacchino Del Regno
2023-05-16 23:00 ` [PATCH 7/7] dt-bindings: iio: adc: Add rockchip,rk3588-saradc string Shreeya Patel
2023-05-17  8:49   ` Krzysztof Kozlowski
2023-05-20 16:00 ` [PATCH 0/7] RK3588 ADC support 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=20230520164935.70094206@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gustavo.padovan@collabora.com \
    --cc=heiko@sntech.de \
    --cc=kernel@collabora.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lars@metafoo.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=robh+dt@kernel.org \
    --cc=sebastian.reichel@collabora.com \
    --cc=serge.broslavsky@collabora.com \
    --cc=shreeya.patel@collabora.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).