[U-Boot] [PATCH v7 01/12] clk: Use dummy clk_get_by_* functions when CONFIG_CLK is disabled

Stephen Warren swarren at wwwdotorg.org
Mon Sep 12 18:44:51 CEST 2016


On 09/11/2016 07:25 AM, Masahiro Yamada wrote:
> Hi Paul,
>
> 2016-09-09 17:01 GMT+09:00 Paul Burton <paul.burton at imgtec.com>:
>> On 09/09/16 04:15, Masahiro Yamada wrote:
>>> 2016-09-08 15:47 GMT+09:00 Paul Burton <paul.burton at imgtec.com>:
>>>> The implementations of clk_get_by_index & clk_get_by_name are only
>>>> available when CONFIG_CLK is enabled.
>>>
>>> Unless I am missing something,
>>> I think this statement also applies to other clk API functions
>>> such as clk_request(), clk_free(), clk_get_rate(), etc.
>>
>> Hi Masahiro,
>>
>> Yes, I agree. To be clear though, this patch doesn't add any new stub
>> functions it simply makes the conditions for the existing ones being
>> provided match the conditions for the real implementations not being
>> provided.
>>
>>>> Provide the dummies when this is
>>>> not the case in order to avoid build failures.
>>>
>>> Why are other functions OK without dummy stubs?
>>
>> In general, I presume because they aren't used.
>>
>> In the specific case I'm using clk_get_by_index for
>> (drivers/serial/ns16550.c in patch 2 of this series) the fact that the
>> dummy clk_get_by_index always returns an error will cause the compiler
>> to optimise out a call to clk_get_rate so any dummy implementation
>> provided for it wouldn't really get used.
>
> I see, but I do not think it is a good idea
> to rely on the optimization by compiler in this case.

FWIW, I'm pretty sure that the Linux kernel relies on exactly the same 
technique with success.


More information about the U-Boot mailing list