[PATCH] regulator: notify sysfs when voltage is set
From: Simon Horman
Date: Thu Mar 15 2012 - 08:04:53 EST
This allows libudev to be used to monitor voltage changes and thus allows
user-space code to avoid polling the sysfs entry for changes.
Signed-off-by: Simon Horman <horms@xxxxxxxxxxxx>
---
drivers/regulator/core.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index b97c4a2..f3905b0 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1783,6 +1783,19 @@ int regulator_is_supported_voltage(struct regulator *regulator,
}
EXPORT_SYMBOL_GPL(regulator_is_supported_voltage);
+static void regulator_generate_event(struct regulator_dev *rdev)
+{
+ char buf[32], *envp[2];
+
+ sprintf(buf, "MICROVOLTS=%d", _regulator_get_voltage(rdev));
+
+ envp[0] = buf;
+ envp[1] = NULL;
+
+ kobject_uevent_env(&rdev->dev.kobj, KOBJ_CHANGE, envp);
+ sysfs_notify(&rdev->dev.kobj, NULL, "microvolts");
+}
+
static int _regulator_do_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV)
{
@@ -1862,6 +1875,8 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
udelay(delay);
}
+ regulator_generate_event(rdev);
+
if (ret == 0)
_notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE,
NULL);
--
1.7.6.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/