Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Nikhil Gautam <nikhilgtr@gmail.com>
Cc: "Linus Walleij" <linus.walleij@linaro.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/3] iio: light: gp2ap002: Fix regulator leaks in runtime resume error path
Date: Mon, 3 Aug 2026 01:27:38 +0100	[thread overview]
Message-ID: <20260803012738.2abf14db@jic23-huawei> (raw)
In-Reply-To: <20260722162247.8229-4-nikhilgtr@gmail.com>

On Wed, 22 Jul 2026 21:52:47 +0530
Nikhil Gautam <nikhilgtr@gmail.com> wrote:

> If enabling vio fails, vdd is left enabled; if re-initializing the
> sensor fails, both regulators are left enabled.
> 
> unwind previously enabled regulators on failure, mirroring the error
> handling already used in probe.
> 
> Fixes: 97d642e23037c ("iio: light: Add a driver for Sharp GP2AP002x00F")
> Signed-off-by: Nikhil Gautam <nikhilgtr@gmail.com>
I'm already carrying this fix via a patch from Laxman,
so dropping this one.


Applied 1 and 2 but there was some noise due to other changes near this
code so please take a look.

Applied to the fixes-togreg branch of iio.git

Thanks

Jonathan

> ---
>  drivers/iio/light/gp2ap002.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/light/gp2ap002.c b/drivers/iio/light/gp2ap002.c
> index e8ba9c00dabb..430336b51f83 100644
> --- a/drivers/iio/light/gp2ap002.c
> +++ b/drivers/iio/light/gp2ap002.c
> @@ -677,7 +677,7 @@ static int gp2ap002_runtime_resume(struct device *dev)
>  	ret = regulator_enable(gp2ap002->vio);
>  	if (ret) {
>  		dev_err(dev, "failed to enable VIO regulator in resume path\n");
> -		return ret;
> +		goto out_disable_vdd;
>  	}
>  
>  	msleep(20);
> @@ -685,13 +685,19 @@ static int gp2ap002_runtime_resume(struct device *dev)
>  	ret = gp2ap002_init(gp2ap002);
>  	if (ret) {
>  		dev_err(dev, "re-initialization failed\n");
> -		return ret;
> +		goto out_disable_vio;
>  	}
>  
>  	/* Re-activate the IRQ */
>  	enable_irq(gp2ap002->irq);
>  
>  	return 0;
> +
> +out_disable_vio:
> +	regulator_disable(gp2ap002->vio);
> +out_disable_vdd:
> +	regulator_disable(gp2ap002->vdd);
> +	return ret;
>  }
>  
>  static DEFINE_RUNTIME_DEV_PM_OPS(gp2ap002_dev_pm_ops, gp2ap002_runtime_suspend,


      reply	other threads:[~2026-08-03  0:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22 16:22 [PATCH v2 0/3] iio: light: gp2ap002: runtime PM and error path fixes Nikhil Gautam
2026-07-22 16:22 ` [PATCH v2 1/3] iio: light: gp2ap002: Fix unbalanced runtime PM on repeated event writes Nikhil Gautam
2026-07-25  0:52   ` Jonathan Cameron
2026-08-03  0:19     ` Jonathan Cameron
2026-07-22 16:22 ` [PATCH v2 2/3] iio: light: gp2ap002: re-enable irq if runtime suspend fails Nikhil Gautam
2026-07-22 16:22 ` [PATCH v2 3/3] iio: light: gp2ap002: Fix regulator leaks in runtime resume error path Nikhil Gautam
2026-08-03  0:27   ` 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=20260803012738.2abf14db@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nikhilgtr@gmail.com \
    --cc=nuno.sa@analog.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