Browse Source

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>
Simon Glass 4 years ago
parent
commit
2189d5f1e8
50 changed files with 76 additions and 26 deletions
  1. 1 0
      arch/arc/lib/cpu.c
  2. 1 0
      arch/arm/cpu/arm926ejs/mx25/generic.c
  3. 1 0
      arch/arm/cpu/arm926ejs/mx27/generic.c
  4. 1 0
      arch/arm/cpu/armv7/ls102xa/cpu.c
  5. 1 0
      arch/arm/cpu/armv8/fsl-layerscape/cpu.c
  6. 1 0
      arch/arm/mach-at91/arm926ejs/cpu.c
  7. 1 0
      arch/arm/mach-at91/armv7/cpu.c
  8. 1 0
      arch/m68k/cpu/mcf5227x/cpu.c
  9. 1 0
      arch/m68k/cpu/mcf523x/cpu.c
  10. 1 0
      arch/m68k/cpu/mcf52x2/cpu.c
  11. 1 0
      arch/m68k/cpu/mcf530x/cpu.c
  12. 1 0
      arch/m68k/cpu/mcf532x/cpu.c
  13. 1 0
      arch/m68k/cpu/mcf5445x/cpu.c
  14. 1 0
      arch/m68k/cpu/mcf547x_8x/cpu.c
  15. 1 0
      arch/powerpc/cpu/mpc83xx/cpu.c
  16. 1 0
      arch/powerpc/cpu/mpc83xx/spd_sdram.c
  17. 1 0
      arch/powerpc/cpu/mpc83xx/speed.c
  18. 1 0
      arch/powerpc/cpu/mpc85xx/cpu.c
  19. 1 0
      arch/powerpc/cpu/mpc86xx/cpu.c
  20. 1 0
      arch/powerpc/cpu/mpc8xx/cpu.c
  21. 1 0
      arch/xtensa/cpu/cpu.c
  22. 1 0
      board/Arcturus/ucp1020/ddr.c
  23. 1 0
      board/atmel/at91sam9261ek/at91sam9261ek.c
  24. 1 0
      board/atmel/at91sam9263ek/at91sam9263ek.c
  25. 1 0
      board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c
  26. 1 0
      board/atmel/at91sam9n12ek/at91sam9n12ek.c
  27. 1 0
      board/atmel/at91sam9rlek/at91sam9rlek.c
  28. 1 0
      board/atmel/common/video_display.c
  29. 1 0
      board/esd/meesc/meesc.c
  30. 1 0
      board/freescale/bsc9131rdb/ddr.c
  31. 1 0
      board/freescale/bsc9132qds/ddr.c
  32. 1 0
      board/freescale/corenet_ds/ddr.c
  33. 1 0
      board/freescale/ls1043ardb/ddr.c
  34. 1 0
      board/freescale/mpc8541cds/mpc8541cds.c
  35. 1 0
      board/freescale/mpc8548cds/mpc8548cds.c
  36. 1 0
      board/freescale/mpc8555cds/mpc8555cds.c
  37. 1 0
      board/freescale/p1010rdb/ddr.c
  38. 1 0
      board/freescale/p1_p2_rdb_pc/ddr.c
  39. 1 0
      board/freescale/p1_twr/ddr.c
  40. 1 0
      board/mini-box/picosam9g45/picosam9g45.c
  41. 1 0
      board/ronetix/pm9261/pm9261.c
  42. 1 0
      cmd/bdinfo.c
  43. 1 0
      drivers/clk/clk_stm32mp1.c
  44. 1 0
      drivers/clk/mpc83xx_clk.c
  45. 1 0
      drivers/cpu/mpc83xx_cpu.c
  46. 0 3
      include/common.h
  47. 10 0
      include/vsprintf.h
  48. 2 2
      lib/Makefile
  49. 0 21
      lib/strmhz.c
  50. 19 0
      lib/vsprintf.c

+ 1 - 0
arch/arc/lib/cpu.c

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

+ 1 - 0
arch/arm/cpu/arm926ejs/mx25/generic.c

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

+ 1 - 0
arch/arm/cpu/arm926ejs/mx27/generic.c

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

+ 1 - 0
arch/arm/cpu/armv7/ls102xa/cpu.c

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

+ 1 - 0
arch/arm/cpu/armv8/fsl-layerscape/cpu.c

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

+ 1 - 0
arch/arm/mach-at91/arm926ejs/cpu.c

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

+ 1 - 0
arch/arm/mach-at91/armv7/cpu.c

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

+ 1 - 0
arch/m68k/cpu/mcf5227x/cpu.c

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

+ 1 - 0
arch/m68k/cpu/mcf523x/cpu.c

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

+ 1 - 0
arch/m68k/cpu/mcf52x2/cpu.c

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

+ 1 - 0
arch/m68k/cpu/mcf530x/cpu.c

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

+ 1 - 0
arch/m68k/cpu/mcf532x/cpu.c

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

+ 1 - 0
arch/m68k/cpu/mcf5445x/cpu.c

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

+ 1 - 0
arch/m68k/cpu/mcf547x_8x/cpu.c

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

+ 1 - 0
arch/powerpc/cpu/mpc83xx/cpu.c

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

+ 1 - 0
arch/powerpc/cpu/mpc83xx/spd_sdram.c

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

+ 1 - 0
arch/powerpc/cpu/mpc83xx/speed.c

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

+ 1 - 0
arch/powerpc/cpu/mpc85xx/cpu.c

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

+ 1 - 0
arch/powerpc/cpu/mpc86xx/cpu.c

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

+ 1 - 0
arch/powerpc/cpu/mpc8xx/cpu.c

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

+ 1 - 0
arch/xtensa/cpu/cpu.c

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

+ 1 - 0
board/Arcturus/ucp1020/ddr.c

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

+ 1 - 0
board/atmel/at91sam9261ek/at91sam9261ek.c

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

+ 1 - 0
board/atmel/at91sam9263ek/at91sam9263ek.c

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

+ 1 - 0
board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c

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

+ 1 - 0
board/atmel/at91sam9n12ek/at91sam9n12ek.c

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

+ 1 - 0
board/atmel/at91sam9rlek/at91sam9rlek.c

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

+ 1 - 0
board/atmel/common/video_display.c

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

+ 1 - 0
board/esd/meesc/meesc.c

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

+ 1 - 0
board/freescale/bsc9131rdb/ddr.c

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

+ 1 - 0
board/freescale/bsc9132qds/ddr.c

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

+ 1 - 0
board/freescale/corenet_ds/ddr.c

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

+ 1 - 0
board/freescale/ls1043ardb/ddr.c

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

+ 1 - 0
board/freescale/mpc8541cds/mpc8541cds.c

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

+ 1 - 0
board/freescale/mpc8548cds/mpc8548cds.c

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

+ 1 - 0
board/freescale/mpc8555cds/mpc8555cds.c

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

+ 1 - 0
board/freescale/p1010rdb/ddr.c

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

+ 1 - 0
board/freescale/p1_p2_rdb_pc/ddr.c

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

+ 1 - 0
board/freescale/p1_twr/ddr.c

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

+ 1 - 0
board/mini-box/picosam9g45/picosam9g45.c

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

+ 1 - 0
board/ronetix/pm9261/pm9261.c

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

+ 1 - 0
cmd/bdinfo.c

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

+ 1 - 0
drivers/clk/clk_stm32mp1.c

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

+ 1 - 0
drivers/clk/mpc83xx_clk.c

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

+ 1 - 0
drivers/cpu/mpc83xx_cpu.c

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

+ 0 - 3
include/common.h

@@ -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)
  */

+ 10 - 0
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

+ 2 - 2
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

+ 0 - 21
lib/strmhz.c

@@ -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);
-}

+ 19 - 0
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 <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;
+}