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>
This commit is contained in:
Wolfgang Denk
2008-10-19 02:35:48 +02:00
parent 681c02d05b
commit d50c7d4be1
2 changed files with 7 additions and 4 deletions

View File

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