[PATCH 0/2] lib: print_freq() should output kHz not KHz

Correct print_freq() for output of kHz. Provide unit tests for print_freq() and print_size().
Heinrich Schuchardt (2): lib: print_freq() should output kHz not KHz test: unit tests for print_freq(), print_size()
include/display_options.h | 2 +- lib/display_options.c | 2 +- test/lib/Makefile | 1 + 3 files changed, 3 insertions(+), 2 deletions(-)
-- 2.28.0

In the International System of Units (SI) the prefix kilo is abbreviated as 'k' not 'K'. 'K' is the symbol for Kelvin.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- include/display_options.h | 2 +- lib/display_options.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/display_options.h b/include/display_options.h index a0dabca2b8..049688e39e 100644 --- a/include/display_options.h +++ b/include/display_options.h @@ -24,7 +24,7 @@ void print_size(uint64_t size, const char *suffix); /** * print_freq() - Print a frequency with a suffix * - * Print frequencies as "x.xx GHz", "xxx KHz", etc as needed; allow for + * Print frequencies as "x.xx GHz", "xxx kHz", etc as needed; allow for * optional trailing string (like "\n") * * @freq: Frequency to print in Hz diff --git a/lib/display_options.c b/lib/display_options.c index ea9977cc18..b2025eeb5c 100644 --- a/lib/display_options.c +++ b/lib/display_options.c @@ -54,7 +54,7 @@ void print_freq(uint64_t freq, const char *s) { unsigned long m = 0; uint32_t f; - static const char names[] = {'G', 'M', 'K'}; + static const char names[] = {'G', 'M', 'k'}; unsigned long d = 1e9; char c = 0; unsigned int i; -- 2.28.0

On 08.10.20 22:23, Heinrich Schuchardt wrote:
In the International System of Units (SI) the prefix kilo is abbreviated as 'k' not 'K'. 'K' is the symbol for Kelvin.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
Reviewed-by: Stefan Roese sr@denx.de
Thanks, Stefan
include/display_options.h | 2 +- lib/display_options.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/display_options.h b/include/display_options.h index a0dabca2b8..049688e39e 100644 --- a/include/display_options.h +++ b/include/display_options.h @@ -24,7 +24,7 @@ void print_size(uint64_t size, const char *suffix); /**
- print_freq() - Print a frequency with a suffix
- Print frequencies as "x.xx GHz", "xxx KHz", etc as needed; allow for
- Print frequencies as "x.xx GHz", "xxx kHz", etc as needed; allow for
- optional trailing string (like "\n")
- @freq: Frequency to print in Hz
diff --git a/lib/display_options.c b/lib/display_options.c index ea9977cc18..b2025eeb5c 100644 --- a/lib/display_options.c +++ b/lib/display_options.c @@ -54,7 +54,7 @@ void print_freq(uint64_t freq, const char *s) { unsigned long m = 0; uint32_t f;
- static const char names[] = {'G', 'M', 'K'};
- static const char names[] = {'G', 'M', 'k'}; unsigned long d = 1e9; char c = 0; unsigned int i;
-- 2.28.0
Viele Grüße, Stefan

On Thu, Oct 08, 2020 at 10:23:23PM +0200, Heinrich Schuchardt wrote:
In the International System of Units (SI) the prefix kilo is abbreviated as 'k' not 'K'. 'K' is the symbol for Kelvin.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de Reviewed-by: Stefan Roese sr@denx.de
Applied to u-boot/master, thanks!

Provide unit tests for functions print_freq() and print_size().
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- test/lib/Makefile | 1 + 1 file changed, 1 insertion(+)
diff --git a/test/lib/Makefile b/test/lib/Makefile index 22236f8587..15cd512506 100644 --- a/test/lib/Makefile +++ b/test/lib/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_EFI_LOADER) += efi_device_path.o obj-$(CONFIG_EFI_SECURE_BOOT) += efi_image_region.o obj-y += hexdump.o obj-y += lmb.o +obj-y += test_print.o obj-$(CONFIG_SSCANF) += sscanf.o obj-y += string.o obj-$(CONFIG_ERRNO_STR) += test_errno_str.o -- 2.28.0

On 10/8/20 4:23 PM, Heinrich Schuchardt wrote:
Provide unit tests for functions print_freq() and print_size().
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
test/lib/Makefile | 1 + 1 file changed, 1 insertion(+)
diff --git a/test/lib/Makefile b/test/lib/Makefile index 22236f8587..15cd512506 100644 --- a/test/lib/Makefile +++ b/test/lib/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_EFI_LOADER) += efi_device_path.o obj-$(CONFIG_EFI_SECURE_BOOT) += efi_image_region.o obj-y += hexdump.o obj-y += lmb.o +obj-y += test_print.o
Should test/lib/test_print.c be included in this patch?
--Sean
obj-$(CONFIG_SSCANF) += sscanf.o obj-y += string.o obj-$(CONFIG_ERRNO_STR) += test_errno_str.o -- 2.28.0

On Thu, Oct 08, 2020 at 10:23:24PM +0200, Heinrich Schuchardt wrote:
Provide unit tests for functions print_freq() and print_size().
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
test/lib/Makefile | 1 + 1 file changed, 1 insertion(+)
-- 2.28.0
diff --git a/test/lib/Makefile b/test/lib/Makefile index 22236f8587..15cd512506 100644 --- a/test/lib/Makefile +++ b/test/lib/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_EFI_LOADER) += efi_device_path.o obj-$(CONFIG_EFI_SECURE_BOOT) += efi_image_region.o obj-y += hexdump.o obj-y += lmb.o +obj-y += test_print.o obj-$(CONFIG_SSCANF) += sscanf.o obj-y += string.o obj-$(CONFIG_ERRNO_STR) += test_errno_str.o
New test file missing.
participants (4)
-
Heinrich Schuchardt
-
Sean Anderson
-
Stefan Roese
-
Tom Rini