lkml.org 
[lkml]   [2015]   [Nov]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 2/3] clk: let of_clk_get_parent_name() fail for invalid clock-indices
From
Hi Stephen,



>>
>> Of course we can, although we have to mention "clock-indices" twice.
>>
>> A good thing for of_get_property() is that we can get both the value
>> and the length
>> at the same time.
>>
>
> Ok. Well if we don't want to count them again, perhaps a goto
> jump over an unconditional return NULL would be better?
>
> of_property_for_each_u32(clkspec.np, "clock-indices", prop, vp, pv) {
> if (index == pv) {
> index = count;
> goto found;
> }
> count++;
> }
>
> return NULL;
> found:
>
> Or since the macro for of_property_for_each_u32() tests the vp
> poitner for NULL, we can check that pointer too...
>
> of_property_for_each_u32(clkspec.np, "clock-indices", prop, vp, pv) {
> if (index == pv) {
> index = count;
> break;
> }
> count++;
> }
>
> /* We didn't find anything */
> if (!vp)
> return NULL;
>
> I guess I prefer the latter approach here.
>

No.

Neither of your two suggestions works because they are false positive.

With your way, if "clock-indices" does not exist, of_clk_get_parent_name()
would return NULL; in this case it should just parse "clock-output-names",
assuming that the clock names are simply indexed from zero.


--
Best Regards
Masahiro Yamada


\
 
 \ /
  Last update: 2015-11-30 10:01    [W:0.078 / U:0.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site