[U-Boot] [PATCH 01/14] powerpc, 8xx: Simplify brgclk calculation and remove get_brgclk()

Christophe LEROY christophe.leroy at c-s.fr
Thu Jul 13 13:12:18 UTC 2017



Le 12/07/2017 à 14:52, Wolfgang Denk a écrit :
> Dear Christophe,
> 
> In message <59ac182501e89d3b9ee1dc7c31ce358ff33c0877.1499629706.git.christophe.leroy at c-s.fr> you wrote:
>> divider is calculated based on SCCR_DFBRG, with:
>> SCCR_DFBRG 00 => divider 1  = 1 << 0
>> SCCR_DFBRG 01 => divider 4  = 1 << 2
>> SCCR_DFBRG 10 => divider 16 = 1 << 4
>> SCCR_DFBRG 11 => divider 64 = 1 << 6
>>
>> This can be easily converted to a single shift operation:
>> divider = 1 << (SCCR_DFBRG * 2)
> 
> Agreed, but...
> 
>> -	switch ((sccr & SCCR_DFBRG11) >> 11) {
> ...
>> +	uint divider = 1 << ((sccr & SCCR_DFBRG11) >> 10);
> 
> The code would be easier to read / understand if you made the
> calculation obvious, i. e.
> 
> 	uint divider = 1 << (((sccr & SCCR_DFBRG11) >> 11) * 2);
> 
> The compiler generates the same code, so there is no size effect.

Ok, done in v2

Christophe
> 
> Reviewed-by: Wolfgang Denk <wd at denx.de>
> 
> 
> Best regards,
> 
> Wolfgang Denk
> 


More information about the U-Boot mailing list