mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Simon Horman <horms@verge.net.au>
To: Liam Girdwood <lrg@ti.com>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: linux-kernel@vger.kernel.org, Simon Horman <horms@verge.net.au>
Subject: [PATCH] regulator: notify sysfs when voltage is set
Date: Thu, 15 Mar 2012 21:04:33 +0900	[thread overview]
Message-ID: <1331813073-714-1-git-send-email-horms@verge.net.au> (raw)

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@verge.net.au>
---
 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


             reply	other threads:[~2012-03-15 12:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-15 12:04 Simon Horman [this message]
2012-03-15 12:46 ` Mark Brown
2012-03-15 14:26   ` Simon Horman
2012-03-15 14:47     ` Mark Brown
2012-03-15 23:23       ` Simon Horman

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=1331813073-714-1-git-send-email-horms@verge.net.au \
    --to=horms@verge.net.au \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@ti.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®