* of_clk_get() / devm_clk_get()
@ 2013-02-14 4:17 Tony Prisk
2013-02-14 4:40 ` Stephen Warren
0 siblings, 1 reply; 4+ messages in thread
From: Tony Prisk @ 2013-02-14 4:17 UTC (permalink / raw)
To: linux-arm-kernel
Currently we have devm_clk_get() which gives a managed-resource clk (by
name), or of_clk_get() which gives an unmanaged resource clk (by id).
I just wanted to sound out everyone as to whether there is a need for a
managed version of the of_clk_get.
My personal concern about devm_clk_get is that it requires (if I
understand correctly) that the DT node have the clock-names property
(which is optional). If the optional name is not supplied, it fails.
This basically makes it 'not optional' when a driver uses devm_clk_get.
(Please correct me if I'm wrong about this).
Everything below here is irrelevant if the above is wrong :)
If the above IS correct, then couldn't we have a devm_of_clk_get which
accepts a *id (as per devm_clk_get) AND an index (as per of_clk_get),
with the *id given priority.
Something along the lines of...
struct clk *devm_of_clk_get(struct device *dev,
const char *id,
int index)
{
struct clk **ptr, *clk = NULL;
if (id)
clk = devm_clk_get(dev, id);
if (!clk || IS_ERR(clk)) {
clk = of_clk_get(dev->of_node, index);
if (!IS_ERR(clk)) {
ptr = devres_alloc(devm_clk_release,
sizeof(*ptr),
GFP_KERNEL)
if (!ptr)
return ERR_PTR(-ENOMEM);
*ptr = clk;
devres_add(dev, ptr);
}
}
return clk;
}
This would make clock-names optional (as intended) and give a fallback
to the index when clock-names isn't specified.
One issue (which I don't know how much of an issue it is) is that this
doesn't follow the normal pattern of normal_func -> devm_func parameter
layout.
Regards
Tony Prisk
^ permalink raw reply [flat|nested] 4+ messages in thread
* of_clk_get() / devm_clk_get()
2013-02-14 4:17 of_clk_get() / devm_clk_get() Tony Prisk
@ 2013-02-14 4:40 ` Stephen Warren
2013-02-14 6:42 ` Tony Prisk
0 siblings, 1 reply; 4+ messages in thread
From: Stephen Warren @ 2013-02-14 4:40 UTC (permalink / raw)
To: linux-arm-kernel
On 02/13/2013 09:17 PM, Tony Prisk wrote:
> Currently we have devm_clk_get() which gives a managed-resource clk (by
> name), or of_clk_get() which gives an unmanaged resource clk (by id).
>
> I just wanted to sound out everyone as to whether there is a need for a
> managed version of the of_clk_get.
>
> My personal concern about devm_clk_get is that it requires (if I
> understand correctly) that the DT node have the clock-names property
> (which is optional). If the optional name is not supplied, it fails.
> This basically makes it 'not optional' when a driver uses devm_clk_get.
> (Please correct me if I'm wrong about this).
I thought supplying NULL for the name/ID simply gave you the first clock
in the list (clocks property)? I'm sure I've seen plenty of Tegra
drivers that end up doing that.
^ permalink raw reply [flat|nested] 4+ messages in thread
* of_clk_get() / devm_clk_get()
2013-02-14 4:40 ` Stephen Warren
@ 2013-02-14 6:42 ` Tony Prisk
2013-02-14 17:28 ` Stephen Warren
0 siblings, 1 reply; 4+ messages in thread
From: Tony Prisk @ 2013-02-14 6:42 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, 2013-02-13 at 21:40 -0700, Stephen Warren wrote:
> On 02/13/2013 09:17 PM, Tony Prisk wrote:
> > Currently we have devm_clk_get() which gives a managed-resource clk (by
> > name), or of_clk_get() which gives an unmanaged resource clk (by id).
> >
> > I just wanted to sound out everyone as to whether there is a need for a
> > managed version of the of_clk_get.
> >
> > My personal concern about devm_clk_get is that it requires (if I
> > understand correctly) that the DT node have the clock-names property
> > (which is optional). If the optional name is not supplied, it fails.
> > This basically makes it 'not optional' when a driver uses devm_clk_get.
> > (Please correct me if I'm wrong about this).
>
> I thought supplying NULL for the name/ID simply gave you the first clock
> in the list (clocks property)? I'm sure I've seen plenty of Tegra
> drivers that end up doing that.
>
I think someone else told me that once before so it is probably correct
- but it doesn't solve the problem of requesting a second clock without
a clock-names property.
That leaves us in the situation of only being able to use managed clocks
when there is only one, or forcing dts files to include the 'optional'
property.
Regards
Tony Prisk
^ permalink raw reply [flat|nested] 4+ messages in thread
* of_clk_get() / devm_clk_get()
2013-02-14 6:42 ` Tony Prisk
@ 2013-02-14 17:28 ` Stephen Warren
0 siblings, 0 replies; 4+ messages in thread
From: Stephen Warren @ 2013-02-14 17:28 UTC (permalink / raw)
To: linux-arm-kernel
On 02/13/2013 11:42 PM, Tony Prisk wrote:
> On Wed, 2013-02-13 at 21:40 -0700, Stephen Warren wrote:
>> On 02/13/2013 09:17 PM, Tony Prisk wrote:
>>> Currently we have devm_clk_get() which gives a managed-resource clk (by
>>> name), or of_clk_get() which gives an unmanaged resource clk (by id).
>>>
>>> I just wanted to sound out everyone as to whether there is a need for a
>>> managed version of the of_clk_get.
>>>
>>> My personal concern about devm_clk_get is that it requires (if I
>>> understand correctly) that the DT node have the clock-names property
>>> (which is optional). If the optional name is not supplied, it fails.
>>> This basically makes it 'not optional' when a driver uses devm_clk_get.
>>> (Please correct me if I'm wrong about this).
>>
>> I thought supplying NULL for the name/ID simply gave you the first clock
>> in the list (clocks property)? I'm sure I've seen plenty of Tegra
>> drivers that end up doing that.
>>
>
> I think someone else told me that once before so it is probably correct
> - but it doesn't solve the problem of requesting a second clock without
> a clock-names property.
>
> That leaves us in the situation of only being able to use managed clocks
> when there is only one, or forcing dts files to include the 'optional'
> property.
True. Writing a devm_ wrapper around of_clk_get() should be pretty
trivial though.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-02-14 17:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-14 4:17 of_clk_get() / devm_clk_get() Tony Prisk
2013-02-14 4:40 ` Stephen Warren
2013-02-14 6:42 ` Tony Prisk
2013-02-14 17:28 ` Stephen Warren
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).