* [PATCH v2] iio: flow: slf3s: disable regulator if measurement restart fails
@ 2026-09-04 1:09 Li Youhong
2026-09-04 8:00 ` Joshua Crofts
0 siblings, 1 reply; 2+ messages in thread
From: Li Youhong @ 2026-09-04 1:09 UTC (permalink / raw)
To: wafgo01, jic23; +Cc: maxwell, dlechner, nuno.sa, andy, linux-iio, Li Youhong
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] iio: flow: slf3s: disable regulator if measurement restart fails
2026-09-04 1:09 [PATCH v2] iio: flow: slf3s: disable regulator if measurement restart fails Li Youhong
@ 2026-09-04 8:00 ` Joshua Crofts
0 siblings, 0 replies; 2+ messages in thread
From: Joshua Crofts @ 2026-09-04 8:00 UTC (permalink / raw)
To: Li Youhong
Cc: wafgo01, jic23, maxwell, dlechner, nuno.sa, andy, linux-iio,
Li Youhong
On Fri, 4 Sep 2026 09:09:02 +0800
"Li Youhong" <dayou5941@163.com> wrote:
> 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>
> ---
LGTM.
Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
--
Kind regards,
Joshua Crofts
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-04 8:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-04 1:09 [PATCH v2] iio: flow: slf3s: disable regulator if measurement restart fails Li Youhong
2026-09-04 8:00 ` Joshua Crofts
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox