summaryrefslogtreecommitdiff
path: root/lib_generic
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2008-10-19 00:35:48 (GMT)
committerWolfgang Denk <wd@denx.de>2008-10-21 09:25:35 (GMT)
commitd50c7d4be150b2252c0d2e16cfcf69643bdd6dc9 (patch)
treef5ee3bd016b0e306564262925b471b8ba5825544 /lib_generic
parent681c02d05b29c6d46093525052c74b9c4ddc8b08 (diff)
downloadu-boot-fsl-qoriq-d50c7d4be150b2252c0d2e16cfcf69643bdd6dc9.tar.xz
strmhz(): Round numbers when printing clock frequencies
Round clock frequencies for printing. Many boards printed off clock frequencies like 399 MHz instead of the exact 400 MHz because numberes were not rounded. This is fixed now. Signed-off-by: Wolfgang Denk <wd@denx.de>
Diffstat (limited to 'lib_generic')
-rw-r--r--lib_generic/strmhz.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib_generic/strmhz.c b/lib_generic/strmhz.c
index d0b6bc6..342cf2b 100644
--- a/lib_generic/strmhz.c
+++ b/lib_generic/strmhz.c
@@ -27,9 +27,11 @@ char *strmhz (char *buf, long hz)
long l, n;
long m;
- n = hz / 1000000L;
+ n = DIV_ROUND(hz, 1000000L);
l = sprintf (buf, "%ld", n);
- m = (hz % 1000000L) / 1000L;
+
+ hz -= n * 1000000L;
+ m = DIV_ROUND(hz, 1000L);
if (m != 0)
sprintf (buf + l, ".%03ld", m);
return (buf);