iio: flow: slf3s: disable regulator if measurement restart fails
Subsystems (2)
PATCH 1/1 iio: flow: slf3s: disable regulator if measurement restart fails
From: Li Youhong <[email protected]>
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.
--- drivers/iio/flow/slf3s.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iio/flow/slf3s.c +5 -1
@@ -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);
Signature · 1 line
2.25.1
Quoted 4 lines · Li Youhong
slf3s_resume()enables the vdd regulator and then starts continuous measurement. Ifslf3s_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.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 32 lines · Li Youhong
From: Li Youhong <[email protected]>
slf3s_resume()enables the vdd regulator and then starts continuous measurement. Ifslf3s_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 <[email protected]>--- drivers/iio/flow/slf3s.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/iio/flow/slf3s.c +5
-1@@ -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);Signature · 1 line
2.25.1
Fixes the unbalanced regulator refcount across resume retries, as described.