From 2189d5f1e8a2fd74ce52906999fd50c8f8330c81 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 14 Nov 2019 12:57:20 -0700 Subject: Move strtomhz() to vsprintf.h At present this function sits in its own file but it does not really justify it. There are similar string functions in vsprintf.h, so move it there. Also add the missing function comment. Use the vsprintf.h include file explicitly where needed. Signed-off-by: Simon Glass Reviewed-by: Tom Rini --- lib/Makefile | 4 ++-- lib/strmhz.c | 21 --------------------- lib/vsprintf.c | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 23 deletions(-) delete mode 100644 lib/strmhz.c (limited to 'lib') diff --git a/lib/Makefile b/lib/Makefile index d248d8626c..e15a189f65 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -109,12 +109,12 @@ ifeq ($(CONFIG_$(SPL_TPL_)BUILD),y) ifdef CONFIG_$(SPL_TPL_)USE_TINY_PRINTF obj-$(CONFIG_$(SPL_TPL_)SPRINTF) += tiny-printf.o else -obj-$(CONFIG_$(SPL_TPL_)SPRINTF) += vsprintf.o strmhz.o +obj-$(CONFIG_$(SPL_TPL_)SPRINTF) += vsprintf.o endif obj-$(CONFIG_$(SPL_TPL_)STRTO) += strto.o else # Main U-Boot always uses the full printf support -obj-y += vsprintf.o strto.o strmhz.o +obj-y += vsprintf.o strto.o endif subdir-ccflags-$(CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED) += -O2 diff --git a/lib/strmhz.c b/lib/strmhz.c deleted file mode 100644 index 66afe91ab9..0000000000 --- a/lib/strmhz.c +++ /dev/null @@ -1,21 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * (C) Copyright 2002-2006 - * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - */ -#include - -char *strmhz (char *buf, unsigned long hz) -{ - long l, n; - long m; - - n = DIV_ROUND_CLOSEST(hz, 1000) / 1000L; - l = sprintf (buf, "%ld", n); - - hz -= n * 1000000L; - m = DIV_ROUND_CLOSEST(hz, 1000L); - if (m != 0) - sprintf (buf + l, ".%03ld", m); - return (buf); -} diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 425f2f53f7..c6467ecd5f 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -2,6 +2,8 @@ * linux/lib/vsprintf.c * * Copyright (C) 1991, 1992 Linus Torvalds + * (C) Copyright 2000-2009 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. */ /* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */ @@ -17,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -873,3 +876,19 @@ bool str2long(const char *p, ulong *num) *num = simple_strtoul(p, &endptr, 16); return *p != '\0' && *endptr == '\0'; } + +char *strmhz(char *buf, unsigned long hz) +{ + long l, n; + long m; + + n = DIV_ROUND_CLOSEST(hz, 1000) / 1000L; + l = sprintf(buf, "%ld", n); + + hz -= n * 1000000L; + m = DIV_ROUND_CLOSEST(hz, 1000L); + if (m != 0) + sprintf(buf + l, ".%03ld", m); + + return buf; +} -- cgit v1.2.1