lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sun, 18 Jan 2009 18:47:25 +0000
From:	Jonathan Cameron <jic23@....ac.uk>
To:	Liam Girdwood <lrg@...mlogic.co.uk>
CC:	LKML <linux-kernel@...r.kernel.org>,
	broonie@...nsource.wolfsonmicro.com
Subject: [RFC] Regulator: Add a voltage changed event to notify consumers

From: Jonathan Cameron <jic23@....ac.uk>
Regulator: Add a voltage changed event to notify consumers
that care when another device changes the regulator voltage.

Signed-off-by: Jonathan Cameron <jic23@....ac.uk>
---
If people are happy with this I'll post a follow up to update the
documentation to reflect this additional event.

This is pretty simple and very similar to the way the forced
disable event is handled. 

Worth noting is that (along with other events) the notifier
blocks are called with the regulator's lock held so any
attempt by consumers to update their voltage must be done
via a scheduled update call rather than within the callback
it self. The documentation will emphasize this.

Example of usage is the sht15 driver posted to lm-sensors where
the temperature measurement is dependent on the supply voltage
and hence needs to know if this has changed.

 drivers/regulator/core.c           |   10 ++++++----
 include/linux/regulator/consumer.h |    2 ++
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index f511a40..9fec166 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1231,18 +1231,20 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
 	/* sanity check */
 	if (!rdev->desc->ops->set_voltage) {
 		ret = -EINVAL;
-		goto out;
+		goto out_unlock;
 	}
 
 	/* constraints check */
 	ret = regulator_check_voltage(rdev, &min_uV, &max_uV);
 	if (ret < 0)
-		goto out;
+		goto out_unlock;
 	regulator->min_uV = min_uV;
 	regulator->max_uV = max_uV;
 	ret = rdev->desc->ops->set_voltage(rdev, min_uV, max_uV);
-
-out:
+	mutex_unlock(&rdev->mutex);
+	_notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE, NULL);
+	return 0;
+out_unlock:
 	mutex_unlock(&rdev->mutex);
 	return ret;
 }
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index 801bf77..6107a70 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -88,6 +88,7 @@
  * FAIL           Regulator output has failed.
  * OVER_TEMP      Regulator over temp.
  * FORCE_DISABLE  Regulator shut down by software.
+ * VOLTAGE_CHANGE Regulator voltage changed.	
  *
  * NOTE: These events can be OR'ed together when passed into handler.
  */
@@ -98,6 +99,7 @@
 #define REGULATOR_EVENT_FAIL			0x08
 #define REGULATOR_EVENT_OVER_TEMP		0x10
 #define REGULATOR_EVENT_FORCE_DISABLE		0x20
+#define REGULATOR_EVENT_VOLTAGE_CHANGE		0x40
 
 struct regulator;
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ