All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clk: add clk_possible_parents debugfs file
@ 2017-03-21 13:20 Peter De Schrijver
  2017-04-07 19:45 ` Stephen Boyd
  0 siblings, 1 reply; 3+ messages in thread
From: Peter De Schrijver @ 2017-03-21 13:20 UTC (permalink / raw)
  To: Peter De Schrijver, Michael Turquette, Stephen Boyd, linux-clk,
	linux-kernel

For validation purposes, it's often useful to be able to retrieve the list
of possible parents in userspace. Add a debugfs file for every clock which
has more than 1 possible parent.

Signed-off-by: Peter De Schrijver <pdeschrijver@nvidia.com>
Reviewed-by: Jon Mayo <jmayo@nvidia.com>
---
 drivers/clk/clk.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index f5f2bcd..2fa2fb8 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2128,6 +2128,34 @@ static int clk_dump_open(struct inode *inode, struct file *file)
 	.release	= single_release,
 };
 
+static int possible_parents_dump(struct seq_file *s, void *data)
+{
+	struct clk_core *core;
+	int i;
+
+	core = (struct clk_core *)s->private;
+
+	for (i = 0; i < core->num_parents - 1; i++)
+		seq_printf(s, "%s ", core->parent_names[i]);
+
+	seq_printf(s, "%s\n", core->parent_names[i]);
+
+	return 0;
+}
+
+static int possible_parents_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, possible_parents_dump, inode->i_private);
+}
+
+
+static const struct file_operations possible_parents_fops = {
+	.open		= possible_parents_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
+
 static int clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
 {
 	struct dentry *d;
@@ -2179,6 +2207,13 @@ static int clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
 	if (!d)
 		goto err_out;
 
+	if (core->num_parents > 1) {
+		d = debugfs_create_file("clk_possible_parents", S_IRUGO,
+				core->dentry, core, &possible_parents_fops);
+		if (!d)
+			goto err_out;
+	}
+
 	if (core->ops->debug_init) {
 		ret = core->ops->debug_init(core->hw, core->dentry);
 		if (ret)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] clk: add clk_possible_parents debugfs file
  2017-03-21 13:20 [PATCH] clk: add clk_possible_parents debugfs file Peter De Schrijver
@ 2017-04-07 19:45 ` Stephen Boyd
  2017-04-11 13:47   ` Peter De Schrijver
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Boyd @ 2017-04-07 19:45 UTC (permalink / raw)
  To: Peter De Schrijver; +Cc: Michael Turquette, linux-clk, linux-kernel

On 03/21, Peter De Schrijver wrote:
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index f5f2bcd..2fa2fb8 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -2128,6 +2128,34 @@ static int clk_dump_open(struct inode *inode, struct file *file)
>  	.release	= single_release,
>  };
>  
> +static int possible_parents_dump(struct seq_file *s, void *data)
> +{
> +	struct clk_core *core;
> +	int i;
> +
> +	core = (struct clk_core *)s->private;

Useless cast from void.

> +
> +	for (i = 0; i < core->num_parents - 1; i++)
> +		seq_printf(s, "%s ", core->parent_names[i]);

I hope we don't have spaces in clk names! I don't think we do.

> +
> +	seq_printf(s, "%s\n", core->parent_names[i]);
> +
> +	return 0;
> +}
> +
> +static int possible_parents_open(struct inode *inode, struct file *file)
> +{
> +	return single_open(file, possible_parents_dump, inode->i_private);
> +}
> +
> +

Double newline.

I fixed both when applying to clk-next.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] clk: add clk_possible_parents debugfs file
  2017-04-07 19:45 ` Stephen Boyd
@ 2017-04-11 13:47   ` Peter De Schrijver
  0 siblings, 0 replies; 3+ messages in thread
From: Peter De Schrijver @ 2017-04-11 13:47 UTC (permalink / raw)
  To: Stephen Boyd; +Cc: Michael Turquette, linux-clk, linux-kernel

On Fri, Apr 07, 2017 at 12:45:06PM -0700, Stephen Boyd wrote:
> On 03/21, Peter De Schrijver wrote:
> > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> > index f5f2bcd..2fa2fb8 100644
> > --- a/drivers/clk/clk.c
> > +++ b/drivers/clk/clk.c
> > @@ -2128,6 +2128,34 @@ static int clk_dump_open(struct inode *inode, struct file *file)
> >  	.release	= single_release,
> >  };
> >  
> > +static int possible_parents_dump(struct seq_file *s, void *data)
> > +{
> > +	struct clk_core *core;
> > +	int i;
> > +
> > +	core = (struct clk_core *)s->private;
> 
> Useless cast from void.
> 
> > +
> > +	for (i = 0; i < core->num_parents - 1; i++)
> > +		seq_printf(s, "%s ", core->parent_names[i]);
> 
> I hope we don't have spaces in clk names! I don't think we do.
> 

I don't think we do either, at least I've never seen a clk name with a space.

Peter.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-11 13:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-21 13:20 [PATCH] clk: add clk_possible_parents debugfs file Peter De Schrijver
2017-04-07 19:45 ` Stephen Boyd
2017-04-11 13:47   ` Peter De Schrijver

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.