From: Benjamin Bara <bbara93@gmail.com>
To: Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>
Cc: support.opensource@diasemi.com,
DLG-Adam.Ward.opensource@dm.renesas.com,
linux-kernel@vger.kernel.org,
Matti Vaittinen <mazziesaccount@gmail.com>,
Benjamin Bara <benjamin.bara@skidata.com>
Subject: [PATCH RFC v3 2/5] regulator: disable monitors when regulator is disabled
Date: Sun, 21 May 2023 13:39:51 +0200 [thread overview]
Message-ID: <20230419-dynamic-vmon-v3-2-4179b586d8a1@skidata.com> (raw)
In-Reply-To: <20230419-dynamic-vmon-v3-0-4179b586d8a1@skidata.com>
From: Benjamin Bara <benjamin.bara@skidata.com>
This disables all enabled monitors before a regulator is disabled. This
only happens if an protection is enabled in the device-tree. If an error
occurs while disabling the regulator, the monitors are enabled again.
Signed-off-by: Benjamin Bara <benjamin.bara@skidata.com>
---
drivers/regulator/core.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 76f112817f9d..e59204920d6c 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2828,7 +2828,7 @@ static int _regulator_do_enable(struct regulator_dev *rdev)
trace_regulator_enable_complete(rdev_get_name(rdev));
- return 0;
+ return monitors_set_state(rdev, true);
}
/**
@@ -2989,6 +2989,10 @@ static int _regulator_do_disable(struct regulator_dev *rdev)
{
int ret;
+ ret = monitors_set_state(rdev, false);
+ if (ret)
+ return ret;
+
trace_regulator_disable(rdev_get_name(rdev));
if (rdev->ena_pin) {
@@ -3043,6 +3047,7 @@ static int _regulator_disable(struct regulator *regulator)
_notifier_call_chain(rdev,
REGULATOR_EVENT_ABORT_DISABLE,
NULL);
+ monitors_set_state(rdev, true);
return ret;
}
_notifier_call_chain(rdev, REGULATOR_EVENT_DISABLE,
@@ -3109,6 +3114,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_set_state(rdev, true);
return ret;
}
@@ -6251,8 +6257,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_set_state(rdev, true);
+ }
} else {
/* The intention is that in future we will
* assume that full constraints are provided
--
2.34.1
next prev parent reply other threads:[~2023-05-21 11:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-21 11:39 [PATCH RFC v3 0/5] regulator: dynamic voltage monitoring support Benjamin Bara
2023-05-21 11:39 ` [PATCH RFC v3 1/5] regulator: move monitor handling into own function Benjamin Bara
2023-05-23 9:46 ` Matti Vaittinen
2023-05-23 11:51 ` Benjamin Bara
2023-05-24 7:28 ` Matti Vaittinen
2023-05-24 10:47 ` Mark Brown
2023-06-13 7:33 ` Benjamin Bara
2023-05-21 11:39 ` Benjamin Bara [this message]
2023-05-21 11:39 ` [PATCH RFC v3 3/5] regulator: add getter for active monitors Benjamin Bara
2023-05-21 11:39 ` [PATCH RFC v3 4/5] regulator: add properties to handle monitoring on state change Benjamin Bara
2023-05-21 11:39 ` [PATCH RFC v3 5/5] regulator: bd718x7: let the core handle the monitors Benjamin Bara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230419-dynamic-vmon-v3-2-4179b586d8a1@skidata.com \
--to=bbara93@gmail.com \
--cc=DLG-Adam.Ward.opensource@dm.renesas.com \
--cc=benjamin.bara@skidata.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mazziesaccount@gmail.com \
--cc=support.opensource@diasemi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®