blob: 66afe91ab99d72ca0cf81a4a69c6b75f8f1cfef9 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Haavard Skinnemoenb644d6b2008-08-18 13:41:27 +02002/*
3 * (C) Copyright 2002-2006
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
Haavard Skinnemoenb644d6b2008-08-18 13:41:27 +02005 */
6#include <common.h>
7
Ed Swarthoutd065acb2011-03-05 10:28:17 -06008char *strmhz (char *buf, unsigned long hz)
Haavard Skinnemoenb644d6b2008-08-18 13:41:27 +02009{
10 long l, n;
11 long m;
12
Masahiro Yamadaeff8e682014-11-07 03:03:26 +090013 n = DIV_ROUND_CLOSEST(hz, 1000) / 1000L;
Haavard Skinnemoenb644d6b2008-08-18 13:41:27 +020014 l = sprintf (buf, "%ld", n);
Wolfgang Denk709e85d2008-10-19 02:35:48 +020015
16 hz -= n * 1000000L;
Masahiro Yamadaeff8e682014-11-07 03:03:26 +090017 m = DIV_ROUND_CLOSEST(hz, 1000L);
Haavard Skinnemoenb644d6b2008-08-18 13:41:27 +020018 if (m != 0)
19 sprintf (buf + l, ".%03ld", m);
20 return (buf);
21}