From 2189d5f1e8a2fd74ce52906999fd50c8f8330c81 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 14 Nov 2019 12:57:20 -0700 Subject: [PATCH] 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 --- arch/arc/lib/cpu.c | 1 + arch/arm/cpu/arm926ejs/mx25/generic.c | 1 + arch/arm/cpu/arm926ejs/mx27/generic.c | 1 + arch/arm/cpu/armv7/ls102xa/cpu.c | 1 + arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 1 + arch/arm/mach-at91/arm926ejs/cpu.c | 1 + arch/arm/mach-at91/armv7/cpu.c | 1 + arch/m68k/cpu/mcf5227x/cpu.c | 1 + arch/m68k/cpu/mcf523x/cpu.c | 1 + arch/m68k/cpu/mcf52x2/cpu.c | 1 + arch/m68k/cpu/mcf530x/cpu.c | 1 + arch/m68k/cpu/mcf532x/cpu.c | 1 + arch/m68k/cpu/mcf5445x/cpu.c | 1 + arch/m68k/cpu/mcf547x_8x/cpu.c | 1 + arch/powerpc/cpu/mpc83xx/cpu.c | 1 + arch/powerpc/cpu/mpc83xx/spd_sdram.c | 1 + arch/powerpc/cpu/mpc83xx/speed.c | 1 + arch/powerpc/cpu/mpc85xx/cpu.c | 1 + arch/powerpc/cpu/mpc86xx/cpu.c | 1 + arch/powerpc/cpu/mpc8xx/cpu.c | 1 + arch/xtensa/cpu/cpu.c | 1 + board/Arcturus/ucp1020/ddr.c | 1 + board/atmel/at91sam9261ek/at91sam9261ek.c | 1 + board/atmel/at91sam9263ek/at91sam9263ek.c | 1 + .../atmel/at91sam9m10g45ek/at91sam9m10g45ek.c | 1 + board/atmel/at91sam9n12ek/at91sam9n12ek.c | 1 + board/atmel/at91sam9rlek/at91sam9rlek.c | 1 + board/atmel/common/video_display.c | 1 + board/esd/meesc/meesc.c | 1 + board/freescale/bsc9131rdb/ddr.c | 1 + board/freescale/bsc9132qds/ddr.c | 1 + board/freescale/corenet_ds/ddr.c | 1 + board/freescale/ls1043ardb/ddr.c | 1 + board/freescale/mpc8541cds/mpc8541cds.c | 1 + board/freescale/mpc8548cds/mpc8548cds.c | 1 + board/freescale/mpc8555cds/mpc8555cds.c | 1 + board/freescale/p1010rdb/ddr.c | 1 + board/freescale/p1_p2_rdb_pc/ddr.c | 1 + board/freescale/p1_twr/ddr.c | 1 + board/mini-box/picosam9g45/picosam9g45.c | 1 + board/ronetix/pm9261/pm9261.c | 1 + cmd/bdinfo.c | 1 + drivers/clk/clk_stm32mp1.c | 1 + drivers/clk/mpc83xx_clk.c | 1 + drivers/cpu/mpc83xx_cpu.c | 1 + include/common.h | 3 --- include/vsprintf.h | 10 +++++++++ lib/Makefile | 4 ++-- lib/strmhz.c | 21 ------------------- lib/vsprintf.c | 19 +++++++++++++++++ 50 files changed, 76 insertions(+), 26 deletions(-) delete mode 100644 lib/strmhz.c diff --git a/arch/arc/lib/cpu.c b/arch/arc/lib/cpu.c index 01cca95d5b..83246550ec 100644 --- a/arch/arc/lib/cpu.c +++ b/arch/arc/lib/cpu.c @@ -5,6 +5,7 @@ #include #include +#include #include #include diff --git a/arch/arm/cpu/arm926ejs/mx25/generic.c b/arch/arm/cpu/arm926ejs/mx25/generic.c index 5fcf06ae1a..eeb61d0d10 100644 --- a/arch/arm/cpu/arm926ejs/mx25/generic.c +++ b/arch/arm/cpu/arm926ejs/mx25/generic.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/arch/arm/cpu/arm926ejs/mx27/generic.c b/arch/arm/cpu/arm926ejs/mx27/generic.c index 08b1b4de71..9bed0e91be 100644 --- a/arch/arm/cpu/arm926ejs/mx27/generic.c +++ b/arch/arm/cpu/arm926ejs/mx27/generic.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/arch/arm/cpu/armv7/ls102xa/cpu.c b/arch/arm/cpu/armv7/ls102xa/cpu.c index 9ccfe1042c..ec9984db79 100644 --- a/arch/arm/cpu/armv7/ls102xa/cpu.c +++ b/arch/arm/cpu/armv7/ls102xa/cpu.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c index 83a3319321..59d03b167c 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/arch/arm/mach-at91/arm926ejs/cpu.c b/arch/arm/mach-at91/arm926ejs/cpu.c index 6f5aa4274b..e9b4e06595 100644 --- a/arch/arm/mach-at91/arm926ejs/cpu.c +++ b/arch/arm/mach-at91/arm926ejs/cpu.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include diff --git a/arch/arm/mach-at91/armv7/cpu.c b/arch/arm/mach-at91/armv7/cpu.c index 5da067cda1..638645c7e4 100644 --- a/arch/arm/mach-at91/armv7/cpu.c +++ b/arch/arm/mach-at91/armv7/cpu.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include diff --git a/arch/m68k/cpu/mcf5227x/cpu.c b/arch/m68k/cpu/mcf5227x/cpu.c index 7ad023dac5..34534d876b 100644 --- a/arch/m68k/cpu/mcf5227x/cpu.c +++ b/arch/m68k/cpu/mcf5227x/cpu.c @@ -9,6 +9,7 @@ */ #include +#include #include #include diff --git a/arch/m68k/cpu/mcf523x/cpu.c b/arch/m68k/cpu/mcf523x/cpu.c index 79be04f7a0..429781945b 100644 --- a/arch/m68k/cpu/mcf523x/cpu.c +++ b/arch/m68k/cpu/mcf523x/cpu.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include diff --git a/arch/m68k/cpu/mcf52x2/cpu.c b/arch/m68k/cpu/mcf52x2/cpu.c index 29a17c57fc..b48a753f9b 100644 --- a/arch/m68k/cpu/mcf52x2/cpu.c +++ b/arch/m68k/cpu/mcf52x2/cpu.c @@ -14,6 +14,7 @@ */ #include +#include #include #include #include diff --git a/arch/m68k/cpu/mcf530x/cpu.c b/arch/m68k/cpu/mcf530x/cpu.c index c7ae65afce..a76deebc68 100644 --- a/arch/m68k/cpu/mcf530x/cpu.c +++ b/arch/m68k/cpu/mcf530x/cpu.c @@ -5,6 +5,7 @@ */ #include +#include #include #include diff --git a/arch/m68k/cpu/mcf532x/cpu.c b/arch/m68k/cpu/mcf532x/cpu.c index a01b5e65a7..c8a1f20530 100644 --- a/arch/m68k/cpu/mcf532x/cpu.c +++ b/arch/m68k/cpu/mcf532x/cpu.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include diff --git a/arch/m68k/cpu/mcf5445x/cpu.c b/arch/m68k/cpu/mcf5445x/cpu.c index 56e5585e09..2f79380c8b 100644 --- a/arch/m68k/cpu/mcf5445x/cpu.c +++ b/arch/m68k/cpu/mcf5445x/cpu.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include diff --git a/arch/m68k/cpu/mcf547x_8x/cpu.c b/arch/m68k/cpu/mcf547x_8x/cpu.c index 819b25f280..dc5ed1aa79 100644 --- a/arch/m68k/cpu/mcf547x_8x/cpu.c +++ b/arch/m68k/cpu/mcf547x_8x/cpu.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include diff --git a/arch/powerpc/cpu/mpc83xx/cpu.c b/arch/powerpc/cpu/mpc83xx/cpu.c index 3048ecf34a..363c0ffd28 100644 --- a/arch/powerpc/cpu/mpc83xx/cpu.c +++ b/arch/powerpc/cpu/mpc83xx/cpu.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include diff --git a/arch/powerpc/cpu/mpc83xx/spd_sdram.c b/arch/powerpc/cpu/mpc83xx/spd_sdram.c index 8b5ecdb9ad..08918a9d75 100644 --- a/arch/powerpc/cpu/mpc83xx/spd_sdram.c +++ b/arch/powerpc/cpu/mpc83xx/spd_sdram.c @@ -13,6 +13,7 @@ #ifndef CONFIG_MPC83XX_SDRAM #include +#include #include #include #include diff --git a/arch/powerpc/cpu/mpc83xx/speed.c b/arch/powerpc/cpu/mpc83xx/speed.c index e118a10fa8..93af7f495f 100644 --- a/arch/powerpc/cpu/mpc83xx/speed.c +++ b/arch/powerpc/cpu/mpc83xx/speed.c @@ -11,6 +11,7 @@ #include #include #include +#include #include DECLARE_GLOBAL_DATA_PTR; diff --git a/arch/powerpc/cpu/mpc85xx/cpu.c b/arch/powerpc/cpu/mpc85xx/cpu.c index 5344b175a4..64024612cd 100644 --- a/arch/powerpc/cpu/mpc85xx/cpu.c +++ b/arch/powerpc/cpu/mpc85xx/cpu.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/arch/powerpc/cpu/mpc86xx/cpu.c b/arch/powerpc/cpu/mpc86xx/cpu.c index c023d0684f..1c3c78217c 100644 --- a/arch/powerpc/cpu/mpc86xx/cpu.c +++ b/arch/powerpc/cpu/mpc86xx/cpu.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include diff --git a/arch/powerpc/cpu/mpc8xx/cpu.c b/arch/powerpc/cpu/mpc8xx/cpu.c index 798eabdc21..6ad86e9a1d 100644 --- a/arch/powerpc/cpu/mpc8xx/cpu.c +++ b/arch/powerpc/cpu/mpc8xx/cpu.c @@ -17,6 +17,7 @@ */ #include +#include #include #include #include diff --git a/arch/xtensa/cpu/cpu.c b/arch/xtensa/cpu/cpu.c index 64bb0b6ee0..6f4b88f88e 100644 --- a/arch/xtensa/cpu/cpu.c +++ b/arch/xtensa/cpu/cpu.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include diff --git a/board/Arcturus/ucp1020/ddr.c b/board/Arcturus/ucp1020/ddr.c index 4b84a1a4c0..a3285ebe5c 100644 --- a/board/Arcturus/ucp1020/ddr.c +++ b/board/Arcturus/ucp1020/ddr.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include diff --git a/board/atmel/at91sam9261ek/at91sam9261ek.c b/board/atmel/at91sam9261ek/at91sam9261ek.c index 6f15bc6776..28765315f7 100644 --- a/board/atmel/at91sam9261ek/at91sam9261ek.c +++ b/board/atmel/at91sam9261ek/at91sam9261ek.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include diff --git a/board/atmel/at91sam9263ek/at91sam9263ek.c b/board/atmel/at91sam9263ek/at91sam9263ek.c index 2d882174de..31bb72c0cd 100644 --- a/board/atmel/at91sam9263ek/at91sam9263ek.c +++ b/board/atmel/at91sam9263ek/at91sam9263ek.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include diff --git a/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c b/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c index 3b277fc575..85004310b1 100644 --- a/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c +++ b/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include diff --git a/board/atmel/at91sam9n12ek/at91sam9n12ek.c b/board/atmel/at91sam9n12ek/at91sam9n12ek.c index b2bb7ec992..51b24e1d59 100644 --- a/board/atmel/at91sam9n12ek/at91sam9n12ek.c +++ b/board/atmel/at91sam9n12ek/at91sam9n12ek.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include diff --git a/board/atmel/at91sam9rlek/at91sam9rlek.c b/board/atmel/at91sam9rlek/at91sam9rlek.c index 0393307315..4e674d49b3 100644 --- a/board/atmel/at91sam9rlek/at91sam9rlek.c +++ b/board/atmel/at91sam9rlek/at91sam9rlek.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include diff --git a/board/atmel/common/video_display.c b/board/atmel/common/video_display.c index cc051d2e0c..5cc52139a7 100644 --- a/board/atmel/common/video_display.c +++ b/board/atmel/common/video_display.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/board/esd/meesc/meesc.c b/board/esd/meesc/meesc.c index b0d2f7b6f8..221048a91f 100644 --- a/board/esd/meesc/meesc.c +++ b/board/esd/meesc/meesc.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include diff --git a/board/freescale/bsc9131rdb/ddr.c b/board/freescale/bsc9131rdb/ddr.c index f9f8d80213..4b6d91df21 100644 --- a/board/freescale/bsc9131rdb/ddr.c +++ b/board/freescale/bsc9131rdb/ddr.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include diff --git a/board/freescale/bsc9132qds/ddr.c b/board/freescale/bsc9132qds/ddr.c index 191ef01d23..f4effe5a2d 100644 --- a/board/freescale/bsc9132qds/ddr.c +++ b/board/freescale/bsc9132qds/ddr.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include diff --git a/board/freescale/corenet_ds/ddr.c b/board/freescale/corenet_ds/ddr.c index 38f13ce4b2..9c8731ce78 100644 --- a/board/freescale/corenet_ds/ddr.c +++ b/board/freescale/corenet_ds/ddr.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include diff --git a/board/freescale/ls1043ardb/ddr.c b/board/freescale/ls1043ardb/ddr.c index 784e482f32..2677b7928f 100644 --- a/board/freescale/ls1043ardb/ddr.c +++ b/board/freescale/ls1043ardb/ddr.c @@ -7,6 +7,7 @@ #include #include #include "ddr.h" +#include #ifdef CONFIG_FSL_DEEP_SLEEP #include #endif diff --git a/board/freescale/mpc8541cds/mpc8541cds.c b/board/freescale/mpc8541cds/mpc8541cds.c index 779c99c268..be79a7ca7b 100644 --- a/board/freescale/mpc8541cds/mpc8541cds.c +++ b/board/freescale/mpc8541cds/mpc8541cds.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include diff --git a/board/freescale/mpc8548cds/mpc8548cds.c b/board/freescale/mpc8548cds/mpc8548cds.c index 2799b5b5a4..28f8a998ce 100644 --- a/board/freescale/mpc8548cds/mpc8548cds.c +++ b/board/freescale/mpc8548cds/mpc8548cds.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include diff --git a/board/freescale/mpc8555cds/mpc8555cds.c b/board/freescale/mpc8555cds/mpc8555cds.c index 6cfb8d5191..bc1ebc51ed 100644 --- a/board/freescale/mpc8555cds/mpc8555cds.c +++ b/board/freescale/mpc8555cds/mpc8555cds.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include diff --git a/board/freescale/p1010rdb/ddr.c b/board/freescale/p1010rdb/ddr.c index 01e3eafd12..71f6259b60 100644 --- a/board/freescale/p1010rdb/ddr.c +++ b/board/freescale/p1010rdb/ddr.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include diff --git a/board/freescale/p1_p2_rdb_pc/ddr.c b/board/freescale/p1_p2_rdb_pc/ddr.c index b9bd7b5276..2346f6a0c2 100644 --- a/board/freescale/p1_p2_rdb_pc/ddr.c +++ b/board/freescale/p1_p2_rdb_pc/ddr.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include diff --git a/board/freescale/p1_twr/ddr.c b/board/freescale/p1_twr/ddr.c index 7e8bd6b8c2..85f1f6344a 100644 --- a/board/freescale/p1_twr/ddr.c +++ b/board/freescale/p1_twr/ddr.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include diff --git a/board/mini-box/picosam9g45/picosam9g45.c b/board/mini-box/picosam9g45/picosam9g45.c index 9554fefd4e..9a724040b0 100644 --- a/board/mini-box/picosam9g45/picosam9g45.c +++ b/board/mini-box/picosam9g45/picosam9g45.c @@ -11,6 +11,7 @@ */ #include +#include #include #include #include diff --git a/board/ronetix/pm9261/pm9261.c b/board/ronetix/pm9261/pm9261.c index f1e7aab629..bad673412a 100644 --- a/board/ronetix/pm9261/pm9261.c +++ b/board/ronetix/pm9261/pm9261.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c index ae6006f85f..abd9151432 100644 --- a/cmd/bdinfo.c +++ b/cmd/bdinfo.c @@ -10,6 +10,7 @@ #include #include #include +#include #include DECLARE_GLOBAL_DATA_PTR; diff --git a/drivers/clk/clk_stm32mp1.c b/drivers/clk/clk_stm32mp1.c index e87307fa60..e223f84eac 100644 --- a/drivers/clk/clk_stm32mp1.c +++ b/drivers/clk/clk_stm32mp1.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/clk/mpc83xx_clk.c b/drivers/clk/mpc83xx_clk.c index 32d2db9eda..cbccda5594 100644 --- a/drivers/clk/mpc83xx_clk.c +++ b/drivers/clk/mpc83xx_clk.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/cpu/mpc83xx_cpu.c b/drivers/cpu/mpc83xx_cpu.c index 7bc86bf9b2..1e58457742 100644 --- a/drivers/cpu/mpc83xx_cpu.c +++ b/drivers/cpu/mpc83xx_cpu.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "mpc83xx_cpu.h" diff --git a/include/common.h b/include/common.h index d17a2b2642..f993e4bef3 100644 --- a/include/common.h +++ b/include/common.h @@ -310,9 +310,6 @@ int ulz4fn(const void *src, size_t srcn, void *dst, size_t *dstn); /* lib/vsprintf.c */ #include -/* lib/strmhz.c */ -char * strmhz(char *buf, unsigned long hz); - /* * STDIO based functions (can always be used) */ diff --git a/include/vsprintf.h b/include/vsprintf.h index d1740a378e..56844dd2de 100644 --- a/include/vsprintf.h +++ b/include/vsprintf.h @@ -212,4 +212,14 @@ void print_grouped_ull(unsigned long long int_val, int digits); bool str2off(const char *p, loff_t *num); bool str2long(const char *p, ulong *num); + +/** + * strmhz() - Convert a value to a Hz string + * + * This creates a string indicating the number of MHz of a value. For example, + * 2700000 produces "2.7". + * @buf: Buffer to hold output string, which must be large enough + * @hz: Value to convert + */ +char *strmhz(char *buf, unsigned long hz); #endif 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; +}