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