blob: f9a17727f53b898e307a7b65853c00623f135909 [file] [log] [blame]
Haavard Skinnemoenb644d6b2008-08-18 13:41:27 +02001/*
2 * (C) Copyright 2002-2006
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Haavard Skinnemoenb644d6b2008-08-18 13:41:27 +02006 */
7#include <common.h>
8
Ed Swarthoutd065acb2011-03-05 10:28:17 -06009char *strmhz (char *buf, unsigned long hz)
Haavard Skinnemoenb644d6b2008-08-18 13:41:27 +020010{
11 long l, n;
12 long m;
13
Wolfgang Denkfc8bc872008-10-21 15:53:51 +020014 n = DIV_ROUND(hz, 1000) / 1000L;
Haavard Skinnemoenb644d6b2008-08-18 13:41:27 +020015 l = sprintf (buf, "%ld", n);
Wolfgang Denk709e85d2008-10-19 02:35:48 +020016
17 hz -= n * 1000000L;
18 m = DIV_ROUND(hz, 1000L);
Haavard Skinnemoenb644d6b2008-08-18 13:41:27 +020019 if (m != 0)
20 sprintf (buf + l, ".%03ld", m);
21 return (buf);
22}