public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
To: <broonie@kernel.org>
Cc: <lgirdwood@gmail.com>, <patches@opensource.wolfsonmicro.com>,
	<linux-kernel@vger.kernel.org>
Subject: [PATCH] regulator: core: Add debugfs for regulator always_on flag
Date: Fri, 22 Apr 2016 14:33:02 +0100	[thread overview]
Message-ID: <1461331982-30960-1-git-send-email-rf@opensource.wolfsonmicro.com> (raw)

This patch adds a debugfs file for the always_on flag in struct regulator.
It's useful for debugging to be able to view the state of this flag and
as it's set by logic inside the regulator core it doesn't necessarily have
the same value as the always_on flag in constraints.

Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
---
 drivers/regulator/core.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 7338175..9b7ad25 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1273,6 +1273,23 @@ static void unset_regulator_supplies(struct regulator_dev *rdev)
 }
 
 #ifdef CONFIG_DEBUG_FS
+static ssize_t always_on_read_file(struct file *file, char __user *user_buf,
+				   size_t count, loff_t *ppos)
+{
+	const struct regulator *regulator = file->private_data;
+	char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
+	ssize_t ret;
+
+	if (!buf)
+		return -ENOMEM;
+
+	ret = snprintf(buf, PAGE_SIZE, "always_on: %u\n", regulator->always_on);
+	ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
+	kfree(buf);
+
+	return ret;
+}
+
 static ssize_t constraint_flags_read_file(struct file *file,
 					  char __user *user_buf,
 					  size_t count, loff_t *ppos)
@@ -1310,8 +1327,15 @@ static ssize_t constraint_flags_read_file(struct file *file,
 
 	return ret;
 }
+#endif
 
+static const struct file_operations always_on_fops = {
+#ifdef CONFIG_DEBUG_FS
+	.open = simple_open,
+	.read = always_on_read_file,
+	.llseek = default_llseek,
 #endif
+};
 
 static const struct file_operations constraint_flags_fops = {
 #ifdef CONFIG_DEBUG_FS
@@ -1376,6 +1400,8 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
 				   &regulator->min_uV);
 		debugfs_create_u32("max_uV", 0444, regulator->debugfs,
 				   &regulator->max_uV);
+		debugfs_create_file("always_on", 0444, regulator->debugfs,
+				    regulator, &always_on_fops);
 		debugfs_create_file("constraint_flags", 0444,
 				    regulator->debugfs, regulator,
 				    &constraint_flags_fops);
-- 
1.9.1

             reply	other threads:[~2016-04-22 13:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-22 13:33 Richard Fitzgerald [this message]
2016-04-22 13:57 ` [PATCH] regulator: core: Add debugfs for regulator always_on flag Mark Brown
2016-04-22 14:40   ` Richard Fitzgerald

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=1461331982-30960-1-git-send-email-rf@opensource.wolfsonmicro.com \
    --to=rf@opensource.wolfsonmicro.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@opensource.wolfsonmicro.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