Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1385176 > unrolled thread

[PATCH] regulator: core: Add debugfs for regulator always_on flag

Started byRichard Fitzgerald <rf@opensource.wolfsonmicro.com>
First post2016-04-22 15:40 +0200
Last post2016-04-22 16:50 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] regulator: core: Add debugfs for regulator always_on flag Richard Fitzgerald <rf@opensource.wolfsonmicro.com> - 2016-04-22 15:40 +0200
    Re: [PATCH] regulator: core: Add debugfs for regulator always_on flag Mark Brown <broonie@kernel.org> - 2016-04-22 16:00 +0200
      Re: [PATCH] regulator: core: Add debugfs for regulator always_on  flag Richard Fitzgerald <rf@opensource.wolfsonmicro.com> - 2016-04-22 16:50 +0200

#1385176 — [PATCH] regulator: core: Add debugfs for regulator always_on flag

FromRichard Fitzgerald <rf@opensource.wolfsonmicro.com>
Date2016-04-22 15:40 +0200
Subject[PATCH] regulator: core: Add debugfs for regulator always_on flag
Message-ID<rqJto-2Ga-7@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1385203

FromMark Brown <broonie@kernel.org>
Date2016-04-22 16:00 +0200
Message-ID<rqJML-2OK-37@gated-at.bofh.it>
In reply to#1385176

[Multipart message — attachments visible in raw view] — view raw

On Fri, Apr 22, 2016 at 02:33:02PM +0100, Richard Fitzgerald wrote:
> 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.

Why not include this in the same file as the rest of the constraints?
Or why not have one file per constraint (which would be easier for
scripts)?

> +	ret = snprintf(buf, PAGE_SIZE, "always_on: %u\n", regulator->always_on);

> +		debugfs_create_file("always_on", 0444, regulator->debugfs,

It seems to be formatted as though it's going to end up in the same file
but it's a separate file so instead it's just repeating the name of the
file inside the file.

[toc] | [prev] | [next] | [standalone]


#1385244 — Re: [PATCH] regulator: core: Add debugfs for regulator always_on flag

FromRichard Fitzgerald <rf@opensource.wolfsonmicro.com>
Date2016-04-22 16:50 +0200
SubjectRe: [PATCH] regulator: core: Add debugfs for regulator always_on flag
Message-ID<rqKz8-3sD-13@gated-at.bofh.it>
In reply to#1385203
On 22/04/16 14:57, Mark Brown wrote:
> On Fri, Apr 22, 2016 at 02:33:02PM +0100, Richard Fitzgerald wrote:
>> 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.
> Why not include this in the same file as the rest of the constraints?
> Or why not have one file per constraint (which would be easier for
> scripts)?
Hmm, well the thing is there's two separate always_on flags, the one in 
constraints (if you have any constraints) and the one in struct 
regulator. I could munge the always_on status printed in the constraints 
debugfs to be (regulator.always_on || constraints.always_on) though I'm 
not sure if that's helpful (it shows actual state) or confusing (it 
might not match what was fed in as constraints).
>> +	ret = snprintf(buf, PAGE_SIZE, "always_on: %u\n", regulator->always_on);
>> +		debugfs_create_file("always_on", 0444, regulator->debugfs,
> It seems to be formatted as though it's going to end up in the same file
> but it's a separate file so instead it's just repeating the name of the
> file inside the file.
Sorry, that was lazy copy-and-paste. I'll fix it.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web