* [PATCH] iio: flow: slf3s: disable regulator if measurement restart fails
@ 2026-09-01 2:50 Li Youhong
2026-09-03 15:15 ` Andy Shevchenko
2026-09-04 7:21 ` Wadim Mueller
0 siblings, 2 replies; 3+ messages in thread
From: Li Youhong @ 2026-09-01 2:50 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. Disable vdd on that path so a
failed resume does not leave the supply on.
Fixes: d240b0b8a1ce ("iio: flow: add Sensirion SLF3S liquid flow sensor driver")
Signed-off-by: Li Youhong <liyouhong@kylinos.cn>
---
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] 3+ messages in thread
* Re: [PATCH] iio: flow: slf3s: disable regulator if measurement restart fails
2026-09-01 2:50 [PATCH] iio: flow: slf3s: disable regulator if measurement restart fails Li Youhong
@ 2026-09-03 15:15 ` Andy Shevchenko
2026-09-04 7:21 ` Wadim Mueller
1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2026-09-03 15:15 UTC (permalink / raw)
To: Li Youhong
Cc: wafgo01, jic23, maxwell, dlechner, nuno.sa, andy, linux-iio,
Li Youhong
On Tue, Sep 01, 2026 at 10:50:10AM +0800, Li Youhong wrote:
> 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. Disable vdd on that path so a
> failed resume does not leave the supply on.
In the scope of resume/suspend path this looks okay, but let's imagine
how it may work without this change. So, if resume fails, device will be
in suspend mode until it gets another resume attempt, right? Will it be
achievable at all? If so, then the regulator reference counting will go
sideways. That's what your patch is probably fixing? Needs a bit more of
an explanation in the commit message.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: flow: slf3s: disable regulator if measurement restart fails
2026-09-01 2:50 [PATCH] iio: flow: slf3s: disable regulator if measurement restart fails Li Youhong
2026-09-03 15:15 ` Andy Shevchenko
@ 2026-09-04 7:21 ` Wadim Mueller
1 sibling, 0 replies; 3+ messages in thread
From: Wadim Mueller @ 2026-09-04 7:21 UTC (permalink / raw)
To: Li Youhong, jic23; +Cc: maxwell, dlechner, nuno.sa, andy, linux-iio, Li Youhong
On 2026-09-01 10:50, Li Youhong 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. Disable vdd on that path so a
> failed resume does not leave the supply on.
>
> Fixes: d240b0b8a1ce ("iio: flow: add Sensirion SLF3S liquid flow sensor driver")
> Signed-off-by: Li Youhong <liyouhong@kylinos.cn>
> ---
> 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
Fixes the unbalanced regulator refcount across resume retries, as described.
Reviewed-by: Wadim Mueller <wafgo01@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-04 7:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-01 2:50 [PATCH] iio: flow: slf3s: disable regulator if measurement restart fails Li Youhong
2026-09-03 15:15 ` Andy Shevchenko
2026-09-04 7:21 ` Wadim Mueller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox