[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230419-dynamic-vmon-v4-9-4d3734e62ada@skidata.com>
Date: Tue, 20 Jun 2023 22:03:02 +0200
From: Benjamin Bara <bbara93@...il.com>
To: Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>
Cc: support.opensource@...semi.com,
DLG-Adam.Ward.opensource@...renesas.com,
Martin Fuzzey <martin.fuzzey@...wbird.group>,
linux-kernel@...r.kernel.org,
Matti Vaittinen <mazziesaccount@...il.com>,
Benjamin Bara <benjamin.bara@...data.com>
Subject: [PATCH RFC v4 09/13] regulator: implement mon_disable_reg_disabled
From: Benjamin Bara <benjamin.bara@...data.com>
The mon_disable_reg_disabled property disables all dt-enabled monitors
before a regulator is disabled. If an error occurs while disabling the
regulator, the monitors are enabled again.
Signed-off-by: Benjamin Bara <benjamin.bara@...data.com>
---
drivers/regulator/core.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 873e53633698..b37dcafff407 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2965,7 +2965,7 @@ static int _regulator_do_enable(struct regulator_dev *rdev)
trace_regulator_enable_complete(rdev_get_name(rdev));
- return 0;
+ return monitors_reenable(rdev, rdev->desc->mon_disable_reg_disabled);
}
/**
@@ -3124,8 +3124,13 @@ EXPORT_SYMBOL_GPL(regulator_enable);
static int _regulator_do_disable(struct regulator_dev *rdev)
{
+ const struct regulator_desc *desc = rdev->desc;
int ret;
+ ret = monitors_disable(rdev, desc->mon_disable_reg_disabled);
+ if (ret)
+ return ret;
+
trace_regulator_disable(rdev_get_name(rdev));
if (rdev->ena_pin) {
@@ -3136,13 +3141,13 @@ static int _regulator_do_disable(struct regulator_dev *rdev)
rdev->ena_gpio_state = 0;
}
- } else if (rdev->desc->ops->disable) {
- ret = rdev->desc->ops->disable(rdev);
+ } else if (desc->ops->disable) {
+ ret = desc->ops->disable(rdev);
if (ret != 0)
return ret;
}
- if (rdev->desc->off_on_delay)
+ if (desc->off_on_delay)
rdev->last_off = ktime_get_boottime();
trace_regulator_disable_complete(rdev_get_name(rdev));
@@ -3180,6 +3185,7 @@ static int _regulator_disable(struct regulator *regulator)
_notifier_call_chain(rdev,
REGULATOR_EVENT_ABORT_DISABLE,
NULL);
+ monitors_reenable(rdev, rdev->desc->mon_disable_reg_disabled);
return ret;
}
_notifier_call_chain(rdev, REGULATOR_EVENT_DISABLE,
@@ -3246,6 +3252,7 @@ static int _regulator_force_disable(struct regulator_dev *rdev)
rdev_err(rdev, "failed to force disable: %pe\n", ERR_PTR(ret));
_notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE |
REGULATOR_EVENT_ABORT_DISABLE, NULL);
+ monitors_reenable(rdev, rdev->desc->mon_disable_reg_disabled);
return ret;
}
@@ -6422,8 +6429,10 @@ static int regulator_late_cleanup(struct device *dev, void *data)
*/
rdev_info(rdev, "disabling\n");
ret = _regulator_do_disable(rdev);
- if (ret != 0)
+ if (ret != 0) {
rdev_err(rdev, "couldn't disable: %pe\n", ERR_PTR(ret));
+ monitors_reenable(rdev, rdev->desc->mon_disable_reg_disabled);
+ }
} else {
/* The intention is that in future we will
* assume that full constraints are provided
--
2.34.1
Powered by blists - more mailing lists