Linux IIO development
 help / color / mirror / Atom feed
From: "Li Youhong" <dayou5941@163.com>
To: wafgo01@gmail.com, jic23@kernel.org
Cc: maxwell@maxwelld.cc, dlechner@baylibre.com, nuno.sa@analog.com,
	andy@kernel.org, linux-iio@vger.kernel.org,
	Li Youhong <liyouhong@kylinos.cn>
Subject: [PATCH v2] iio: flow: slf3s: disable regulator if measurement restart fails
Date: Fri,  4 Sep 2026 09:09:02 +0800	[thread overview]
Message-ID: <20260904010902.1481157-1-dayou5941@163.com> (raw)

From: Li Youhong <liyouhong@kylinos.cn>

slf3s_resume() enables the vdd regulator and then starts continuous
measurement. If slf3s_start_meas() fails, resume returns an error
while leaving the regulator enabled.

After a failed resume the device stays suspended until another resume
attempt. That later resume will call regulator_enable() again. Without
a matching disable on the failed path, the regulator enable count is
skewed and the supply can remain on even after a successful suspend.

Disable vdd when slf3s_start_meas() fails so the enable/disable pairing
stays balanced across resume retries.

Fixes: d240b0b8a1ce ("iio: flow: add Sensirion SLF3S liquid flow sensor driver")
Signed-off-by: Li Youhong <liyouhong@kylinos.cn>
---
v2:
- Expand the commit message to explain resume-retry regulator refcounting
  v1 Link: https://lore.kernel.org/all/20260901025010.356735-1-dayou5941@163.com/

 drivers/iio/flow/slf3s.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/flow/slf3s.c b/drivers/iio/flow/slf3s.c
index dfa7c1409045..9b63ceb3768a 100644
--- a/drivers/iio/flow/slf3s.c
+++ b/drivers/iio/flow/slf3s.c
@@ -487,7 +487,11 @@ static int slf3s_resume(struct device *dev)
 
 	fsleep(SLF3S_POWER_UP_DELAY_US);
 
-	return slf3s_start_meas(sf, sf->medium);
+	ret = slf3s_start_meas(sf, sf->medium);
+	if (ret)
+		regulator_disable(sf->vdd);
+
+	return ret;
 }
 
 static DEFINE_SIMPLE_DEV_PM_OPS(slf3s_pm_ops, slf3s_suspend, slf3s_resume);
-- 
2.25.1


             reply	other threads:[~2026-09-04  1:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04  1:09 Li Youhong [this message]
2026-09-04  8:00 ` [PATCH v2] iio: flow: slf3s: disable regulator if measurement restart fails Joshua Crofts

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=20260904010902.1481157-1-dayou5941@163.com \
    --to=dayou5941@163.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=liyouhong@kylinos.cn \
    --cc=maxwell@maxwelld.cc \
    --cc=nuno.sa@analog.com \
    --cc=wafgo01@gmail.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