Blame view

lib/strmhz.c 409 Bytes
83d290c56   Tom Rini   SPDX: Convert all...
1
  // SPDX-License-Identifier: GPL-2.0+
0768b7a87   Haavard Skinnemoen   Consolidate strmh...
2
3
4
  /*
   * (C) Copyright 2002-2006
   * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
0768b7a87   Haavard Skinnemoen   Consolidate strmh...
5
6
   */
  #include <common.h>
55f7934d2   Ed Swarthout   strmhz: Make hz u...
7
  char *strmhz (char *buf, unsigned long hz)
0768b7a87   Haavard Skinnemoen   Consolidate strmh...
8
9
10
  {
  	long l, n;
  	long m;
4515992fc   Masahiro Yamada   replace DIV_ROUND...
11
  	n = DIV_ROUND_CLOSEST(hz, 1000) / 1000L;
0768b7a87   Haavard Skinnemoen   Consolidate strmh...
12
  	l = sprintf (buf, "%ld", n);
d50c7d4be   Wolfgang Denk   strmhz(): Round n...
13
14
  
  	hz -= n * 1000000L;
4515992fc   Masahiro Yamada   replace DIV_ROUND...
15
  	m = DIV_ROUND_CLOSEST(hz, 1000L);
0768b7a87   Haavard Skinnemoen   Consolidate strmh...
16
17
18
19
  	if (m != 0)
  		sprintf (buf + l, ".%03ld", m);
  	return (buf);
  }