From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jerry Van Baren Date: Tue, 21 Oct 2008 13:07:11 -0400 Subject: [U-Boot] [PATCH] improved strmhz() In-Reply-To: <0E4961A3-232C-4307-91E3-B2F7CB216BFA@kernel.crashing.org> References: <48FDCEB6.9040206@ronetix.at> <20081021135519.D8053835694E@gemini.denx.de> <0E4961A3-232C-4307-91E3-B2F7CB216BFA@kernel.crashing.org> Message-ID: <48FE0C3F.2080206@ge.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 >> Date: Tue, 21 Oct 2008 15:53:51 +0200 >> Subject: [PATCH] Fix strmhz(): avoid printing negative fractions >> >> Signed-off-by: Wolfgang Denk >> --- >> 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