linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Question about devm_get_clk_from_child()
       [not found] ` <87wolcbhy4.wl-kuninori.morimoto.gx@renesas.com>
@ 2019-03-06 17:20   ` Stephen Boyd
  2019-03-07  0:20     ` Kuninori Morimoto
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Boyd @ 2019-03-06 17:20 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, linux-clk

Quoting Kuninori Morimoto (2019-03-05 23:18:28)
> 
> of_clk_get_by_name() is using -1 for __of_clk_get() index.
> It will goes to of_parse_clkspec(), and be used for
> of_parse_phandle_with_args().
> Here, if user doesn't specified clock name
> (= of_clk_get_by_name(np, NULL)), this index is still -1,
> and of_parse_phandle_with_args() will return -EINVAL
> (This index will be updated if if it had clock name).
> clk_get_by_name(np, NULL) should work, then, default index
> should be 0 instead of -1.
> This patch fixup it.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  drivers/clk/clk.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index 14cbf23..96053a9 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -4213,7 +4213,7 @@ struct clk *of_clk_get_by_name(struct device_node *np, const char *name)
>         if (!np)
>                 return ERR_PTR(-ENOENT);
>  
> -       return __of_clk_get(np, -1, np->full_name, name);
> +       return __of_clk_get(np, 0, np->full_name, name);
>  }

Yes this is correct. Thanks for debugging and fixing my thinko here. I
was thinking that nobody would call of_clk_get_by_name() unless they
wanted to find some clk that had a matching name, but it seems that we
also allow NULL to be passed as the name to mean the typical "wildcard
match" thing that clkdev has done for years. I'll throw this patch on
top of the merge commit so the breakage window is small as I'd rather
not rewrite the series just for this. Thanks.


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

* Re: Question about devm_get_clk_from_child()
  2019-03-06 17:20   ` Question about devm_get_clk_from_child() Stephen Boyd
@ 2019-03-07  0:20     ` Kuninori Morimoto
  2019-03-07 19:18       ` Stephen Boyd
  0 siblings, 1 reply; 4+ messages in thread
From: Kuninori Morimoto @ 2019-03-07  0:20 UTC (permalink / raw)
  To: Stephen Boyd; +Cc: Linux-ALSA, linux-clk


Hi Stephen

> > index 14cbf23..96053a9 100644
> > --- a/drivers/clk/clk.c
> > +++ b/drivers/clk/clk.c
> > @@ -4213,7 +4213,7 @@ struct clk *of_clk_get_by_name(struct device_node *np, const char *name)
> >         if (!np)
> >                 return ERR_PTR(-ENOENT);
> >  
> > -       return __of_clk_get(np, -1, np->full_name, name);
> > +       return __of_clk_get(np, 0, np->full_name, name);
> >  }
> 
> Yes this is correct. Thanks for debugging and fixing my thinko here. I
> was thinking that nobody would call of_clk_get_by_name() unless they
> wanted to find some clk that had a matching name, but it seems that we
> also allow NULL to be passed as the name to mean the typical "wildcard
> match" thing that clkdev has done for years. I'll throw this patch on
> top of the merge commit so the breakage window is small as I'd rather
> not rewrite the series just for this. Thanks.

Ahh, OK.
So, how about this ? it is including both opinion :)
I'm not sure which one should be applied, but both can solve my issue.

--------------------
From e75755351963c9b70ff3484f3088c4ed76d9d196 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Date: Thu, 7 Mar 2019 09:05:51 +0900
Subject: [PATCH] clk: fixup default index for of_clk_get_by_name()

of_clk_get_by_name() is using -1 for __of_clk_get() index.
It will goes to of_parse_clkspec(), and be used for
of_parse_phandle_with_args().
Here, if user doesn't specified clock name
(= of_clk_get_by_name(np, NULL)), this index is still -1,
and of_parse_phandle_with_args() will return -EINVAL
(This index will be updated if if it had clock name).

OTAH, nobody would call of_clk_get_by_name() unless they
wanted to find some clk that had a matching name.
But we also allow NULL to be passed as the name to mean the
typical "wildcard match" thing.

This means default index should be 0 instead of -1 if name was NULL.
This patch fixup it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/clk/clk.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 14cbf23..66c71e9 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -4210,10 +4210,12 @@ EXPORT_SYMBOL(of_clk_get);
  */
 struct clk *of_clk_get_by_name(struct device_node *np, const char *name)
 {
+	int index = name ? -1 : 0;
+
 	if (!np)
 		return ERR_PTR(-ENOENT);
 
-	return __of_clk_get(np, -1, np->full_name, name);
+	return __of_clk_get(np, index, np->full_name, name);
 }
 EXPORT_SYMBOL(of_clk_get_by_name);
 
-- 
2.7.4


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

* Re: Question about devm_get_clk_from_child()
  2019-03-07  0:20     ` Kuninori Morimoto
@ 2019-03-07 19:18       ` Stephen Boyd
  2019-03-08  0:23         ` Kuninori Morimoto
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Boyd @ 2019-03-07 19:18 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, linux-clk

Quoting Kuninori Morimoto (2019-03-06 16:20:40)
> 
> Hi Stephen
> 
> > > index 14cbf23..96053a9 100644
> > > --- a/drivers/clk/clk.c
> > > +++ b/drivers/clk/clk.c
> > > @@ -4213,7 +4213,7 @@ struct clk *of_clk_get_by_name(struct device_node *np, const char *name)
> > >         if (!np)
> > >                 return ERR_PTR(-ENOENT);
> > >  
> > > -       return __of_clk_get(np, -1, np->full_name, name);
> > > +       return __of_clk_get(np, 0, np->full_name, name);
> > >  }
> > 
> > Yes this is correct. Thanks for debugging and fixing my thinko here. I
> > was thinking that nobody would call of_clk_get_by_name() unless they
> > wanted to find some clk that had a matching name, but it seems that we
> > also allow NULL to be passed as the name to mean the typical "wildcard
> > match" thing that clkdev has done for years. I'll throw this patch on
> > top of the merge commit so the breakage window is small as I'd rather
> > not rewrite the series just for this. Thanks.
> 
> Ahh, OK.
> So, how about this ? it is including both opinion :)
> I'm not sure which one should be applied, but both can solve my issue.
> 

No worries. I applied your original patch.


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

* Re: Question about devm_get_clk_from_child()
  2019-03-07 19:18       ` Stephen Boyd
@ 2019-03-08  0:23         ` Kuninori Morimoto
  0 siblings, 0 replies; 4+ messages in thread
From: Kuninori Morimoto @ 2019-03-08  0:23 UTC (permalink / raw)
  To: Stephen Boyd; +Cc: Linux-ALSA, linux-clk


Hi Stephen

> > > Yes this is correct. Thanks for debugging and fixing my thinko here. I
> > > was thinking that nobody would call of_clk_get_by_name() unless they
> > > wanted to find some clk that had a matching name, but it seems that we
> > > also allow NULL to be passed as the name to mean the typical "wildcard
> > > match" thing that clkdev has done for years. I'll throw this patch on
> > > top of the merge commit so the breakage window is small as I'd rather
> > > not rewrite the series just for this. Thanks.
> > 
> > Ahh, OK.
> > So, how about this ? it is including both opinion :)
> > I'm not sure which one should be applied, but both can solve my issue.
> > 
> 
> No worries. I applied your original patch.

OK. Thanks a lot !!

Best regards
---
Kuninori Morimoto

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

end of thread, other threads:[~2019-03-08  0:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <877edcczwl.wl-kuninori.morimoto.gx@renesas.com>
     [not found] ` <87wolcbhy4.wl-kuninori.morimoto.gx@renesas.com>
2019-03-06 17:20   ` Question about devm_get_clk_from_child() Stephen Boyd
2019-03-07  0:20     ` Kuninori Morimoto
2019-03-07 19:18       ` Stephen Boyd
2019-03-08  0:23         ` Kuninori Morimoto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).