]> git.ipfire.org Git - thirdparty/u-boot.git/blame - lib/strmhz.c
Merge tag 'video-for-2019.07-rc1' of git://git.denx.de/u-boot-video
[thirdparty/u-boot.git] / lib / strmhz.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
0768b7a8
HS
2/*
3 * (C) Copyright 2002-2006
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
0768b7a8
HS
5 */
6#include <common.h>
7
55f7934d 8char *strmhz (char *buf, unsigned long hz)
0768b7a8
HS
9{
10 long l, n;
11 long m;
12
4515992f 13 n = DIV_ROUND_CLOSEST(hz, 1000) / 1000L;
0768b7a8 14 l = sprintf (buf, "%ld", n);
d50c7d4b
WD
15
16 hz -= n * 1000000L;
4515992f 17 m = DIV_ROUND_CLOSEST(hz, 1000L);
0768b7a8
HS
18 if (m != 0)
19 sprintf (buf + l, ".%03ld", m);
20 return (buf);
21}