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