From: Naresh Solanki <naresh.solanki@9elements.com>
To: broonie@kernel.org, zev@bewilderbeest.net,
Liam Girdwood <lgirdwood@gmail.com>
Cc: Patrick Rudolph <patrick.rudolph@9elements.com>,
Naresh Solanki <naresh.solanki@9elements.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH] drivers/regulator: Notify sysfs about status changes
Date: Thu, 5 Oct 2023 15:30:58 +0200 [thread overview]
Message-ID: <20231005133059.917577-1-naresh.solanki@9elements.com> (raw)
From: Patrick Rudolph <patrick.rudolph@9elements.com>
Notify sysfs for state, status & microvolts.
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Signed-off-by: Naresh Solanki <naresh.solanki@9elements.com>
---
drivers/regulator/core.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 3137e40fcd3e..ef5fa70ae2f1 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -98,6 +98,10 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
static void destroy_regulator(struct regulator *regulator);
static void _regulator_put(struct regulator *regulator);
+static struct device_attribute dev_attr_status;
+static struct device_attribute dev_attr_microvolts;
+static struct device_attribute dev_attr_state;
+
const char *rdev_get_name(struct regulator_dev *rdev)
{
if (rdev->constraints && rdev->constraints->name)
@@ -2798,6 +2802,8 @@ static int _regulator_do_enable(struct regulator_dev *rdev)
_regulator_delay_helper(delay);
}
+ sysfs_notify(&rdev->dev.kobj, NULL, dev_attr_state.attr.name);
+
trace_regulator_enable_complete(rdev_get_name(rdev));
return 0;
@@ -2980,6 +2986,8 @@ static int _regulator_do_disable(struct regulator_dev *rdev)
if (rdev->desc->off_on_delay)
rdev->last_off = ktime_get_boottime();
+ sysfs_notify(&rdev->dev.kobj, NULL, dev_attr_state.attr.name);
+
trace_regulator_disable_complete(rdev_get_name(rdev));
return 0;
@@ -4848,8 +4856,21 @@ EXPORT_SYMBOL_GPL(regulator_unregister_notifier);
static int _notifier_call_chain(struct regulator_dev *rdev,
unsigned long event, void *data)
{
+ const char *name;
+ int ret;
+
/* call rdev chain first */
- return blocking_notifier_call_chain(&rdev->notifier, event, data);
+ ret = blocking_notifier_call_chain(&rdev->notifier, event, data);
+
+ if (event & REGULATOR_EVENT_VOLTAGE_CHANGE) {
+ name = dev_attr_microvolts.attr.name;
+ sysfs_notify(&rdev->dev.kobj, NULL, name);
+ } else {
+ name = dev_attr_status.attr.name;
+ sysfs_notify(&rdev->dev.kobj, NULL, name);
+ }
+
+ return ret;
}
int _regulator_bulk_get(struct device *dev, int num_consumers,
base-commit: f9a1d31874c383f58bb4f89bfe79b764682cd026
--
2.41.0
next reply other threads:[~2023-10-05 14:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-05 13:30 Naresh Solanki [this message]
2023-10-05 17:00 ` Mark Brown
2023-11-02 12:05 ` Naresh Solanki
2023-11-02 13:06 ` Mark Brown
2023-11-02 14:47 ` Naresh Solanki
2023-11-02 15:01 ` Mark Brown
2023-11-02 15:33 ` Naresh Solanki
2023-11-02 16:50 ` Mark Brown
2023-11-09 10:38 ` Naresh Solanki
2023-11-09 11:31 ` Mark Brown
2023-11-09 15:11 ` Naresh Solanki
2023-11-09 15:21 ` Naresh Solanki
2023-11-13 19:56 ` Mark Brown
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=20231005133059.917577-1-naresh.solanki@9elements.com \
--to=naresh.solanki@9elements.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=patrick.rudolph@9elements.com \
--cc=zev@bewilderbeest.net \
/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®