[5/5,RFC] ARM: timer-sp: Use of_clk_get_parent_count() instead of open coding
diff mbox

Message ID 1432891549-23295-6-git-send-email-geert+renesas@glider.be
State New
Headers show

Commit Message

Geert Uytterhoeven May 29, 2015, 9:25 a.m. UTC
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
This is an RFC, as it depends on "[RFC] clk: Provide dummy
of_clk_get_parent_count() for !OF/!CCF".
---
 arch/arm/common/timer-sp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Stephen Boyd June 3, 2015, 11:44 p.m. UTC | #1
On 05/29, Geert Uytterhoeven wrote:
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> This is an RFC, as it depends on "[RFC] clk: Provide dummy
> of_clk_get_parent_count() for !OF/!CCF".
> ---
>  arch/arm/common/timer-sp.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/common/timer-sp.c b/arch/arm/common/timer-sp.c
> index 19211324772f387c..be87a5d480ffb655 100644
> --- a/arch/arm/common/timer-sp.c
> +++ b/arch/arm/common/timer-sp.c
> @@ -21,6 +21,7 @@
>  #include <linux/clk.h>
>  #include <linux/clocksource.h>
>  #include <linux/clockchips.h>
> +#include <linux/clk-provider.h>

This looks weird. This is not a clock provider.

>  #include <linux/err.h>
>  #include <linux/interrupt.h>
>  #include <linux/irq.h>
> @@ -234,7 +235,7 @@ static void __init sp804_of_init(struct device_node *np)
>  		clk1 = NULL;
>  
>  	/* Get the 2nd clock if the timer has 3 timer clocks */
> -	if (of_count_phandle_with_args(np, "clocks", "#clock-cells") == 3) {
> +	if (of_clk_get_parent_count(np) == 3) {

So maybe it means if we want to expose of_clk_get_parent_count()
we should move it to some other header file (of_clk.h?). And then
maybe we should always compile said helpers if OF=y and
HAVE_CLK=y.
Geert Uytterhoeven June 4, 2015, 7:26 a.m. UTC | #2
Hi Stephen,

On Thu, Jun 4, 2015 at 1:44 AM, Stephen Boyd <sboyd@codeaurora.org> wrote:
> On 05/29, Geert Uytterhoeven wrote:
>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>> ---
>> This is an RFC, as it depends on "[RFC] clk: Provide dummy
>> of_clk_get_parent_count() for !OF/!CCF".
>> ---
>>  arch/arm/common/timer-sp.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/common/timer-sp.c b/arch/arm/common/timer-sp.c
>> index 19211324772f387c..be87a5d480ffb655 100644
>> --- a/arch/arm/common/timer-sp.c
>> +++ b/arch/arm/common/timer-sp.c
>> @@ -21,6 +21,7 @@
>>  #include <linux/clk.h>
>>  #include <linux/clocksource.h>
>>  #include <linux/clockchips.h>
>> +#include <linux/clk-provider.h>
>
> This looks weird. This is not a clock provider.

But that's where the declaration of of_clk_get_parent_count() lives...

>>  #include <linux/err.h>
>>  #include <linux/interrupt.h>
>>  #include <linux/irq.h>
>> @@ -234,7 +235,7 @@ static void __init sp804_of_init(struct device_node *np)
>>               clk1 = NULL;
>>
>>       /* Get the 2nd clock if the timer has 3 timer clocks */
>> -     if (of_count_phandle_with_args(np, "clocks", "#clock-cells") == 3) {
>> +     if (of_clk_get_parent_count(np) == 3) {
>
> So maybe it means if we want to expose of_clk_get_parent_count()
> we should move it to some other header file (of_clk.h?). And then
> maybe we should always compile said helpers if OF=y and
> HAVE_CLK=y.

That makes sense.

Currently we have lots of of_clk_*() in <linux/clk-provider.h>, and a few
of_clk_get*() in <inux/clk.h>.
And the mysterious of_clk_set_defaults() in <linux/clk/clk-conf.h>.

All of_clk_get*() could be moved to a new <linux/of_clk.h>.

Alternatively, of_clk_get_parent_count() could just move to <linux/clk.h>?

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
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Stephen Boyd June 4, 2015, 6:14 p.m. UTC | #3
On 06/04, Geert Uytterhoeven wrote:
> Hi Stephen,
> 
> On Thu, Jun 4, 2015 at 1:44 AM, Stephen Boyd <sboyd@codeaurora.org> wrote:
> > On 05/29, Geert Uytterhoeven wrote:
> >> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> >>  #include <linux/err.h>
> >>  #include <linux/interrupt.h>
> >>  #include <linux/irq.h>
> >> @@ -234,7 +235,7 @@ static void __init sp804_of_init(struct device_node *np)
> >>               clk1 = NULL;
> >>
> >>       /* Get the 2nd clock if the timer has 3 timer clocks */
> >> -     if (of_count_phandle_with_args(np, "clocks", "#clock-cells") == 3) {
> >> +     if (of_clk_get_parent_count(np) == 3) {
> >
> > So maybe it means if we want to expose of_clk_get_parent_count()
> > we should move it to some other header file (of_clk.h?). And then
> > maybe we should always compile said helpers if OF=y and
> > HAVE_CLK=y.
> 
> That makes sense.
> 
> Currently we have lots of of_clk_*() in <linux/clk-provider.h>, and a few
> of_clk_get*() in <inux/clk.h>.
> And the mysterious of_clk_set_defaults() in <linux/clk/clk-conf.h>.
> 
> All of_clk_get*() could be moved to a new <linux/of_clk.h>.
> 
> Alternatively, of_clk_get_parent_count() could just move to <linux/clk.h>?

Hmm... of_clk_*() functions that return a struct clk * or work
with a struct clk * should stay within clk.h. But these ones in
clk-provider.h should probably move to a new of_clk.h file:

	of_clk_get_parent_count
	of_clk_get_parent_name
	of_clk_init

Patch
diff mbox

diff --git a/arch/arm/common/timer-sp.c b/arch/arm/common/timer-sp.c
index 19211324772f387c..be87a5d480ffb655 100644
--- a/arch/arm/common/timer-sp.c
+++ b/arch/arm/common/timer-sp.c
@@ -21,6 +21,7 @@ 
 #include <linux/clk.h>
 #include <linux/clocksource.h>
 #include <linux/clockchips.h>
+#include <linux/clk-provider.h>
 #include <linux/err.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
@@ -234,7 +235,7 @@  static void __init sp804_of_init(struct device_node *np)
 		clk1 = NULL;
 
 	/* Get the 2nd clock if the timer has 3 timer clocks */
-	if (of_count_phandle_with_args(np, "clocks", "#clock-cells") == 3) {
+	if (of_clk_get_parent_count(np) == 3) {
 		clk2 = of_clk_get(np, 1);
 		if (IS_ERR(clk2)) {
 			pr_err("sp804: %s clock not found: %d\n", np->name,