[U-Boot] [PATCH] improved strmhz()

Jerry Van Baren gerald.vanbaren at ge.com
Tue Oct 21 19:07:11 CEST 2008


Kumar Gala wrote:
>> That looks overly complex to me. Can you please check if this patch
>> fixes the problem for your test cases, too:
>>
>>> From 963e7db81379225b78bfac0d7457300c86d6b4d6 Mon Sep 17 00:00:00  
>>> 2001
>> From: Wolfgang Denk <wd at denx.de>
>> Date: Tue, 21 Oct 2008 15:53:51 +0200
>> Subject: [PATCH] Fix strmhz(): avoid printing negative fractions
>>
>> Signed-off-by: Wolfgang Denk <wd at denx.de>
>> ---
>> lib_generic/strmhz.c |    2 +-
>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/lib_generic/strmhz.c b/lib_generic/strmhz.c
>> index 342cf2b..d6da1d1 100644
>> --- a/lib_generic/strmhz.c
>> +++ b/lib_generic/strmhz.c
>> @@ -27,7 +27,7 @@ char *strmhz (char *buf, long hz)
>> 	long l, n;
>> 	long m;
>>
>> -	n = DIV_ROUND(hz, 1000000L);
>> +	n = DIV_ROUND(hz, 1000) / 1000L;
>> 	l = sprintf (buf, "%ld", n);
>>
>> 	hz -= n * 1000000L;
>> -- 
>> 1.5.5.1
> 
> I haven't been following this thread, but can we control the number of  
> significant digits.  I'm starting to see output like:
> 
> Clock Configuration:
>         CPU:1500.4294967282 MHz, CCB:600.4294967291 MHz,
>         DDR:400.4294967293 MHz (800.4294967289 MT/s data rate)  

(unsigned) 4294967289 = (signed) -7 (if I did my math right).  This is 
indicating Wolfgang's patch still does negative remainders, but masks 
that by printing them as unsigned numbers.

Best regards,
gvb


More information about the U-Boot mailing list