lkml.org 
[lkml]   [2023]   [Jun]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
Subject[PATCH RFC v4 11/13] regulator: implement mon_unsupported_reg_modes
From: Benjamin Bara <benjamin.bara@skidata.com>

The mon_unsupported_reg_modes property disables all dt-enabled monitors
when the mode of the regulator is changed to an "unsupported" one.

Signed-off-by: Benjamin Bara <benjamin.bara@skidata.com>
---
drivers/regulator/core.c | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 74b9c12d38e9..ca768d0ddb1e 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -4816,8 +4816,21 @@ int regulator_set_mode(struct regulator *regulator, unsigned int mode)
if (ret < 0)
goto out;

+ if (mode & rdev->desc->mon_unsupported_reg_modes) {
+ ret = monitors_disable(rdev, REGULATOR_MONITOR_ALL);
+ if (ret)
+ goto out;
+ }
+
ret = rdev->desc->ops->set_mode(rdev, mode);
+
out:
+ /* if changing mode failed, ignore monitoring error. */
+ if (ret)
+ monitors_reenable(rdev, REGULATOR_MONITOR_ALL);
+ else
+ ret = monitors_reenable(rdev, REGULATOR_MONITOR_ALL);
+
regulator_unlock(rdev);
return ret;
}
--
2.34.1

\
 
 \ /
  Last update: 2023-06-20 22:05    [W:0.217 / U:0.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site