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 <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
Simon Glass 2019-11-14 12:57:20 -07:00 committed by Tom Rini
parent 8bef79bf3c
commit 2189d5f1e8
50 changed files with 76 additions and 26 deletions

View file

@ -5,6 +5,7 @@
#include <common.h>
#include <malloc.h>
#include <vsprintf.h>
#include <asm/arcregs.h>
#include <asm/cache.h>

View file

@ -11,6 +11,7 @@
#include <common.h>
#include <div64.h>
#include <netdev.h>
#include <vsprintf.h>
#include <asm/io.h>
#include <asm/arch-imx/cpu.h>
#include <asm/arch/imx-regs.h>

View file

@ -7,6 +7,7 @@
#include <common.h>
#include <div64.h>
#include <netdev.h>
#include <vsprintf.h>
#include <asm/io.h>
#include <asm/arch/imx-regs.h>
#include <asm/arch/clock.h>

View file

@ -4,6 +4,7 @@
*/
#include <common.h>
#include <vsprintf.h>
#include <asm/arch/clock.h>
#include <asm/io.h>
#include <asm/arch/immap_ls102xa.h>

View file

@ -7,6 +7,7 @@
#include <common.h>
#include <env.h>
#include <fsl_ddr_sdram.h>
#include <vsprintf.h>
#include <asm/io.h>
#include <linux/errno.h>
#include <asm/system.h>

View file

@ -7,6 +7,7 @@
*/
#include <common.h>
#include <vsprintf.h>
#include <asm/io.h>
#include <asm/arch/hardware.h>
#include <asm/arch/at91_pit.h>

View file

@ -9,6 +9,7 @@
*/
#include <common.h>
#include <vsprintf.h>
#include <asm/io.h>
#include <asm/arch/hardware.h>
#include <asm/arch/at91_pit.h>

View file

@ -9,6 +9,7 @@
*/
#include <common.h>
#include <vsprintf.h>
#include <watchdog.h>
#include <command.h>

View file

@ -9,6 +9,7 @@
*/
#include <common.h>
#include <vsprintf.h>
#include <watchdog.h>
#include <command.h>
#include <netdev.h>

View file

@ -14,6 +14,7 @@
*/
#include <common.h>
#include <vsprintf.h>
#include <watchdog.h>
#include <command.h>
#include <asm/immap.h>

View file

@ -5,6 +5,7 @@
*/
#include <common.h>
#include <vsprintf.h>
#include <asm/immap.h>
#include <asm/io.h>

View file

@ -9,6 +9,7 @@
*/
#include <common.h>
#include <vsprintf.h>
#include <watchdog.h>
#include <command.h>
#include <netdev.h>

View file

@ -9,6 +9,7 @@
*/
#include <common.h>
#include <vsprintf.h>
#include <watchdog.h>
#include <command.h>
#include <netdev.h>

View file

@ -9,6 +9,7 @@
*/
#include <common.h>
#include <vsprintf.h>
#include <watchdog.h>
#include <command.h>
#include <netdev.h>

View file

@ -10,6 +10,7 @@
*/
#include <common.h>
#include <vsprintf.h>
#include <watchdog.h>
#include <command.h>
#include <mpc83xx.h>

View file

@ -13,6 +13,7 @@
#ifndef CONFIG_MPC83XX_SDRAM
#include <common.h>
#include <vsprintf.h>
#include <asm/processor.h>
#include <asm/io.h>
#include <i2c.h>

View file

@ -11,6 +11,7 @@
#include <common.h>
#include <mpc83xx.h>
#include <command.h>
#include <vsprintf.h>
#include <asm/processor.h>
DECLARE_GLOBAL_DATA_PTR;

View file

@ -11,6 +11,7 @@
#include <config.h>
#include <common.h>
#include <cpu_func.h>
#include <vsprintf.h>
#include <watchdog.h>
#include <command.h>
#include <fsl_esdhc.h>

View file

@ -6,6 +6,7 @@
*/
#include <common.h>
#include <vsprintf.h>
#include <watchdog.h>
#include <command.h>
#include <asm/cache.h>

View file

@ -17,6 +17,7 @@
*/
#include <common.h>
#include <vsprintf.h>
#include <watchdog.h>
#include <command.h>
#include <mpc8xx.h>

View file

@ -10,6 +10,7 @@
#include <common.h>
#include <command.h>
#include <vsprintf.h>
#include <linux/stringify.h>
#include <asm/global_data.h>
#include <asm/cache.h>

View file

@ -8,6 +8,7 @@
*/
#include <common.h>
#include <vsprintf.h>
#include <asm/mmu.h>
#include <asm/immap_85xx.h>
#include <asm/processor.h>

View file

@ -7,6 +7,7 @@
#include <common.h>
#include <debug_uart.h>
#include <vsprintf.h>
#include <asm/io.h>
#include <asm/arch/at91sam9261.h>
#include <asm/arch/at91sam9261_matrix.h>

View file

@ -7,6 +7,7 @@
#include <common.h>
#include <debug_uart.h>
#include <vsprintf.h>
#include <linux/sizes.h>
#include <asm/arch/at91sam9263.h>
#include <asm/arch/at91sam9_smc.h>

View file

@ -7,6 +7,7 @@
#include <common.h>
#include <debug_uart.h>
#include <vsprintf.h>
#include <asm/io.h>
#include <asm/arch/clk.h>
#include <asm/arch/at91sam9g45_matrix.h>

View file

@ -5,6 +5,7 @@
*/
#include <common.h>
#include <vsprintf.h>
#include <asm/io.h>
#include <asm/arch/at91sam9x5_matrix.h>
#include <asm/arch/at91sam9_smc.h>

View file

@ -7,6 +7,7 @@
#include <common.h>
#include <debug_uart.h>
#include <vsprintf.h>
#include <asm/io.h>
#include <asm/mach-types.h>
#include <asm/arch/at91sam9rl.h>

View file

@ -11,6 +11,7 @@
#include <version.h>
#include <video.h>
#include <video_console.h>
#include <vsprintf.h>
#include <asm/io.h>
#include <asm/arch/clk.h>

View file

@ -11,6 +11,7 @@
#include <common.h>
#include <env.h>
#include <vsprintf.h>
#include <asm/io.h>
#include <asm/gpio.h>
#include <asm/mach-types.h>

View file

@ -4,6 +4,7 @@
*/
#include <common.h>
#include <vsprintf.h>
#include <asm/mmu.h>
#include <asm/immap_85xx.h>
#include <asm/processor.h>

View file

@ -4,6 +4,7 @@
*/
#include <common.h>
#include <vsprintf.h>
#include <asm/mmu.h>
#include <asm/immap_85xx.h>
#include <asm/processor.h>

View file

@ -6,6 +6,7 @@
#include <common.h>
#include <i2c.h>
#include <hwconfig.h>
#include <vsprintf.h>
#include <asm/mmu.h>
#include <fsl_ddr_sdram.h>
#include <fsl_ddr_dimm_params.h>

View file

@ -7,6 +7,7 @@
#include <fsl_ddr_sdram.h>
#include <fsl_ddr_dimm_params.h>
#include "ddr.h"
#include <vsprintf.h>
#ifdef CONFIG_FSL_DEEP_SLEEP
#include <fsl_sleep.h>
#endif

View file

@ -7,6 +7,7 @@
#include <common.h>
#include <pci.h>
#include <vsprintf.h>
#include <asm/processor.h>
#include <asm/mmu.h>
#include <asm/immap_85xx.h>

View file

@ -7,6 +7,7 @@
#include <common.h>
#include <pci.h>
#include <vsprintf.h>
#include <asm/processor.h>
#include <asm/mmu.h>
#include <asm/immap_85xx.h>

View file

@ -5,6 +5,7 @@
#include <common.h>
#include <pci.h>
#include <vsprintf.h>
#include <asm/processor.h>
#include <asm/mmu.h>
#include <asm/immap_85xx.h>

View file

@ -4,6 +4,7 @@
*/
#include <common.h>
#include <vsprintf.h>
#include <asm/mmu.h>
#include <asm/immap_85xx.h>
#include <asm/processor.h>

View file

@ -4,6 +4,7 @@
*/
#include <common.h>
#include <vsprintf.h>
#include <asm/mmu.h>
#include <asm/immap_85xx.h>
#include <asm/processor.h>

View file

@ -4,6 +4,7 @@
*/
#include <common.h>
#include <vsprintf.h>
#include <asm/mmu.h>
#include <asm/immap_85xx.h>
#include <asm/processor.h>

View file

@ -11,6 +11,7 @@
*/
#include <common.h>
#include <vsprintf.h>
#include <asm/io.h>
#include <asm/arch/clk.h>
#include <asm/arch/at91sam9g45_matrix.h>

View file

@ -8,6 +8,7 @@
*/
#include <common.h>
#include <vsprintf.h>
#include <linux/sizes.h>
#include <asm/io.h>
#include <asm/gpio.h>

View file

@ -10,6 +10,7 @@
#include <common.h>
#include <command.h>
#include <env.h>
#include <vsprintf.h>
#include <linux/compiler.h>
DECLARE_GLOBAL_DATA_PTR;

View file

@ -10,6 +10,7 @@
#include <regmap.h>
#include <spl.h>
#include <syscon.h>
#include <vsprintf.h>
#include <linux/io.h>
#include <linux/iopoll.h>
#include <dt-bindings/clock/stm32mp1-clks.h>

View file

@ -7,6 +7,7 @@
#include <common.h>
#include <clk-uclass.h>
#include <dm.h>
#include <vsprintf.h>
#include <dm/lists.h>
#include <dt-bindings/clk/mpc83xx-clk.h>
#include <asm/arch/soc.h>

View file

@ -9,6 +9,7 @@
#include <clk.h>
#include <cpu.h>
#include <dm.h>
#include <vsprintf.h>
#include "mpc83xx_cpu.h"

View file

@ -310,9 +310,6 @@ int ulz4fn(const void *src, size_t srcn, void *dst, size_t *dstn);
/* lib/vsprintf.c */
#include <vsprintf.h>
/* lib/strmhz.c */
char * strmhz(char *buf, unsigned long hz);
/*
* STDIO based functions (can always be used)
*/

View file

@ -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

View file

@ -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

View file

@ -1,21 +0,0 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* (C) Copyright 2002-2006
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*/
#include <common.h>
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);
}

View file

@ -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 <div64.h>
#include <hexdump.h>
#include <stdarg.h>
#include <vsprintf.h>
#include <linux/ctype.h>
#include <linux/err.h>
#include <linux/types.h>
@ -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;
}