2008-08-18 11:41:27 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2002-2006
|
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2008-08-18 11:41:27 +00:00
|
|
|
*/
|
|
|
|
#include <common.h>
|
|
|
|
|
2011-03-05 16:28:17 +00:00
|
|
|
char *strmhz (char *buf, unsigned long hz)
|
2008-08-18 11:41:27 +00:00
|
|
|
{
|
|
|
|
long l, n;
|
|
|
|
long m;
|
|
|
|
|
2014-11-06 18:03:26 +00:00
|
|
|
n = DIV_ROUND_CLOSEST(hz, 1000) / 1000L;
|
2008-08-18 11:41:27 +00:00
|
|
|
l = sprintf (buf, "%ld", n);
|
2008-10-19 00:35:48 +00:00
|
|
|
|
|
|
|
hz -= n * 1000000L;
|
2014-11-06 18:03:26 +00:00
|
|
|
m = DIV_ROUND_CLOSEST(hz, 1000L);
|
2008-08-18 11:41:27 +00:00
|
|
|
if (m != 0)
|
|
|
|
sprintf (buf + l, ".%03ld", m);
|
|
|
|
return (buf);
|
|
|
|
}
|