From: Stephen Boyd <sboyd@codeaurora.org>
To: "A.s. Dong" <aisheng.dong@nxp.com>
Cc: Shawn Guo <shawnguo@kernel.org>,
Michael Turquette <mturquette@baylibre.com>,
"linux-clk@vger.kernel.org" <linux-clk@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
Shawn Guo <shawn.guo@linaro.org>
Subject: Re: [PATCH] clk: bulk: call of_clk_get() when id is NULL
Date: Wed, 30 Aug 2017 22:26:30 -0700 [thread overview]
Message-ID: <20170831052630.GU21656@codeaurora.org> (raw)
In-Reply-To: <AM3PR04MB3064504A935B4AA0CBEE962809C0@AM3PR04MB306.eurprd04.prod.outlook.com>
On 08/30, A.s. Dong wrote:
> > -----Original Message-----
> > From: Shawn Guo [mailto:shawnguo@kernel.org]
> > Sent: Sunday, August 13, 2017 10:19 PM
> > To: Stephen Boyd
> > Cc: Michael Turquette; A.s. Dong; linux-clk@vger.kernel.org; linux-arm-
> > kernel@lists.infradead.org; Shawn Guo
> > Subject: Re: [PATCH] clk: bulk: call of_clk_get() when id is NULL
> >
> > Hi Stephen,
> >
> > On Wed, Aug 09, 2017 at 10:33:18AM -0700, Stephen Boyd wrote:
> > > > diff --git a/drivers/clk/clk-bulk.c b/drivers/clk/clk-bulk.c index
> > > > c834f5abfc49..65cee595a67e 100644
> > > > --- a/drivers/clk/clk-bulk.c
> > > > +++ b/drivers/clk/clk-bulk.c
> > > > @@ -39,7 +39,10 @@ int __must_check clk_bulk_get(struct device *dev,
> > int num_clks,
> > > > clks[i].clk = NULL;
> > > >
> > > > for (i = 0; i < num_clks; i++) {
> > > > - clks[i].clk = clk_get(dev, clks[i].id);
> > > > + if (clks[i].id)
> > > > + clks[i].clk = clk_get(dev, clks[i].id);
> > > > + else if (dev->of_node)
> > > > + clks[i].clk = of_clk_get(dev->of_node, i);
> > >
> > > This seems a little too magical. The omission of an id in an array of
> > > clks would mean that only that one clk is acquired through
> > > of_clk_get(). We could have a mixture of ids and no ids for some
> > > device, and then do very odd things.
> > >
> > > How about we add a flag to clk_bulk_data that indicates we want it to
> > > use of_clk_get() instead of clk_get() for all of the clks?
> > > Then the id is ignored for the entire function.
> >
> > I have sent v2 to add a flag to clk_bulk_data to address your comments.
> > But I just found it might not be what you want exactly, because the
> > current bulk clk APIs defines clk_bulk_data in a different way from what
> > you are asking here.
> >
> > It seems that you think clk_bulk_data represents all the clocks that bulk
> > APIs manage, but actually it only represents one of the multiple clocks.
> > Callers need to prepare an array of clk_bulk_data to represent multiple
> > clocks. That said, the flag we add to clk_bulk_data only affects one
> > clock instead of all clocks.
> >
> > I feel this is something we can improve. clk_bulk_data can be used to
> > represent all clocks, something like below. In this case, bulk clk APIs
> > do not need to take num_clks as a separate parameter, and callers do not
> > need to maintain multiple clk_bulk_data instances. Since we do not have
> > any in tree users of bulk clk APIs yet, we can make this semantic change
> > quickly. Thoughts?
> >
>
> Flags may be better used for extending per clk feature support in the future.
>
> IMHO how about implement a of_clk_bulk_get() to handle this issue as we already
> have a of_clk_get?
> e.g.
>
> int __must_check of_clk_bulk_get(struct device_node *np, int num_clks,
> struct clk_bulk_data *clks)
> {
> for (i = 0; i < num_clks; i++) {
> clks[i].clk = of_clk_get(dev, clks[i].id);
> ...
>
> }
>
> Then it's less intrusive.
>
This looks ok too. Go ahead and send this version instead.
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
WARNING: multiple messages have this Message-ID (diff)
From: sboyd@codeaurora.org (Stephen Boyd)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] clk: bulk: call of_clk_get() when id is NULL
Date: Wed, 30 Aug 2017 22:26:30 -0700 [thread overview]
Message-ID: <20170831052630.GU21656@codeaurora.org> (raw)
In-Reply-To: <AM3PR04MB3064504A935B4AA0CBEE962809C0@AM3PR04MB306.eurprd04.prod.outlook.com>
On 08/30, A.s. Dong wrote:
> > -----Original Message-----
> > From: Shawn Guo [mailto:shawnguo at kernel.org]
> > Sent: Sunday, August 13, 2017 10:19 PM
> > To: Stephen Boyd
> > Cc: Michael Turquette; A.s. Dong; linux-clk at vger.kernel.org; linux-arm-
> > kernel at lists.infradead.org; Shawn Guo
> > Subject: Re: [PATCH] clk: bulk: call of_clk_get() when id is NULL
> >
> > Hi Stephen,
> >
> > On Wed, Aug 09, 2017 at 10:33:18AM -0700, Stephen Boyd wrote:
> > > > diff --git a/drivers/clk/clk-bulk.c b/drivers/clk/clk-bulk.c index
> > > > c834f5abfc49..65cee595a67e 100644
> > > > --- a/drivers/clk/clk-bulk.c
> > > > +++ b/drivers/clk/clk-bulk.c
> > > > @@ -39,7 +39,10 @@ int __must_check clk_bulk_get(struct device *dev,
> > int num_clks,
> > > > clks[i].clk = NULL;
> > > >
> > > > for (i = 0; i < num_clks; i++) {
> > > > - clks[i].clk = clk_get(dev, clks[i].id);
> > > > + if (clks[i].id)
> > > > + clks[i].clk = clk_get(dev, clks[i].id);
> > > > + else if (dev->of_node)
> > > > + clks[i].clk = of_clk_get(dev->of_node, i);
> > >
> > > This seems a little too magical. The omission of an id in an array of
> > > clks would mean that only that one clk is acquired through
> > > of_clk_get(). We could have a mixture of ids and no ids for some
> > > device, and then do very odd things.
> > >
> > > How about we add a flag to clk_bulk_data that indicates we want it to
> > > use of_clk_get() instead of clk_get() for all of the clks?
> > > Then the id is ignored for the entire function.
> >
> > I have sent v2 to add a flag to clk_bulk_data to address your comments.
> > But I just found it might not be what you want exactly, because the
> > current bulk clk APIs defines clk_bulk_data in a different way from what
> > you are asking here.
> >
> > It seems that you think clk_bulk_data represents all the clocks that bulk
> > APIs manage, but actually it only represents one of the multiple clocks.
> > Callers need to prepare an array of clk_bulk_data to represent multiple
> > clocks. That said, the flag we add to clk_bulk_data only affects one
> > clock instead of all clocks.
> >
> > I feel this is something we can improve. clk_bulk_data can be used to
> > represent all clocks, something like below. In this case, bulk clk APIs
> > do not need to take num_clks as a separate parameter, and callers do not
> > need to maintain multiple clk_bulk_data instances. Since we do not have
> > any in tree users of bulk clk APIs yet, we can make this semantic change
> > quickly. Thoughts?
> >
>
> Flags may be better used for extending per clk feature support in the future.
>
> IMHO how about implement a of_clk_bulk_get() to handle this issue as we already
> have a of_clk_get?
> e.g.
>
> int __must_check of_clk_bulk_get(struct device_node *np, int num_clks,
> struct clk_bulk_data *clks)
> {
> for (i = 0; i < num_clks; i++) {
> clks[i].clk = of_clk_get(dev, clks[i].id);
> ...
>
> }
>
> Then it's less intrusive.
>
This looks ok too. Go ahead and send this version instead.
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
next prev parent reply other threads:[~2017-08-31 5:26 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-09 1:50 [PATCH] clk: bulk: call of_clk_get() when id is NULL Shawn Guo
2017-08-09 1:50 ` Shawn Guo
2017-08-09 17:33 ` Stephen Boyd
2017-08-09 17:33 ` Stephen Boyd
2017-08-10 1:31 ` Shawn Guo
2017-08-10 1:31 ` Shawn Guo
2017-08-13 14:18 ` Shawn Guo
2017-08-13 14:18 ` Shawn Guo
2017-08-30 15:31 ` A.s. Dong
2017-08-30 15:31 ` A.s. Dong
2017-08-31 5:26 ` Stephen Boyd [this message]
2017-08-31 5:26 ` Stephen Boyd
2017-09-11 4:51 ` A.s. Dong
2017-09-11 4:51 ` A.s. Dong
2017-09-11 5:57 ` Shawn Guo
2017-09-11 5:57 ` Shawn Guo
2017-08-31 7:01 ` Shawn Guo
2017-08-31 7:01 ` Shawn Guo
2017-08-31 7:12 ` A.s. Dong
2017-08-31 7:12 ` A.s. Dong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170831052630.GU21656@codeaurora.org \
--to=sboyd@codeaurora.org \
--cc=aisheng.dong@nxp.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=shawn.guo@linaro.org \
--cc=shawnguo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.