All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clk: Add clk_parent entry in debugfs
@ 2019-05-24  8:25 ` Leonard Crestez
  0 siblings, 0 replies; 10+ messages in thread
From: Leonard Crestez @ 2019-05-24  8:25 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Michael Turquette, Peter De Schrijver, Geert Uytterhoeven,
	Greg Kroah-Hartman, Rafael J. Wysocki, linux-clk,
	linux-arm-kernel

This allows to easily determine the parent in shell scripts without
parsing more complex files.

Add the clk_parent file unconditionally because this information is
useful for more than just muxes.

Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
---
 drivers/clk/clk.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index aa51756fd4d6..94a93b07dd37 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3009,10 +3009,21 @@ static int possible_parents_show(struct seq_file *s, void *data)
 
 	return 0;
 }
 DEFINE_SHOW_ATTRIBUTE(possible_parents);
 
+static int current_parent_show(struct seq_file *s, void *data)
+{
+	struct clk_core *core = s->private;
+
+	if (core->parent)
+		seq_printf(s, "%s\n", core->parent->name);
+
+	return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(current_parent);
+
 static int clk_duty_cycle_show(struct seq_file *s, void *data)
 {
 	struct clk_core *core = s->private;
 	struct clk_duty *duty = &core->duty;
 
@@ -3040,10 +3051,11 @@ static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
 	debugfs_create_u32("clk_enable_count", 0444, root, &core->enable_count);
 	debugfs_create_u32("clk_protect_count", 0444, root, &core->protect_count);
 	debugfs_create_u32("clk_notifier_count", 0444, root, &core->notifier_count);
 	debugfs_create_file("clk_duty_cycle", 0444, root, core,
 			    &clk_duty_cycle_fops);
+	debugfs_create_file("clk_parent", 0444, root, core, &current_parent_fops);
 
 	if (core->num_parents > 1)
 		debugfs_create_file("clk_possible_parents", 0444, root, core,
 				    &possible_parents_fops);
 
-- 
2.17.1


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

* [PATCH] clk: Add clk_parent entry in debugfs
@ 2019-05-24  8:25 ` Leonard Crestez
  0 siblings, 0 replies; 10+ messages in thread
From: Leonard Crestez @ 2019-05-24  8:25 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Peter De Schrijver, Geert Uytterhoeven, Rafael J. Wysocki,
	Greg Kroah-Hartman, Michael Turquette, linux-clk,
	linux-arm-kernel

This allows to easily determine the parent in shell scripts without
parsing more complex files.

Add the clk_parent file unconditionally because this information is
useful for more than just muxes.

Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
---
 drivers/clk/clk.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index aa51756fd4d6..94a93b07dd37 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3009,10 +3009,21 @@ static int possible_parents_show(struct seq_file *s, void *data)
 
 	return 0;
 }
 DEFINE_SHOW_ATTRIBUTE(possible_parents);
 
+static int current_parent_show(struct seq_file *s, void *data)
+{
+	struct clk_core *core = s->private;
+
+	if (core->parent)
+		seq_printf(s, "%s\n", core->parent->name);
+
+	return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(current_parent);
+
 static int clk_duty_cycle_show(struct seq_file *s, void *data)
 {
 	struct clk_core *core = s->private;
 	struct clk_duty *duty = &core->duty;
 
@@ -3040,10 +3051,11 @@ static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
 	debugfs_create_u32("clk_enable_count", 0444, root, &core->enable_count);
 	debugfs_create_u32("clk_protect_count", 0444, root, &core->protect_count);
 	debugfs_create_u32("clk_notifier_count", 0444, root, &core->notifier_count);
 	debugfs_create_file("clk_duty_cycle", 0444, root, core,
 			    &clk_duty_cycle_fops);
+	debugfs_create_file("clk_parent", 0444, root, core, &current_parent_fops);
 
 	if (core->num_parents > 1)
 		debugfs_create_file("clk_possible_parents", 0444, root, core,
 				    &possible_parents_fops);
 
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] clk: Add clk_parent entry in debugfs
  2019-05-24  8:25 ` Leonard Crestez
@ 2019-06-07 19:05   ` Stephen Boyd
  -1 siblings, 0 replies; 10+ messages in thread
From: Stephen Boyd @ 2019-06-07 19:05 UTC (permalink / raw)
  To: Leonard Crestez
  Cc: Michael Turquette, Peter De Schrijver, Geert Uytterhoeven,
	Greg Kroah-Hartman, Rafael J. Wysocki, linux-clk,
	linux-arm-kernel

Quoting Leonard Crestez (2019-05-24 01:25:25)
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index aa51756fd4d6..94a93b07dd37 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -3009,10 +3009,21 @@ static int possible_parents_show(struct seq_file *s, void *data)
>  
>         return 0;
>  }
>  DEFINE_SHOW_ATTRIBUTE(possible_parents);
>  
> +static int current_parent_show(struct seq_file *s, void *data)
> +{
> +       struct clk_core *core = s->private;
> +
> +       if (core->parent)
> +               seq_printf(s, "%s\n", core->parent->name);
> +
> +       return 0;
> +}
> +DEFINE_SHOW_ATTRIBUTE(current_parent);

Looks OK.

> +
>  static int clk_duty_cycle_show(struct seq_file *s, void *data)
>  {
>         struct clk_core *core = s->private;
>         struct clk_duty *duty = &core->duty;
>  
> @@ -3040,10 +3051,11 @@ static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
>         debugfs_create_u32("clk_enable_count", 0444, root, &core->enable_count);
>         debugfs_create_u32("clk_protect_count", 0444, root, &core->protect_count);
>         debugfs_create_u32("clk_notifier_count", 0444, root, &core->notifier_count);
>         debugfs_create_file("clk_duty_cycle", 0444, root, core,
>                             &clk_duty_cycle_fops);
> +       debugfs_create_file("clk_parent", 0444, root, core, &current_parent_fops);

Shouldn't we skip creation of this file if core->num_parents == 0? So
put this under the if condition below?

>  
>         if (core->num_parents > 1)
>                 debugfs_create_file("clk_possible_parents", 0444, root, core,
>                                     &possible_parents_fops);
>  

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

* Re: [PATCH] clk: Add clk_parent entry in debugfs
@ 2019-06-07 19:05   ` Stephen Boyd
  0 siblings, 0 replies; 10+ messages in thread
From: Stephen Boyd @ 2019-06-07 19:05 UTC (permalink / raw)
  To: Leonard Crestez
  Cc: Peter De Schrijver, Geert Uytterhoeven, Rafael J. Wysocki,
	Greg Kroah-Hartman, Michael Turquette, linux-clk,
	linux-arm-kernel

Quoting Leonard Crestez (2019-05-24 01:25:25)
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index aa51756fd4d6..94a93b07dd37 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -3009,10 +3009,21 @@ static int possible_parents_show(struct seq_file *s, void *data)
>  
>         return 0;
>  }
>  DEFINE_SHOW_ATTRIBUTE(possible_parents);
>  
> +static int current_parent_show(struct seq_file *s, void *data)
> +{
> +       struct clk_core *core = s->private;
> +
> +       if (core->parent)
> +               seq_printf(s, "%s\n", core->parent->name);
> +
> +       return 0;
> +}
> +DEFINE_SHOW_ATTRIBUTE(current_parent);

Looks OK.

> +
>  static int clk_duty_cycle_show(struct seq_file *s, void *data)
>  {
>         struct clk_core *core = s->private;
>         struct clk_duty *duty = &core->duty;
>  
> @@ -3040,10 +3051,11 @@ static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
>         debugfs_create_u32("clk_enable_count", 0444, root, &core->enable_count);
>         debugfs_create_u32("clk_protect_count", 0444, root, &core->protect_count);
>         debugfs_create_u32("clk_notifier_count", 0444, root, &core->notifier_count);
>         debugfs_create_file("clk_duty_cycle", 0444, root, core,
>                             &clk_duty_cycle_fops);
> +       debugfs_create_file("clk_parent", 0444, root, core, &current_parent_fops);

Shouldn't we skip creation of this file if core->num_parents == 0? So
put this under the if condition below?

>  
>         if (core->num_parents > 1)
>                 debugfs_create_file("clk_possible_parents", 0444, root, core,
>                                     &possible_parents_fops);
>  

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] clk: Add clk_parent entry in debugfs
  2019-06-07 19:05   ` Stephen Boyd
@ 2019-06-08  7:26     ` Leonard Crestez
  -1 siblings, 0 replies; 10+ messages in thread
From: Leonard Crestez @ 2019-06-08  7:26 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Michael Turquette, Peter De Schrijver, Geert Uytterhoeven,
	Greg Kroah-Hartman, Rafael J. Wysocki, linux-clk,
	linux-arm-kernel

On 6/7/19 10:05 PM, Stephen Boyd wrote:
> Quoting Leonard Crestez (2019-05-24 01:25:25)

>> @@ -3040,10 +3051,11 @@ static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
>>          debugfs_create_u32("clk_enable_count", 0444, root, &core->enable_count);
>>          debugfs_create_u32("clk_protect_count", 0444, root, &core->protect_count);
>>          debugfs_create_u32("clk_notifier_count", 0444, root, &core->notifier_count);
>>          debugfs_create_file("clk_duty_cycle", 0444, root, core,
>>                              &clk_duty_cycle_fops);
>> +       debugfs_create_file("clk_parent", 0444, root, core, &current_parent_fops);
> 
> Shouldn't we skip creation of this file if core->num_parents == 0? So
> put this under the if condition below?

It's still useful to determine clk tree structure from debugfs fields, 
otherwise you'd have to extract by parsing other files.

Would you hide clk_rate for fixed-rate? I'd rather have everything 
available for uniformity, even if it's otherwise constant at runtime.

--
Regards,
Leonard

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

* Re: [PATCH] clk: Add clk_parent entry in debugfs
@ 2019-06-08  7:26     ` Leonard Crestez
  0 siblings, 0 replies; 10+ messages in thread
From: Leonard Crestez @ 2019-06-08  7:26 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Peter De Schrijver, Geert Uytterhoeven, Rafael J. Wysocki,
	Greg Kroah-Hartman, Michael Turquette, linux-clk,
	linux-arm-kernel

On 6/7/19 10:05 PM, Stephen Boyd wrote:
> Quoting Leonard Crestez (2019-05-24 01:25:25)

>> @@ -3040,10 +3051,11 @@ static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
>>          debugfs_create_u32("clk_enable_count", 0444, root, &core->enable_count);
>>          debugfs_create_u32("clk_protect_count", 0444, root, &core->protect_count);
>>          debugfs_create_u32("clk_notifier_count", 0444, root, &core->notifier_count);
>>          debugfs_create_file("clk_duty_cycle", 0444, root, core,
>>                              &clk_duty_cycle_fops);
>> +       debugfs_create_file("clk_parent", 0444, root, core, &current_parent_fops);
> 
> Shouldn't we skip creation of this file if core->num_parents == 0? So
> put this under the if condition below?

It's still useful to determine clk tree structure from debugfs fields, 
otherwise you'd have to extract by parsing other files.

Would you hide clk_rate for fixed-rate? I'd rather have everything 
available for uniformity, even if it's otherwise constant at runtime.

--
Regards,
Leonard

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] clk: Add clk_parent entry in debugfs
  2019-06-08  7:26     ` Leonard Crestez
@ 2019-06-08 12:19       ` Geert Uytterhoeven
  -1 siblings, 0 replies; 10+ messages in thread
From: Geert Uytterhoeven @ 2019-06-08 12:19 UTC (permalink / raw)
  To: Leonard Crestez
  Cc: Stephen Boyd, Michael Turquette, Peter De Schrijver,
	Geert Uytterhoeven, Greg Kroah-Hartman, Rafael J. Wysocki,
	linux-clk, linux-arm-kernel

Hi Leonard,

On Sat, Jun 8, 2019 at 9:26 AM Leonard Crestez <leonard.crestez@nxp.com> wrote:
> On 6/7/19 10:05 PM, Stephen Boyd wrote:
> > Quoting Leonard Crestez (2019-05-24 01:25:25)
>
> >> @@ -3040,10 +3051,11 @@ static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
> >>          debugfs_create_u32("clk_enable_count", 0444, root, &core->enable_count);
> >>          debugfs_create_u32("clk_protect_count", 0444, root, &core->protect_count);
> >>          debugfs_create_u32("clk_notifier_count", 0444, root, &core->notifier_count);
> >>          debugfs_create_file("clk_duty_cycle", 0444, root, core,
> >>                              &clk_duty_cycle_fops);
> >> +       debugfs_create_file("clk_parent", 0444, root, core, &current_parent_fops);
> >
> > Shouldn't we skip creation of this file if core->num_parents == 0? So
> > put this under the if condition below?
>
> It's still useful to determine clk tree structure from debugfs fields,
> otherwise you'd have to extract by parsing other files.
>
> Would you hide clk_rate for fixed-rate? I'd rather have everything
> available for uniformity, even if it's otherwise constant at runtime.

Unless I' missing something, there's a big difference here: all clocks
have a rate, but not all clocks have a parent.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH] clk: Add clk_parent entry in debugfs
@ 2019-06-08 12:19       ` Geert Uytterhoeven
  0 siblings, 0 replies; 10+ messages in thread
From: Geert Uytterhoeven @ 2019-06-08 12:19 UTC (permalink / raw)
  To: Leonard Crestez
  Cc: Geert Uytterhoeven, Rafael J. Wysocki, Stephen Boyd,
	Greg Kroah-Hartman, Michael Turquette, linux-clk,
	Peter De Schrijver, linux-arm-kernel

Hi Leonard,

On Sat, Jun 8, 2019 at 9:26 AM Leonard Crestez <leonard.crestez@nxp.com> wrote:
> On 6/7/19 10:05 PM, Stephen Boyd wrote:
> > Quoting Leonard Crestez (2019-05-24 01:25:25)
>
> >> @@ -3040,10 +3051,11 @@ static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
> >>          debugfs_create_u32("clk_enable_count", 0444, root, &core->enable_count);
> >>          debugfs_create_u32("clk_protect_count", 0444, root, &core->protect_count);
> >>          debugfs_create_u32("clk_notifier_count", 0444, root, &core->notifier_count);
> >>          debugfs_create_file("clk_duty_cycle", 0444, root, core,
> >>                              &clk_duty_cycle_fops);
> >> +       debugfs_create_file("clk_parent", 0444, root, core, &current_parent_fops);
> >
> > Shouldn't we skip creation of this file if core->num_parents == 0? So
> > put this under the if condition below?
>
> It's still useful to determine clk tree structure from debugfs fields,
> otherwise you'd have to extract by parsing other files.
>
> Would you hide clk_rate for fixed-rate? I'd rather have everything
> available for uniformity, even if it's otherwise constant at runtime.

Unless I' missing something, there's a big difference here: all clocks
have a rate, but not all clocks have a parent.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] clk: Add clk_parent entry in debugfs
  2019-06-08 12:19       ` Geert Uytterhoeven
@ 2019-06-08 12:48         ` Leonard Crestez
  -1 siblings, 0 replies; 10+ messages in thread
From: Leonard Crestez @ 2019-06-08 12:48 UTC (permalink / raw)
  To: Geert Uytterhoeven, Stephen Boyd
  Cc: Michael Turquette, Peter De Schrijver, Geert Uytterhoeven,
	Greg Kroah-Hartman, Rafael J. Wysocki, linux-clk,
	linux-arm-kernel

On 6/8/19 3:19 PM, Geert Uytterhoeven wrote:
> Hi Leonard,
> 
> On Sat, Jun 8, 2019 at 9:26 AM Leonard Crestez <leonard.crestez@nxp.com> wrote:
>> On 6/7/19 10:05 PM, Stephen Boyd wrote:
>>> Quoting Leonard Crestez (2019-05-24 01:25:25)
>>
>>>> @@ -3040,10 +3051,11 @@ static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
>>>>           debugfs_create_u32("clk_enable_count", 0444, root, &core->enable_count);
>>>>           debugfs_create_u32("clk_protect_count", 0444, root, &core->protect_count);
>>>>           debugfs_create_u32("clk_notifier_count", 0444, root, &core->notifier_count);
>>>>           debugfs_create_file("clk_duty_cycle", 0444, root, core,
>>>>                               &clk_duty_cycle_fops);
>>>> +       debugfs_create_file("clk_parent", 0444, root, core, &current_parent_fops);
>>>
>>> Shouldn't we skip creation of this file if core->num_parents == 0? So
>>> put this under the if condition below?
>>
>> It's still useful to determine clk tree structure from debugfs fields,
>> otherwise you'd have to extract by parsing other files.
>>
>> Would you hide clk_rate for fixed-rate? I'd rather have everything
>> available for uniformity, even if it's otherwise constant at runtime.
> 
> Unless I' missing something, there's a big difference here: all clocks
> have a rate, but not all clocks have a parent.

Sorry, I got confused and thought that condition checked for muxes so 
the parent of intermediate clk nodes will be hidden. But intermediate 
nodes have num_parents == 1.

Will fix in v2.

--
Regards,
Leonard

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

* Re: [PATCH] clk: Add clk_parent entry in debugfs
@ 2019-06-08 12:48         ` Leonard Crestez
  0 siblings, 0 replies; 10+ messages in thread
From: Leonard Crestez @ 2019-06-08 12:48 UTC (permalink / raw)
  To: Geert Uytterhoeven, Stephen Boyd
  Cc: Peter De Schrijver, Geert Uytterhoeven, Rafael J. Wysocki,
	Greg Kroah-Hartman, Michael Turquette, linux-clk,
	linux-arm-kernel

On 6/8/19 3:19 PM, Geert Uytterhoeven wrote:
> Hi Leonard,
> 
> On Sat, Jun 8, 2019 at 9:26 AM Leonard Crestez <leonard.crestez@nxp.com> wrote:
>> On 6/7/19 10:05 PM, Stephen Boyd wrote:
>>> Quoting Leonard Crestez (2019-05-24 01:25:25)
>>
>>>> @@ -3040,10 +3051,11 @@ static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry)
>>>>           debugfs_create_u32("clk_enable_count", 0444, root, &core->enable_count);
>>>>           debugfs_create_u32("clk_protect_count", 0444, root, &core->protect_count);
>>>>           debugfs_create_u32("clk_notifier_count", 0444, root, &core->notifier_count);
>>>>           debugfs_create_file("clk_duty_cycle", 0444, root, core,
>>>>                               &clk_duty_cycle_fops);
>>>> +       debugfs_create_file("clk_parent", 0444, root, core, &current_parent_fops);
>>>
>>> Shouldn't we skip creation of this file if core->num_parents == 0? So
>>> put this under the if condition below?
>>
>> It's still useful to determine clk tree structure from debugfs fields,
>> otherwise you'd have to extract by parsing other files.
>>
>> Would you hide clk_rate for fixed-rate? I'd rather have everything
>> available for uniformity, even if it's otherwise constant at runtime.
> 
> Unless I' missing something, there's a big difference here: all clocks
> have a rate, but not all clocks have a parent.

Sorry, I got confused and thought that condition checked for muxes so 
the parent of intermediate clk nodes will be hidden. But intermediate 
nodes have num_parents == 1.

Will fix in v2.

--
Regards,
Leonard

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-06-08 12:49 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-24  8:25 [PATCH] clk: Add clk_parent entry in debugfs Leonard Crestez
2019-05-24  8:25 ` Leonard Crestez
2019-06-07 19:05 ` Stephen Boyd
2019-06-07 19:05   ` Stephen Boyd
2019-06-08  7:26   ` Leonard Crestez
2019-06-08  7:26     ` Leonard Crestez
2019-06-08 12:19     ` Geert Uytterhoeven
2019-06-08 12:19       ` Geert Uytterhoeven
2019-06-08 12:48       ` Leonard Crestez
2019-06-08 12:48         ` Leonard Crestez

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.