All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jerry Van Baren <gerald.vanbaren@ge.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] improved strmhz()
Date: Tue, 21 Oct 2008 13:07:11 -0400	[thread overview]
Message-ID: <48FE0C3F.2080206@ge.com> (raw)
In-Reply-To: <0E4961A3-232C-4307-91E3-B2F7CB216BFA@kernel.crashing.org>

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@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@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

  reply	other threads:[~2008-10-21 17:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-21 12:44 [U-Boot] [PATCH] improved strmhz() Ilko Iliev
2008-10-21 13:55 ` Wolfgang Denk
2008-10-21 14:11   ` Ilko Iliev
2008-10-21 16:54   ` Kumar Gala
2008-10-21 17:07     ` Jerry Van Baren [this message]
2008-10-21 17:38     ` Mike Frysinger
2008-10-21 19:15     ` Wolfgang Denk
2008-10-22  7:03       ` Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48FE0C3F.2080206@ge.com \
    --to=gerald.vanbaren@ge.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.