* [PATCH] regulator: core: Add PRE_DISABLE notification
@ 2014-11-24 14:10 Richard Fitzgerald
2014-11-24 15:26 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Richard Fitzgerald @ 2014-11-24 14:10 UTC (permalink / raw)
To: broonie; +Cc: lgirdwood, linux-kernel, patches
Add a PRE_DISABLE notification so that consumers can use a
notifier to run any steps required to prepare for the
regulator being switched off. Since the regulator disable
can fail an abort notification is also added.
Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
---
drivers/regulator/core.c | 16 ++++++++++++++++
include/linux/regulator/consumer.h | 4 ++++
2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index bbf93c9..8f48df4 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1976,9 +1976,18 @@ static int _regulator_disable(struct regulator_dev *rdev)
/* we are last user */
if (_regulator_can_change_status(rdev)) {
+ ret = _notifier_call_chain(rdev,
+ REGULATOR_EVENT_PRE_DISABLE,
+ NULL);
+ if (ret & NOTIFY_STOP_MASK)
+ return -EINVAL;
+
ret = _regulator_do_disable(rdev);
if (ret < 0) {
rdev_err(rdev, "failed to disable\n");
+ _notifier_call_chain(rdev,
+ REGULATOR_EVENT_ABORT_DISABLE,
+ NULL);
return ret;
}
_notifier_call_chain(rdev, REGULATOR_EVENT_DISABLE,
@@ -2035,9 +2044,16 @@ static int _regulator_force_disable(struct regulator_dev *rdev)
{
int ret = 0;
+ ret = _notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE |
+ REGULATOR_EVENT_PRE_DISABLE, NULL);
+ if (ret & NOTIFY_STOP_MASK)
+ return -EINVAL;
+
ret = _regulator_do_disable(rdev);
if (ret < 0) {
rdev_err(rdev, "failed to force disable\n");
+ _notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE |
+ REGULATOR_EVENT_ABORT_DISABLE, NULL);
return ret;
}
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index 3c4fad5..d17e1ff 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -101,6 +101,8 @@ struct regmap;
* Data passed is "struct pre_voltage_change_data"
* ABORT_VOLTAGE_CHANGE Regulator voltage change failed for some reason.
* Data passed is old voltage cast to (void *).
+ * PRE_DISABLE Regulator is about to be disabled
+ * ABORT_DISABLE Regulator disable failed for some reason
*
* NOTE: These events can be OR'ed together when passed into handler.
*/
@@ -115,6 +117,8 @@ struct regmap;
#define REGULATOR_EVENT_DISABLE 0x80
#define REGULATOR_EVENT_PRE_VOLTAGE_CHANGE 0x100
#define REGULATOR_EVENT_ABORT_VOLTAGE_CHANGE 0x200
+#define REGULATOR_EVENT_PRE_DISABLE 0x400
+#define REGULATOR_EVENT_ABORT_DISABLE 0x800
/**
* struct pre_voltage_change_data - Data sent with PRE_VOLTAGE_CHANGE event
--
1.7.2.5
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] regulator: core: Add PRE_DISABLE notification
2014-11-24 14:10 [PATCH] regulator: core: Add PRE_DISABLE notification Richard Fitzgerald
@ 2014-11-24 15:26 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2014-11-24 15:26 UTC (permalink / raw)
To: Richard Fitzgerald; +Cc: lgirdwood, linux-kernel, patches
[-- Attachment #1: Type: text/plain, Size: 311 bytes --]
On Mon, Nov 24, 2014 at 02:10:52PM +0000, Richard Fitzgerald wrote:
> Add a PRE_DISABLE notification so that consumers can use a
> notifier to run any steps required to prepare for the
> regulator being switched off. Since the regulator disable
> can fail an abort notification is also added.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-11-24 15:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-24 14:10 [PATCH] regulator: core: Add PRE_DISABLE notification Richard Fitzgerald
2014-11-24 15:26 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome