History log of /u-boot/include/vsprintf.h
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 3e96ed44 17-Jan-2023 Simon Glass <sjg@chromium.org>

lib: Add a function to split a string into substrings

Some environment variables provide a space-separated list of strings. It
is easier to process these when they are broken out into an array of
strings.

Add a utility function to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8565efd5 24-Apr-2022 Simon Glass <sjg@chromium.org>

lib: Add a way to find the postiion of a trailing number

At present it is not possible to find out which part of the string is the
number part and which is before it. Add a new variant which provides this
feature, so we can separate the two in the caller.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d667a0d8 24-Apr-2022 Simon Glass <sjg@chromium.org>

lib: Fix a few bugs in trailing_strtoln()

At present this has a minor bug in that it reads the byte before the
start of the string, if it is empty. Also it doesn't handle a
non-numeric prefix which is only one character long.

Fix these bugs with a reworked implementation. Add a test for the second
case. The first one is hard to test.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4e64cae0 24-Apr-2022 Simon Glass <sjg@chromium.org>

lib: Correct comment formatting to avoid sphinx problems

Tweak a few comments to kep sphinx happy, in case we want to include this
file one day.

Also fix the 'exxamine' typo.

Patch-notes:
This uses:

sed -i 's/@param \(\S*\)\s*/@\1: /' include/vsprintf.h

to convert the @param to the new format.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 18436c74 24-Apr-2022 Simon Glass <sjg@chromium.org>

test: Add tests for trailing_strtol()

This function currently has no tests. Add some.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 185f812c 19-Jan-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

doc: replace @return by Return:

Sphinx expects Return: and not @return to indicate a return value.

find . -name '*.c' -exec \
sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \;

find . -name '*.h' -exec \
sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \;

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

# 499f1844 20-Dec-2021 Samuel Dionne-Riel <samuel@dionne-riel.com>

lib: export vsscanf

The function was missing from exports, even though it loooks like the
intent of the implementation in sscanf.c was to have it exported.

Signed-off-by: Samuel Dionne-Riel <samuel@dionne-riel.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 4a255ea3 14-Oct-2021 Simon Glass <sjg@chromium.org>

lib: Add a function to convert a string to a hex value

Add an xtoa() function, similar to itoa() but for hex instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Artem Lapkin <email2tema@gmail.com>
Tested-by: Artem Lapkin <email2tema@gmail.com>

# 3bfb0f71 14-Oct-2021 Simon Glass <sjg@chromium.org>

lib: Add tests for simple_itoa()

Add test and a comment for this function.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Artem Lapkin <email2tema@gmail.com>

# e6951139 24-Jul-2021 Simon Glass <sjg@chromium.org>

lib: Allow using 0x when a decimal value is requested

U-Boot mostly uses hex for value input, largely because addresses are much
easier to understand in hex.

But in some cases a decimal value is requested, such as where the value is
small or hex does not make sense in the context. In these cases it is
sometimes useful to be able to provide a hex value in any case, if only to
resolve any ambiguity.

Add this functionality, for increased flexibility.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 18546f29 24-Jul-2021 Simon Glass <sjg@chromium.org>

lib: Comment the base parameter with simple_strtoul/l()

This parameter is not documented properly since it does not cover the
meaning when the base is 0. Update this in both functions.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0b1284eb 24-Jul-2021 Simon Glass <sjg@chromium.org>

global: Convert simple_strtoul() with decimal to dectoul()

It is a pain to have to specify the value 10 in each call. Add a new
dectoul() function and update the code to use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 7e5f460e 24-Jul-2021 Simon Glass <sjg@chromium.org>

global: Convert simple_strtoul() with hex to hextoul()

It is a pain to have to specify the value 16 in each call. Add a new
hextoul() function and update the code to use it.

Add a proper comment to simple_strtoul() while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0b016428 22-Jul-2021 Roland Gaudig <roland.gaudig@weidmueller.com>

lib: strto: add simple_strtoll function

Add simple_strtoll function for converting a string containing digits
into a long long int value.

Signed-off-by: Roland Gaudig <roland.gaudig@weidmueller.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# e87dfb05 05-Aug-2020 Andrii Anisov <andrii_anisov@epam.com>

lib: sscanf: add sscanf implementation

Port sscanf implementation from mini-os and introduce new
Kconfig option to enable it: CONFIG_SSCANF. Disable by default.

Signed-off-by: Andrii Anisov <andrii_anisov@epam.com>
Signed-off-by: Anastasiia Lukianenko <anastasiia_lukianenko@epam.com>
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>

# fdc79a6b 08-Apr-2020 Simon Glass <sjg@chromium.org>

lib: Add a function to convert a string to upper case

Add a helper function for this operation. Update the strtoul() tests to
check upper case as well.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 2189d5f1 14-Nov-2019 Simon Glass <sjg@chromium.org>

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>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# f7d6b896 15-Sep-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

vsprintf.h: include <linux/types.h>

This header uses ulong, size_t, loff_t.
Include <linux/types.h> to make this header self-contained.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

# de2de319 06-Sep-2017 Heinrich Schuchardt <xypron.glpk@gmx.de>

vsprintf: vsprintf does not have parameter size

The inline documentation of vsprintf mentions a parameter size
which does not exist in the function declaration.

int vsprintf(char *buf, const char *fmt, va_list args);

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 3450a859 23-Oct-2016 Vagrant Cascadian <vagrant@debian.org>

Fix spelling of "resetting".

Cover-Letter: Fixes several spelling errors for the words "resetting",
"extended", "occur", and "multiple".

Signed-off-by: Vagrant Cascadian <vagrant@debian.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# f272f1fc 05-Jul-2016 Maxime Ripard <maxime.ripard@free-electrons.com>

vsprintf: Include stdarg for va_list

vsprintf.h doesn't include the stdarg.h file, which means that it relies on
the files that include vsprintf.h to include stdarg.h as well.

Add an explicit include to avoid build errors when simply including that
file.

Acked-by: Simon Glass <sjg@chromium.org>
Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

# 947c626d 14-Jan-2016 Tom Rini <trini@konsulko.com>

vsprintf.c: Always enable CONFIG_SYS_VSNPRINTF

Enabling this function always removes some class of string saftey issues.
The size change here in general is about 400 bytes and this seems a reasonable
trade-off.

Cc: Peng Fan <peng.fan@nxp.com>
Cc: Peter Robinson <pbrobinson@gmail.com>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Adrian Alonso <aalonso@freescale.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# c4af6732 23-Jun-2015 Simon Glass <sjg@chromium.org>

lib: Add function to extract a number from the end of a string

Split out the code in fdtdec which finds a number at the end of a string. It
can be useful in other situations.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 09c32807 26-Apr-2015 Heiko Schocher <hs@denx.de>

mtd, nand: Move common functions from cmd_nand.c to common place

Move common functions from cmd_nand.c (for calculating offset
and size from cmdline paramter) to common place, so they could
used from other commands which use mtd partitions.

For onenand the arg_off_size() is left in common/cmd_onenand.c.
It should use now the common arg_off() function, but as I could
not test onenand I let it there ...

Signed-off-by: Heiko Schocher <hs@denx.de>
Acked-by: Scott Wood <scottwood@freescale.com>
Reviewed-by: Jagannadh Teki <jteki@openedev.com>

# 66312374 27-Feb-2015 Simon Glass <sjg@chromium.org>

dm: Add a panic_str() function to reduce code size

The printf() in panic() adds about 1.5KB of code size to SPL when compiled
with Thumb-2. Provide a smaller version that does not support printf()-style
arguments and use it in two commonly compiled places.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 3765b3e7 07-Oct-2013 Wolfgang Denk <wd@denx.de>

Coding Style cleanup: remove trailing white space

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# b8bcaa3a 11-Jun-2013 Simon Glass <sjg@chromium.org>

Add function to print a number with grouped digits

Move bootstage's numbering printing code into a generic place so that it can
be used by tracing also.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 71ec92b6 02-Nov-2011 Simon Glass <sjg@chromium.org>

vsprintf: Move function documentation into header file

Now that this is not in common.h, perhaps it is acceptable to move this
documentation into the header file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 046a37bd 02-Nov-2011 Sonny Rao <sonnyrao@chromium.org>

Add safe vsnprintf and snprintf library functions

From: Sonny Rao <sonnyrao@chromium.org>

These functions are useful in U-Boot because they allow a graceful failure
rather than an unpredictable stack overflow when printf() buffers are
exceeded.

Mostly copied from the Linux kernel. I copied vscnprintf and
scnprintf so we can change printf and vprintf to use the safe
implementation but still return the correct values.

(Simon Glass <sjg@chromium.org> modified this commit a little)

Signed-off-by: Sonny Rao <sonnyrao@chromium.org>

# 9785c905 02-Nov-2011 Simon Glass <sjg@chromium.org>

Move vsprintf functions into their own header

common.h is very large, so before changing the vsprintf functions, move the
prototypes into their own header file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8565efd5 24-Apr-2022 Simon Glass <sjg@chromium.org>

lib: Add a way to find the postiion of a trailing number

At present it is not possible to find out which part of the string is the
number part and which is before it. Add a new variant which provides this
feature, so we can separate the two in the caller.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d667a0d8 24-Apr-2022 Simon Glass <sjg@chromium.org>

lib: Fix a few bugs in trailing_strtoln()

At present this has a minor bug in that it reads the byte before the
start of the string, if it is empty. Also it doesn't handle a
non-numeric prefix which is only one character long.

Fix these bugs with a reworked implementation. Add a test for the second
case. The first one is hard to test.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4e64cae0 24-Apr-2022 Simon Glass <sjg@chromium.org>

lib: Correct comment formatting to avoid sphinx problems

Tweak a few comments to kep sphinx happy, in case we want to include this
file one day.

Also fix the 'exxamine' typo.

Patch-notes:
This uses:

sed -i 's/@param \(\S*\)\s*/@\1: /' include/vsprintf.h

to convert the @param to the new format.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 18436c74 24-Apr-2022 Simon Glass <sjg@chromium.org>

test: Add tests for trailing_strtol()

This function currently has no tests. Add some.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 185f812c 19-Jan-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

doc: replace @return by Return:

Sphinx expects Return: and not @return to indicate a return value.

find . -name '*.c' -exec \
sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \;

find . -name '*.h' -exec \
sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \;

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

# 499f1844 20-Dec-2021 Samuel Dionne-Riel <samuel@dionne-riel.com>

lib: export vsscanf

The function was missing from exports, even though it loooks like the
intent of the implementation in sscanf.c was to have it exported.

Signed-off-by: Samuel Dionne-Riel <samuel@dionne-riel.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 4a255ea3 14-Oct-2021 Simon Glass <sjg@chromium.org>

lib: Add a function to convert a string to a hex value

Add an xtoa() function, similar to itoa() but for hex instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Artem Lapkin <email2tema@gmail.com>
Tested-by: Artem Lapkin <email2tema@gmail.com>

# 3bfb0f71 14-Oct-2021 Simon Glass <sjg@chromium.org>

lib: Add tests for simple_itoa()

Add test and a comment for this function.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Artem Lapkin <email2tema@gmail.com>

# e6951139 24-Jul-2021 Simon Glass <sjg@chromium.org>

lib: Allow using 0x when a decimal value is requested

U-Boot mostly uses hex for value input, largely because addresses are much
easier to understand in hex.

But in some cases a decimal value is requested, such as where the value is
small or hex does not make sense in the context. In these cases it is
sometimes useful to be able to provide a hex value in any case, if only to
resolve any ambiguity.

Add this functionality, for increased flexibility.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 18546f29 24-Jul-2021 Simon Glass <sjg@chromium.org>

lib: Comment the base parameter with simple_strtoul/l()

This parameter is not documented properly since it does not cover the
meaning when the base is 0. Update this in both functions.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0b1284eb 24-Jul-2021 Simon Glass <sjg@chromium.org>

global: Convert simple_strtoul() with decimal to dectoul()

It is a pain to have to specify the value 10 in each call. Add a new
dectoul() function and update the code to use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 7e5f460e 24-Jul-2021 Simon Glass <sjg@chromium.org>

global: Convert simple_strtoul() with hex to hextoul()

It is a pain to have to specify the value 16 in each call. Add a new
hextoul() function and update the code to use it.

Add a proper comment to simple_strtoul() while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0b016428 22-Jul-2021 Roland Gaudig <roland.gaudig@weidmueller.com>

lib: strto: add simple_strtoll function

Add simple_strtoll function for converting a string containing digits
into a long long int value.

Signed-off-by: Roland Gaudig <roland.gaudig@weidmueller.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# e87dfb05 05-Aug-2020 Andrii Anisov <andrii_anisov@epam.com>

lib: sscanf: add sscanf implementation

Port sscanf implementation from mini-os and introduce new
Kconfig option to enable it: CONFIG_SSCANF. Disable by default.

Signed-off-by: Andrii Anisov <andrii_anisov@epam.com>
Signed-off-by: Anastasiia Lukianenko <anastasiia_lukianenko@epam.com>
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>

# fdc79a6b 08-Apr-2020 Simon Glass <sjg@chromium.org>

lib: Add a function to convert a string to upper case

Add a helper function for this operation. Update the strtoul() tests to
check upper case as well.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 2189d5f1 14-Nov-2019 Simon Glass <sjg@chromium.org>

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>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# f7d6b896 15-Sep-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

vsprintf.h: include <linux/types.h>

This header uses ulong, size_t, loff_t.
Include <linux/types.h> to make this header self-contained.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

# de2de319 06-Sep-2017 Heinrich Schuchardt <xypron.glpk@gmx.de>

vsprintf: vsprintf does not have parameter size

The inline documentation of vsprintf mentions a parameter size
which does not exist in the function declaration.

int vsprintf(char *buf, const char *fmt, va_list args);

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 3450a859 23-Oct-2016 Vagrant Cascadian <vagrant@debian.org>

Fix spelling of "resetting".

Cover-Letter: Fixes several spelling errors for the words "resetting",
"extended", "occur", and "multiple".

Signed-off-by: Vagrant Cascadian <vagrant@debian.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# f272f1fc 05-Jul-2016 Maxime Ripard <maxime.ripard@free-electrons.com>

vsprintf: Include stdarg for va_list

vsprintf.h doesn't include the stdarg.h file, which means that it relies on
the files that include vsprintf.h to include stdarg.h as well.

Add an explicit include to avoid build errors when simply including that
file.

Acked-by: Simon Glass <sjg@chromium.org>
Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

# 947c626d 14-Jan-2016 Tom Rini <trini@konsulko.com>

vsprintf.c: Always enable CONFIG_SYS_VSNPRINTF

Enabling this function always removes some class of string saftey issues.
The size change here in general is about 400 bytes and this seems a reasonable
trade-off.

Cc: Peng Fan <peng.fan@nxp.com>
Cc: Peter Robinson <pbrobinson@gmail.com>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Adrian Alonso <aalonso@freescale.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# c4af6732 23-Jun-2015 Simon Glass <sjg@chromium.org>

lib: Add function to extract a number from the end of a string

Split out the code in fdtdec which finds a number at the end of a string. It
can be useful in other situations.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 09c32807 26-Apr-2015 Heiko Schocher <hs@denx.de>

mtd, nand: Move common functions from cmd_nand.c to common place

Move common functions from cmd_nand.c (for calculating offset
and size from cmdline paramter) to common place, so they could
used from other commands which use mtd partitions.

For onenand the arg_off_size() is left in common/cmd_onenand.c.
It should use now the common arg_off() function, but as I could
not test onenand I let it there ...

Signed-off-by: Heiko Schocher <hs@denx.de>
Acked-by: Scott Wood <scottwood@freescale.com>
Reviewed-by: Jagannadh Teki <jteki@openedev.com>

# 66312374 27-Feb-2015 Simon Glass <sjg@chromium.org>

dm: Add a panic_str() function to reduce code size

The printf() in panic() adds about 1.5KB of code size to SPL when compiled
with Thumb-2. Provide a smaller version that does not support printf()-style
arguments and use it in two commonly compiled places.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 3765b3e7 07-Oct-2013 Wolfgang Denk <wd@denx.de>

Coding Style cleanup: remove trailing white space

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# b8bcaa3a 11-Jun-2013 Simon Glass <sjg@chromium.org>

Add function to print a number with grouped digits

Move bootstage's numbering printing code into a generic place so that it can
be used by tracing also.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 71ec92b6 02-Nov-2011 Simon Glass <sjg@chromium.org>

vsprintf: Move function documentation into header file

Now that this is not in common.h, perhaps it is acceptable to move this
documentation into the header file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 046a37bd 02-Nov-2011 Sonny Rao <sonnyrao@chromium.org>

Add safe vsnprintf and snprintf library functions

From: Sonny Rao <sonnyrao@chromium.org>

These functions are useful in U-Boot because they allow a graceful failure
rather than an unpredictable stack overflow when printf() buffers are
exceeded.

Mostly copied from the Linux kernel. I copied vscnprintf and
scnprintf so we can change printf and vprintf to use the safe
implementation but still return the correct values.

(Simon Glass <sjg@chromium.org> modified this commit a little)

Signed-off-by: Sonny Rao <sonnyrao@chromium.org>

# 9785c905 02-Nov-2011 Simon Glass <sjg@chromium.org>

Move vsprintf functions into their own header

common.h is very large, so before changing the vsprintf functions, move the
prototypes into their own header file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 185f812c 19-Jan-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

doc: replace @return by Return:

Sphinx expects Return: and not @return to indicate a return value.

find . -name '*.c' -exec \
sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \;

find . -name '*.h' -exec \
sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \;

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

# 499f1844 20-Dec-2021 Samuel Dionne-Riel <samuel@dionne-riel.com>

lib: export vsscanf

The function was missing from exports, even though it loooks like the
intent of the implementation in sscanf.c was to have it exported.

Signed-off-by: Samuel Dionne-Riel <samuel@dionne-riel.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 4a255ea3 14-Oct-2021 Simon Glass <sjg@chromium.org>

lib: Add a function to convert a string to a hex value

Add an xtoa() function, similar to itoa() but for hex instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Artem Lapkin <email2tema@gmail.com>
Tested-by: Artem Lapkin <email2tema@gmail.com>

# 3bfb0f71 14-Oct-2021 Simon Glass <sjg@chromium.org>

lib: Add tests for simple_itoa()

Add test and a comment for this function.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Artem Lapkin <email2tema@gmail.com>

# e6951139 24-Jul-2021 Simon Glass <sjg@chromium.org>

lib: Allow using 0x when a decimal value is requested

U-Boot mostly uses hex for value input, largely because addresses are much
easier to understand in hex.

But in some cases a decimal value is requested, such as where the value is
small or hex does not make sense in the context. In these cases it is
sometimes useful to be able to provide a hex value in any case, if only to
resolve any ambiguity.

Add this functionality, for increased flexibility.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 18546f29 24-Jul-2021 Simon Glass <sjg@chromium.org>

lib: Comment the base parameter with simple_strtoul/l()

This parameter is not documented properly since it does not cover the
meaning when the base is 0. Update this in both functions.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0b1284eb 24-Jul-2021 Simon Glass <sjg@chromium.org>

global: Convert simple_strtoul() with decimal to dectoul()

It is a pain to have to specify the value 10 in each call. Add a new
dectoul() function and update the code to use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 7e5f460e 24-Jul-2021 Simon Glass <sjg@chromium.org>

global: Convert simple_strtoul() with hex to hextoul()

It is a pain to have to specify the value 16 in each call. Add a new
hextoul() function and update the code to use it.

Add a proper comment to simple_strtoul() while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0b016428 22-Jul-2021 Roland Gaudig <roland.gaudig@weidmueller.com>

lib: strto: add simple_strtoll function

Add simple_strtoll function for converting a string containing digits
into a long long int value.

Signed-off-by: Roland Gaudig <roland.gaudig@weidmueller.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# e87dfb05 05-Aug-2020 Andrii Anisov <andrii_anisov@epam.com>

lib: sscanf: add sscanf implementation

Port sscanf implementation from mini-os and introduce new
Kconfig option to enable it: CONFIG_SSCANF. Disable by default.

Signed-off-by: Andrii Anisov <andrii_anisov@epam.com>
Signed-off-by: Anastasiia Lukianenko <anastasiia_lukianenko@epam.com>
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>

# fdc79a6b 08-Apr-2020 Simon Glass <sjg@chromium.org>

lib: Add a function to convert a string to upper case

Add a helper function for this operation. Update the strtoul() tests to
check upper case as well.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 2189d5f1 14-Nov-2019 Simon Glass <sjg@chromium.org>

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>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# f7d6b896 15-Sep-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

vsprintf.h: include <linux/types.h>

This header uses ulong, size_t, loff_t.
Include <linux/types.h> to make this header self-contained.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

# de2de319 06-Sep-2017 Heinrich Schuchardt <xypron.glpk@gmx.de>

vsprintf: vsprintf does not have parameter size

The inline documentation of vsprintf mentions a parameter size
which does not exist in the function declaration.

int vsprintf(char *buf, const char *fmt, va_list args);

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 3450a859 23-Oct-2016 Vagrant Cascadian <vagrant@debian.org>

Fix spelling of "resetting".

Cover-Letter: Fixes several spelling errors for the words "resetting",
"extended", "occur", and "multiple".

Signed-off-by: Vagrant Cascadian <vagrant@debian.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# f272f1fc 05-Jul-2016 Maxime Ripard <maxime.ripard@free-electrons.com>

vsprintf: Include stdarg for va_list

vsprintf.h doesn't include the stdarg.h file, which means that it relies on
the files that include vsprintf.h to include stdarg.h as well.

Add an explicit include to avoid build errors when simply including that
file.

Acked-by: Simon Glass <sjg@chromium.org>
Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

# 947c626d 14-Jan-2016 Tom Rini <trini@konsulko.com>

vsprintf.c: Always enable CONFIG_SYS_VSNPRINTF

Enabling this function always removes some class of string saftey issues.
The size change here in general is about 400 bytes and this seems a reasonable
trade-off.

Cc: Peng Fan <peng.fan@nxp.com>
Cc: Peter Robinson <pbrobinson@gmail.com>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Adrian Alonso <aalonso@freescale.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# c4af6732 23-Jun-2015 Simon Glass <sjg@chromium.org>

lib: Add function to extract a number from the end of a string

Split out the code in fdtdec which finds a number at the end of a string. It
can be useful in other situations.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 09c32807 26-Apr-2015 Heiko Schocher <hs@denx.de>

mtd, nand: Move common functions from cmd_nand.c to common place

Move common functions from cmd_nand.c (for calculating offset
and size from cmdline paramter) to common place, so they could
used from other commands which use mtd partitions.

For onenand the arg_off_size() is left in common/cmd_onenand.c.
It should use now the common arg_off() function, but as I could
not test onenand I let it there ...

Signed-off-by: Heiko Schocher <hs@denx.de>
Acked-by: Scott Wood <scottwood@freescale.com>
Reviewed-by: Jagannadh Teki <jteki@openedev.com>

# 66312374 27-Feb-2015 Simon Glass <sjg@chromium.org>

dm: Add a panic_str() function to reduce code size

The printf() in panic() adds about 1.5KB of code size to SPL when compiled
with Thumb-2. Provide a smaller version that does not support printf()-style
arguments and use it in two commonly compiled places.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 3765b3e7 07-Oct-2013 Wolfgang Denk <wd@denx.de>

Coding Style cleanup: remove trailing white space

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# b8bcaa3a 11-Jun-2013 Simon Glass <sjg@chromium.org>

Add function to print a number with grouped digits

Move bootstage's numbering printing code into a generic place so that it can
be used by tracing also.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 71ec92b6 02-Nov-2011 Simon Glass <sjg@chromium.org>

vsprintf: Move function documentation into header file

Now that this is not in common.h, perhaps it is acceptable to move this
documentation into the header file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 046a37bd 02-Nov-2011 Sonny Rao <sonnyrao@chromium.org>

Add safe vsnprintf and snprintf library functions

From: Sonny Rao <sonnyrao@chromium.org>

These functions are useful in U-Boot because they allow a graceful failure
rather than an unpredictable stack overflow when printf() buffers are
exceeded.

Mostly copied from the Linux kernel. I copied vscnprintf and
scnprintf so we can change printf and vprintf to use the safe
implementation but still return the correct values.

(Simon Glass <sjg@chromium.org> modified this commit a little)

Signed-off-by: Sonny Rao <sonnyrao@chromium.org>

# 9785c905 02-Nov-2011 Simon Glass <sjg@chromium.org>

Move vsprintf functions into their own header

common.h is very large, so before changing the vsprintf functions, move the
prototypes into their own header file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 499f1844 20-Dec-2021 Samuel Dionne-Riel <samuel@dionne-riel.com>

lib: export vsscanf

The function was missing from exports, even though it loooks like the
intent of the implementation in sscanf.c was to have it exported.

Signed-off-by: Samuel Dionne-Riel <samuel@dionne-riel.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 4a255ea3 14-Oct-2021 Simon Glass <sjg@chromium.org>

lib: Add a function to convert a string to a hex value

Add an xtoa() function, similar to itoa() but for hex instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Artem Lapkin <email2tema@gmail.com>
Tested-by: Artem Lapkin <email2tema@gmail.com>

# 3bfb0f71 14-Oct-2021 Simon Glass <sjg@chromium.org>

lib: Add tests for simple_itoa()

Add test and a comment for this function.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Artem Lapkin <email2tema@gmail.com>

# e6951139 24-Jul-2021 Simon Glass <sjg@chromium.org>

lib: Allow using 0x when a decimal value is requested

U-Boot mostly uses hex for value input, largely because addresses are much
easier to understand in hex.

But in some cases a decimal value is requested, such as where the value is
small or hex does not make sense in the context. In these cases it is
sometimes useful to be able to provide a hex value in any case, if only to
resolve any ambiguity.

Add this functionality, for increased flexibility.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 18546f29 24-Jul-2021 Simon Glass <sjg@chromium.org>

lib: Comment the base parameter with simple_strtoul/l()

This parameter is not documented properly since it does not cover the
meaning when the base is 0. Update this in both functions.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0b1284eb 24-Jul-2021 Simon Glass <sjg@chromium.org>

global: Convert simple_strtoul() with decimal to dectoul()

It is a pain to have to specify the value 10 in each call. Add a new
dectoul() function and update the code to use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 7e5f460e 24-Jul-2021 Simon Glass <sjg@chromium.org>

global: Convert simple_strtoul() with hex to hextoul()

It is a pain to have to specify the value 16 in each call. Add a new
hextoul() function and update the code to use it.

Add a proper comment to simple_strtoul() while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0b016428 22-Jul-2021 Roland Gaudig <roland.gaudig@weidmueller.com>

lib: strto: add simple_strtoll function

Add simple_strtoll function for converting a string containing digits
into a long long int value.

Signed-off-by: Roland Gaudig <roland.gaudig@weidmueller.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# e87dfb05 05-Aug-2020 Andrii Anisov <andrii_anisov@epam.com>

lib: sscanf: add sscanf implementation

Port sscanf implementation from mini-os and introduce new
Kconfig option to enable it: CONFIG_SSCANF. Disable by default.

Signed-off-by: Andrii Anisov <andrii_anisov@epam.com>
Signed-off-by: Anastasiia Lukianenko <anastasiia_lukianenko@epam.com>
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>

# fdc79a6b 08-Apr-2020 Simon Glass <sjg@chromium.org>

lib: Add a function to convert a string to upper case

Add a helper function for this operation. Update the strtoul() tests to
check upper case as well.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 2189d5f1 14-Nov-2019 Simon Glass <sjg@chromium.org>

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>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# f7d6b896 15-Sep-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

vsprintf.h: include <linux/types.h>

This header uses ulong, size_t, loff_t.
Include <linux/types.h> to make this header self-contained.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

# de2de319 06-Sep-2017 Heinrich Schuchardt <xypron.glpk@gmx.de>

vsprintf: vsprintf does not have parameter size

The inline documentation of vsprintf mentions a parameter size
which does not exist in the function declaration.

int vsprintf(char *buf, const char *fmt, va_list args);

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 3450a859 23-Oct-2016 Vagrant Cascadian <vagrant@debian.org>

Fix spelling of "resetting".

Cover-Letter: Fixes several spelling errors for the words "resetting",
"extended", "occur", and "multiple".

Signed-off-by: Vagrant Cascadian <vagrant@debian.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# f272f1fc 05-Jul-2016 Maxime Ripard <maxime.ripard@free-electrons.com>

vsprintf: Include stdarg for va_list

vsprintf.h doesn't include the stdarg.h file, which means that it relies on
the files that include vsprintf.h to include stdarg.h as well.

Add an explicit include to avoid build errors when simply including that
file.

Acked-by: Simon Glass <sjg@chromium.org>
Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

# 947c626d 14-Jan-2016 Tom Rini <trini@konsulko.com>

vsprintf.c: Always enable CONFIG_SYS_VSNPRINTF

Enabling this function always removes some class of string saftey issues.
The size change here in general is about 400 bytes and this seems a reasonable
trade-off.

Cc: Peng Fan <peng.fan@nxp.com>
Cc: Peter Robinson <pbrobinson@gmail.com>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Adrian Alonso <aalonso@freescale.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# c4af6732 23-Jun-2015 Simon Glass <sjg@chromium.org>

lib: Add function to extract a number from the end of a string

Split out the code in fdtdec which finds a number at the end of a string. It
can be useful in other situations.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 09c32807 26-Apr-2015 Heiko Schocher <hs@denx.de>

mtd, nand: Move common functions from cmd_nand.c to common place

Move common functions from cmd_nand.c (for calculating offset
and size from cmdline paramter) to common place, so they could
used from other commands which use mtd partitions.

For onenand the arg_off_size() is left in common/cmd_onenand.c.
It should use now the common arg_off() function, but as I could
not test onenand I let it there ...

Signed-off-by: Heiko Schocher <hs@denx.de>
Acked-by: Scott Wood <scottwood@freescale.com>
Reviewed-by: Jagannadh Teki <jteki@openedev.com>

# 66312374 27-Feb-2015 Simon Glass <sjg@chromium.org>

dm: Add a panic_str() function to reduce code size

The printf() in panic() adds about 1.5KB of code size to SPL when compiled
with Thumb-2. Provide a smaller version that does not support printf()-style
arguments and use it in two commonly compiled places.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 3765b3e7 07-Oct-2013 Wolfgang Denk <wd@denx.de>

Coding Style cleanup: remove trailing white space

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# b8bcaa3a 11-Jun-2013 Simon Glass <sjg@chromium.org>

Add function to print a number with grouped digits

Move bootstage's numbering printing code into a generic place so that it can
be used by tracing also.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 71ec92b6 02-Nov-2011 Simon Glass <sjg@chromium.org>

vsprintf: Move function documentation into header file

Now that this is not in common.h, perhaps it is acceptable to move this
documentation into the header file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 046a37bd 02-Nov-2011 Sonny Rao <sonnyrao@chromium.org>

Add safe vsnprintf and snprintf library functions

From: Sonny Rao <sonnyrao@chromium.org>

These functions are useful in U-Boot because they allow a graceful failure
rather than an unpredictable stack overflow when printf() buffers are
exceeded.

Mostly copied from the Linux kernel. I copied vscnprintf and
scnprintf so we can change printf and vprintf to use the safe
implementation but still return the correct values.

(Simon Glass <sjg@chromium.org> modified this commit a little)

Signed-off-by: Sonny Rao <sonnyrao@chromium.org>

# 9785c905 02-Nov-2011 Simon Glass <sjg@chromium.org>

Move vsprintf functions into their own header

common.h is very large, so before changing the vsprintf functions, move the
prototypes into their own header file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4a255ea3 14-Oct-2021 Simon Glass <sjg@chromium.org>

lib: Add a function to convert a string to a hex value

Add an xtoa() function, similar to itoa() but for hex instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Artem Lapkin <email2tema@gmail.com>
Tested-by: Artem Lapkin <email2tema@gmail.com>

# 3bfb0f71 14-Oct-2021 Simon Glass <sjg@chromium.org>

lib: Add tests for simple_itoa()

Add test and a comment for this function.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Artem Lapkin <email2tema@gmail.com>

# e6951139 24-Jul-2021 Simon Glass <sjg@chromium.org>

lib: Allow using 0x when a decimal value is requested

U-Boot mostly uses hex for value input, largely because addresses are much
easier to understand in hex.

But in some cases a decimal value is requested, such as where the value is
small or hex does not make sense in the context. In these cases it is
sometimes useful to be able to provide a hex value in any case, if only to
resolve any ambiguity.

Add this functionality, for increased flexibility.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 18546f29 24-Jul-2021 Simon Glass <sjg@chromium.org>

lib: Comment the base parameter with simple_strtoul/l()

This parameter is not documented properly since it does not cover the
meaning when the base is 0. Update this in both functions.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0b1284eb 24-Jul-2021 Simon Glass <sjg@chromium.org>

global: Convert simple_strtoul() with decimal to dectoul()

It is a pain to have to specify the value 10 in each call. Add a new
dectoul() function and update the code to use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 7e5f460e 24-Jul-2021 Simon Glass <sjg@chromium.org>

global: Convert simple_strtoul() with hex to hextoul()

It is a pain to have to specify the value 16 in each call. Add a new
hextoul() function and update the code to use it.

Add a proper comment to simple_strtoul() while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0b016428 22-Jul-2021 Roland Gaudig <roland.gaudig@weidmueller.com>

lib: strto: add simple_strtoll function

Add simple_strtoll function for converting a string containing digits
into a long long int value.

Signed-off-by: Roland Gaudig <roland.gaudig@weidmueller.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# e87dfb05 05-Aug-2020 Andrii Anisov <andrii_anisov@epam.com>

lib: sscanf: add sscanf implementation

Port sscanf implementation from mini-os and introduce new
Kconfig option to enable it: CONFIG_SSCANF. Disable by default.

Signed-off-by: Andrii Anisov <andrii_anisov@epam.com>
Signed-off-by: Anastasiia Lukianenko <anastasiia_lukianenko@epam.com>
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>

# fdc79a6b 08-Apr-2020 Simon Glass <sjg@chromium.org>

lib: Add a function to convert a string to upper case

Add a helper function for this operation. Update the strtoul() tests to
check upper case as well.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 2189d5f1 14-Nov-2019 Simon Glass <sjg@chromium.org>

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>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# f7d6b896 15-Sep-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

vsprintf.h: include <linux/types.h>

This header uses ulong, size_t, loff_t.
Include <linux/types.h> to make this header self-contained.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

# de2de319 06-Sep-2017 Heinrich Schuchardt <xypron.glpk@gmx.de>

vsprintf: vsprintf does not have parameter size

The inline documentation of vsprintf mentions a parameter size
which does not exist in the function declaration.

int vsprintf(char *buf, const char *fmt, va_list args);

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 3450a859 23-Oct-2016 Vagrant Cascadian <vagrant@debian.org>

Fix spelling of "resetting".

Cover-Letter: Fixes several spelling errors for the words "resetting",
"extended", "occur", and "multiple".

Signed-off-by: Vagrant Cascadian <vagrant@debian.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# f272f1fc 05-Jul-2016 Maxime Ripard <maxime.ripard@free-electrons.com>

vsprintf: Include stdarg for va_list

vsprintf.h doesn't include the stdarg.h file, which means that it relies on
the files that include vsprintf.h to include stdarg.h as well.

Add an explicit include to avoid build errors when simply including that
file.

Acked-by: Simon Glass <sjg@chromium.org>
Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

# 947c626d 14-Jan-2016 Tom Rini <trini@konsulko.com>

vsprintf.c: Always enable CONFIG_SYS_VSNPRINTF

Enabling this function always removes some class of string saftey issues.
The size change here in general is about 400 bytes and this seems a reasonable
trade-off.

Cc: Peng Fan <peng.fan@nxp.com>
Cc: Peter Robinson <pbrobinson@gmail.com>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Adrian Alonso <aalonso@freescale.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# c4af6732 23-Jun-2015 Simon Glass <sjg@chromium.org>

lib: Add function to extract a number from the end of a string

Split out the code in fdtdec which finds a number at the end of a string. It
can be useful in other situations.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 09c32807 26-Apr-2015 Heiko Schocher <hs@denx.de>

mtd, nand: Move common functions from cmd_nand.c to common place

Move common functions from cmd_nand.c (for calculating offset
and size from cmdline paramter) to common place, so they could
used from other commands which use mtd partitions.

For onenand the arg_off_size() is left in common/cmd_onenand.c.
It should use now the common arg_off() function, but as I could
not test onenand I let it there ...

Signed-off-by: Heiko Schocher <hs@denx.de>
Acked-by: Scott Wood <scottwood@freescale.com>
Reviewed-by: Jagannadh Teki <jteki@openedev.com>

# 66312374 27-Feb-2015 Simon Glass <sjg@chromium.org>

dm: Add a panic_str() function to reduce code size

The printf() in panic() adds about 1.5KB of code size to SPL when compiled
with Thumb-2. Provide a smaller version that does not support printf()-style
arguments and use it in two commonly compiled places.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 3765b3e7 07-Oct-2013 Wolfgang Denk <wd@denx.de>

Coding Style cleanup: remove trailing white space

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# b8bcaa3a 11-Jun-2013 Simon Glass <sjg@chromium.org>

Add function to print a number with grouped digits

Move bootstage's numbering printing code into a generic place so that it can
be used by tracing also.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 71ec92b6 02-Nov-2011 Simon Glass <sjg@chromium.org>

vsprintf: Move function documentation into header file

Now that this is not in common.h, perhaps it is acceptable to move this
documentation into the header file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 046a37bd 02-Nov-2011 Sonny Rao <sonnyrao@chromium.org>

Add safe vsnprintf and snprintf library functions

From: Sonny Rao <sonnyrao@chromium.org>

These functions are useful in U-Boot because they allow a graceful failure
rather than an unpredictable stack overflow when printf() buffers are
exceeded.

Mostly copied from the Linux kernel. I copied vscnprintf and
scnprintf so we can change printf and vprintf to use the safe
implementation but still return the correct values.

(Simon Glass <sjg@chromium.org> modified this commit a little)

Signed-off-by: Sonny Rao <sonnyrao@chromium.org>

# 9785c905 02-Nov-2011 Simon Glass <sjg@chromium.org>

Move vsprintf functions into their own header

common.h is very large, so before changing the vsprintf functions, move the
prototypes into their own header file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e6951139 24-Jul-2021 Simon Glass <sjg@chromium.org>

lib: Allow using 0x when a decimal value is requested

U-Boot mostly uses hex for value input, largely because addresses are much
easier to understand in hex.

But in some cases a decimal value is requested, such as where the value is
small or hex does not make sense in the context. In these cases it is
sometimes useful to be able to provide a hex value in any case, if only to
resolve any ambiguity.

Add this functionality, for increased flexibility.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 18546f29 24-Jul-2021 Simon Glass <sjg@chromium.org>

lib: Comment the base parameter with simple_strtoul/l()

This parameter is not documented properly since it does not cover the
meaning when the base is 0. Update this in both functions.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0b1284eb 24-Jul-2021 Simon Glass <sjg@chromium.org>

global: Convert simple_strtoul() with decimal to dectoul()

It is a pain to have to specify the value 10 in each call. Add a new
dectoul() function and update the code to use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 7e5f460e 24-Jul-2021 Simon Glass <sjg@chromium.org>

global: Convert simple_strtoul() with hex to hextoul()

It is a pain to have to specify the value 16 in each call. Add a new
hextoul() function and update the code to use it.

Add a proper comment to simple_strtoul() while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0b016428 22-Jul-2021 Roland Gaudig <roland.gaudig@weidmueller.com>

lib: strto: add simple_strtoll function

Add simple_strtoll function for converting a string containing digits
into a long long int value.

Signed-off-by: Roland Gaudig <roland.gaudig@weidmueller.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# e87dfb05 05-Aug-2020 Andrii Anisov <andrii_anisov@epam.com>

lib: sscanf: add sscanf implementation

Port sscanf implementation from mini-os and introduce new
Kconfig option to enable it: CONFIG_SSCANF. Disable by default.

Signed-off-by: Andrii Anisov <andrii_anisov@epam.com>
Signed-off-by: Anastasiia Lukianenko <anastasiia_lukianenko@epam.com>
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>

# fdc79a6b 08-Apr-2020 Simon Glass <sjg@chromium.org>

lib: Add a function to convert a string to upper case

Add a helper function for this operation. Update the strtoul() tests to
check upper case as well.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 2189d5f1 14-Nov-2019 Simon Glass <sjg@chromium.org>

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>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# f7d6b896 15-Sep-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

vsprintf.h: include <linux/types.h>

This header uses ulong, size_t, loff_t.
Include <linux/types.h> to make this header self-contained.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

# de2de319 06-Sep-2017 Heinrich Schuchardt <xypron.glpk@gmx.de>

vsprintf: vsprintf does not have parameter size

The inline documentation of vsprintf mentions a parameter size
which does not exist in the function declaration.

int vsprintf(char *buf, const char *fmt, va_list args);

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 3450a859 23-Oct-2016 Vagrant Cascadian <vagrant@debian.org>

Fix spelling of "resetting".

Cover-Letter: Fixes several spelling errors for the words "resetting",
"extended", "occur", and "multiple".

Signed-off-by: Vagrant Cascadian <vagrant@debian.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# f272f1fc 05-Jul-2016 Maxime Ripard <maxime.ripard@free-electrons.com>

vsprintf: Include stdarg for va_list

vsprintf.h doesn't include the stdarg.h file, which means that it relies on
the files that include vsprintf.h to include stdarg.h as well.

Add an explicit include to avoid build errors when simply including that
file.

Acked-by: Simon Glass <sjg@chromium.org>
Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

# 947c626d 14-Jan-2016 Tom Rini <trini@konsulko.com>

vsprintf.c: Always enable CONFIG_SYS_VSNPRINTF

Enabling this function always removes some class of string saftey issues.
The size change here in general is about 400 bytes and this seems a reasonable
trade-off.

Cc: Peng Fan <peng.fan@nxp.com>
Cc: Peter Robinson <pbrobinson@gmail.com>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Adrian Alonso <aalonso@freescale.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# c4af6732 23-Jun-2015 Simon Glass <sjg@chromium.org>

lib: Add function to extract a number from the end of a string

Split out the code in fdtdec which finds a number at the end of a string. It
can be useful in other situations.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 09c32807 26-Apr-2015 Heiko Schocher <hs@denx.de>

mtd, nand: Move common functions from cmd_nand.c to common place

Move common functions from cmd_nand.c (for calculating offset
and size from cmdline paramter) to common place, so they could
used from other commands which use mtd partitions.

For onenand the arg_off_size() is left in common/cmd_onenand.c.
It should use now the common arg_off() function, but as I could
not test onenand I let it there ...

Signed-off-by: Heiko Schocher <hs@denx.de>
Acked-by: Scott Wood <scottwood@freescale.com>
Reviewed-by: Jagannadh Teki <jteki@openedev.com>

# 66312374 27-Feb-2015 Simon Glass <sjg@chromium.org>

dm: Add a panic_str() function to reduce code size

The printf() in panic() adds about 1.5KB of code size to SPL when compiled
with Thumb-2. Provide a smaller version that does not support printf()-style
arguments and use it in two commonly compiled places.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 3765b3e7 07-Oct-2013 Wolfgang Denk <wd@denx.de>

Coding Style cleanup: remove trailing white space

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# b8bcaa3a 11-Jun-2013 Simon Glass <sjg@chromium.org>

Add function to print a number with grouped digits

Move bootstage's numbering printing code into a generic place so that it can
be used by tracing also.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 71ec92b6 02-Nov-2011 Simon Glass <sjg@chromium.org>

vsprintf: Move function documentation into header file

Now that this is not in common.h, perhaps it is acceptable to move this
documentation into the header file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 046a37bd 02-Nov-2011 Sonny Rao <sonnyrao@chromium.org>

Add safe vsnprintf and snprintf library functions

From: Sonny Rao <sonnyrao@chromium.org>

These functions are useful in U-Boot because they allow a graceful failure
rather than an unpredictable stack overflow when printf() buffers are
exceeded.

Mostly copied from the Linux kernel. I copied vscnprintf and
scnprintf so we can change printf and vprintf to use the safe
implementation but still return the correct values.

(Simon Glass <sjg@chromium.org> modified this commit a little)

Signed-off-by: Sonny Rao <sonnyrao@chromium.org>

# 9785c905 02-Nov-2011 Simon Glass <sjg@chromium.org>

Move vsprintf functions into their own header

common.h is very large, so before changing the vsprintf functions, move the
prototypes into their own header file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0b016428 22-Jul-2021 Roland Gaudig <roland.gaudig@weidmueller.com>

lib: strto: add simple_strtoll function

Add simple_strtoll function for converting a string containing digits
into a long long int value.

Signed-off-by: Roland Gaudig <roland.gaudig@weidmueller.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# e87dfb05 05-Aug-2020 Andrii Anisov <andrii_anisov@epam.com>

lib: sscanf: add sscanf implementation

Port sscanf implementation from mini-os and introduce new
Kconfig option to enable it: CONFIG_SSCANF. Disable by default.

Signed-off-by: Andrii Anisov <andrii_anisov@epam.com>
Signed-off-by: Anastasiia Lukianenko <anastasiia_lukianenko@epam.com>
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>

# fdc79a6b 08-Apr-2020 Simon Glass <sjg@chromium.org>

lib: Add a function to convert a string to upper case

Add a helper function for this operation. Update the strtoul() tests to
check upper case as well.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 2189d5f1 14-Nov-2019 Simon Glass <sjg@chromium.org>

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>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# f7d6b896 15-Sep-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

vsprintf.h: include <linux/types.h>

This header uses ulong, size_t, loff_t.
Include <linux/types.h> to make this header self-contained.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

# de2de319 06-Sep-2017 Heinrich Schuchardt <xypron.glpk@gmx.de>

vsprintf: vsprintf does not have parameter size

The inline documentation of vsprintf mentions a parameter size
which does not exist in the function declaration.

int vsprintf(char *buf, const char *fmt, va_list args);

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 3450a859 23-Oct-2016 Vagrant Cascadian <vagrant@debian.org>

Fix spelling of "resetting".

Cover-Letter: Fixes several spelling errors for the words "resetting",
"extended", "occur", and "multiple".

Signed-off-by: Vagrant Cascadian <vagrant@debian.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# f272f1fc 05-Jul-2016 Maxime Ripard <maxime.ripard@free-electrons.com>

vsprintf: Include stdarg for va_list

vsprintf.h doesn't include the stdarg.h file, which means that it relies on
the files that include vsprintf.h to include stdarg.h as well.

Add an explicit include to avoid build errors when simply including that
file.

Acked-by: Simon Glass <sjg@chromium.org>
Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

# 947c626d 14-Jan-2016 Tom Rini <trini@konsulko.com>

vsprintf.c: Always enable CONFIG_SYS_VSNPRINTF

Enabling this function always removes some class of string saftey issues.
The size change here in general is about 400 bytes and this seems a reasonable
trade-off.

Cc: Peng Fan <peng.fan@nxp.com>
Cc: Peter Robinson <pbrobinson@gmail.com>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Adrian Alonso <aalonso@freescale.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# c4af6732 23-Jun-2015 Simon Glass <sjg@chromium.org>

lib: Add function to extract a number from the end of a string

Split out the code in fdtdec which finds a number at the end of a string. It
can be useful in other situations.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 09c32807 26-Apr-2015 Heiko Schocher <hs@denx.de>

mtd, nand: Move common functions from cmd_nand.c to common place

Move common functions from cmd_nand.c (for calculating offset
and size from cmdline paramter) to common place, so they could
used from other commands which use mtd partitions.

For onenand the arg_off_size() is left in common/cmd_onenand.c.
It should use now the common arg_off() function, but as I could
not test onenand I let it there ...

Signed-off-by: Heiko Schocher <hs@denx.de>
Acked-by: Scott Wood <scottwood@freescale.com>
Reviewed-by: Jagannadh Teki <jteki@openedev.com>

# 66312374 27-Feb-2015 Simon Glass <sjg@chromium.org>

dm: Add a panic_str() function to reduce code size

The printf() in panic() adds about 1.5KB of code size to SPL when compiled
with Thumb-2. Provide a smaller version that does not support printf()-style
arguments and use it in two commonly compiled places.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 3765b3e7 07-Oct-2013 Wolfgang Denk <wd@denx.de>

Coding Style cleanup: remove trailing white space

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# b8bcaa3a 11-Jun-2013 Simon Glass <sjg@chromium.org>

Add function to print a number with grouped digits

Move bootstage's numbering printing code into a generic place so that it can
be used by tracing also.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 71ec92b6 02-Nov-2011 Simon Glass <sjg@chromium.org>

vsprintf: Move function documentation into header file

Now that this is not in common.h, perhaps it is acceptable to move this
documentation into the header file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 046a37bd 02-Nov-2011 Sonny Rao <sonnyrao@chromium.org>

Add safe vsnprintf and snprintf library functions

From: Sonny Rao <sonnyrao@chromium.org>

These functions are useful in U-Boot because they allow a graceful failure
rather than an unpredictable stack overflow when printf() buffers are
exceeded.

Mostly copied from the Linux kernel. I copied vscnprintf and
scnprintf so we can change printf and vprintf to use the safe
implementation but still return the correct values.

(Simon Glass <sjg@chromium.org> modified this commit a little)

Signed-off-by: Sonny Rao <sonnyrao@chromium.org>

# 9785c905 02-Nov-2011 Simon Glass <sjg@chromium.org>

Move vsprintf functions into their own header

common.h is very large, so before changing the vsprintf functions, move the
prototypes into their own header file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e87dfb05 05-Aug-2020 Andrii Anisov <andrii_anisov@epam.com>

lib: sscanf: add sscanf implementation

Port sscanf implementation from mini-os and introduce new
Kconfig option to enable it: CONFIG_SSCANF. Disable by default.

Signed-off-by: Andrii Anisov <andrii_anisov@epam.com>
Signed-off-by: Anastasiia Lukianenko <anastasiia_lukianenko@epam.com>
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>

# fdc79a6b 08-Apr-2020 Simon Glass <sjg@chromium.org>

lib: Add a function to convert a string to upper case

Add a helper function for this operation. Update the strtoul() tests to
check upper case as well.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 2189d5f1 14-Nov-2019 Simon Glass <sjg@chromium.org>

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>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# f7d6b896 15-Sep-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

vsprintf.h: include <linux/types.h>

This header uses ulong, size_t, loff_t.
Include <linux/types.h> to make this header self-contained.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

# de2de319 06-Sep-2017 Heinrich Schuchardt <xypron.glpk@gmx.de>

vsprintf: vsprintf does not have parameter size

The inline documentation of vsprintf mentions a parameter size
which does not exist in the function declaration.

int vsprintf(char *buf, const char *fmt, va_list args);

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 3450a859 23-Oct-2016 Vagrant Cascadian <vagrant@debian.org>

Fix spelling of "resetting".

Cover-Letter: Fixes several spelling errors for the words "resetting",
"extended", "occur", and "multiple".

Signed-off-by: Vagrant Cascadian <vagrant@debian.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# f272f1fc 05-Jul-2016 Maxime Ripard <maxime.ripard@free-electrons.com>

vsprintf: Include stdarg for va_list

vsprintf.h doesn't include the stdarg.h file, which means that it relies on
the files that include vsprintf.h to include stdarg.h as well.

Add an explicit include to avoid build errors when simply including that
file.

Acked-by: Simon Glass <sjg@chromium.org>
Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

# 947c626d 14-Jan-2016 Tom Rini <trini@konsulko.com>

vsprintf.c: Always enable CONFIG_SYS_VSNPRINTF

Enabling this function always removes some class of string saftey issues.
The size change here in general is about 400 bytes and this seems a reasonable
trade-off.

Cc: Peng Fan <peng.fan@nxp.com>
Cc: Peter Robinson <pbrobinson@gmail.com>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Adrian Alonso <aalonso@freescale.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# c4af6732 23-Jun-2015 Simon Glass <sjg@chromium.org>

lib: Add function to extract a number from the end of a string

Split out the code in fdtdec which finds a number at the end of a string. It
can be useful in other situations.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 09c32807 26-Apr-2015 Heiko Schocher <hs@denx.de>

mtd, nand: Move common functions from cmd_nand.c to common place

Move common functions from cmd_nand.c (for calculating offset
and size from cmdline paramter) to common place, so they could
used from other commands which use mtd partitions.

For onenand the arg_off_size() is left in common/cmd_onenand.c.
It should use now the common arg_off() function, but as I could
not test onenand I let it there ...

Signed-off-by: Heiko Schocher <hs@denx.de>
Acked-by: Scott Wood <scottwood@freescale.com>
Reviewed-by: Jagannadh Teki <jteki@openedev.com>

# 66312374 27-Feb-2015 Simon Glass <sjg@chromium.org>

dm: Add a panic_str() function to reduce code size

The printf() in panic() adds about 1.5KB of code size to SPL when compiled
with Thumb-2. Provide a smaller version that does not support printf()-style
arguments and use it in two commonly compiled places.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 3765b3e7 07-Oct-2013 Wolfgang Denk <wd@denx.de>

Coding Style cleanup: remove trailing white space

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# b8bcaa3a 11-Jun-2013 Simon Glass <sjg@chromium.org>

Add function to print a number with grouped digits

Move bootstage's numbering printing code into a generic place so that it can
be used by tracing also.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 71ec92b6 02-Nov-2011 Simon Glass <sjg@chromium.org>

vsprintf: Move function documentation into header file

Now that this is not in common.h, perhaps it is acceptable to move this
documentation into the header file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 046a37bd 02-Nov-2011 Sonny Rao <sonnyrao@chromium.org>

Add safe vsnprintf and snprintf library functions

From: Sonny Rao <sonnyrao@chromium.org>

These functions are useful in U-Boot because they allow a graceful failure
rather than an unpredictable stack overflow when printf() buffers are
exceeded.

Mostly copied from the Linux kernel. I copied vscnprintf and
scnprintf so we can change printf and vprintf to use the safe
implementation but still return the correct values.

(Simon Glass <sjg@chromium.org> modified this commit a little)

Signed-off-by: Sonny Rao <sonnyrao@chromium.org>

# 9785c905 02-Nov-2011 Simon Glass <sjg@chromium.org>

Move vsprintf functions into their own header

common.h is very large, so before changing the vsprintf functions, move the
prototypes into their own header file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# fdc79a6b 08-Apr-2020 Simon Glass <sjg@chromium.org>

lib: Add a function to convert a string to upper case

Add a helper function for this operation. Update the strtoul() tests to
check upper case as well.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 2189d5f1 14-Nov-2019 Simon Glass <sjg@chromium.org>

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>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# f7d6b896 15-Sep-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

vsprintf.h: include <linux/types.h>

This header uses ulong, size_t, loff_t.
Include <linux/types.h> to make this header self-contained.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

# de2de319 06-Sep-2017 Heinrich Schuchardt <xypron.glpk@gmx.de>

vsprintf: vsprintf does not have parameter size

The inline documentation of vsprintf mentions a parameter size
which does not exist in the function declaration.

int vsprintf(char *buf, const char *fmt, va_list args);

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 3450a859 23-Oct-2016 Vagrant Cascadian <vagrant@debian.org>

Fix spelling of "resetting".

Cover-Letter: Fixes several spelling errors for the words "resetting",
"extended", "occur", and "multiple".

Signed-off-by: Vagrant Cascadian <vagrant@debian.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# f272f1fc 05-Jul-2016 Maxime Ripard <maxime.ripard@free-electrons.com>

vsprintf: Include stdarg for va_list

vsprintf.h doesn't include the stdarg.h file, which means that it relies on
the files that include vsprintf.h to include stdarg.h as well.

Add an explicit include to avoid build errors when simply including that
file.

Acked-by: Simon Glass <sjg@chromium.org>
Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

# 947c626d 14-Jan-2016 Tom Rini <trini@konsulko.com>

vsprintf.c: Always enable CONFIG_SYS_VSNPRINTF

Enabling this function always removes some class of string saftey issues.
The size change here in general is about 400 bytes and this seems a reasonable
trade-off.

Cc: Peng Fan <peng.fan@nxp.com>
Cc: Peter Robinson <pbrobinson@gmail.com>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Adrian Alonso <aalonso@freescale.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# c4af6732 23-Jun-2015 Simon Glass <sjg@chromium.org>

lib: Add function to extract a number from the end of a string

Split out the code in fdtdec which finds a number at the end of a string. It
can be useful in other situations.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 09c32807 26-Apr-2015 Heiko Schocher <hs@denx.de>

mtd, nand: Move common functions from cmd_nand.c to common place

Move common functions from cmd_nand.c (for calculating offset
and size from cmdline paramter) to common place, so they could
used from other commands which use mtd partitions.

For onenand the arg_off_size() is left in common/cmd_onenand.c.
It should use now the common arg_off() function, but as I could
not test onenand I let it there ...

Signed-off-by: Heiko Schocher <hs@denx.de>
Acked-by: Scott Wood <scottwood@freescale.com>
Reviewed-by: Jagannadh Teki <jteki@openedev.com>

# 66312374 27-Feb-2015 Simon Glass <sjg@chromium.org>

dm: Add a panic_str() function to reduce code size

The printf() in panic() adds about 1.5KB of code size to SPL when compiled
with Thumb-2. Provide a smaller version that does not support printf()-style
arguments and use it in two commonly compiled places.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 3765b3e7 07-Oct-2013 Wolfgang Denk <wd@denx.de>

Coding Style cleanup: remove trailing white space

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# b8bcaa3a 11-Jun-2013 Simon Glass <sjg@chromium.org>

Add function to print a number with grouped digits

Move bootstage's numbering printing code into a generic place so that it can
be used by tracing also.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 71ec92b6 02-Nov-2011 Simon Glass <sjg@chromium.org>

vsprintf: Move function documentation into header file

Now that this is not in common.h, perhaps it is acceptable to move this
documentation into the header file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 046a37bd 02-Nov-2011 Sonny Rao <sonnyrao@chromium.org>

Add safe vsnprintf and snprintf library functions

From: Sonny Rao <sonnyrao@chromium.org>

These functions are useful in U-Boot because they allow a graceful failure
rather than an unpredictable stack overflow when printf() buffers are
exceeded.

Mostly copied from the Linux kernel. I copied vscnprintf and
scnprintf so we can change printf and vprintf to use the safe
implementation but still return the correct values.

(Simon Glass <sjg@chromium.org> modified this commit a little)

Signed-off-by: Sonny Rao <sonnyrao@chromium.org>

# 9785c905 02-Nov-2011 Simon Glass <sjg@chromium.org>

Move vsprintf functions into their own header

common.h is very large, so before changing the vsprintf functions, move the
prototypes into their own header file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 2189d5f1 14-Nov-2019 Simon Glass <sjg@chromium.org>

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>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# f7d6b896 15-Sep-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

vsprintf.h: include <linux/types.h>

This header uses ulong, size_t, loff_t.
Include <linux/types.h> to make this header self-contained.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

# de2de319 06-Sep-2017 Heinrich Schuchardt <xypron.glpk@gmx.de>

vsprintf: vsprintf does not have parameter size

The inline documentation of vsprintf mentions a parameter size
which does not exist in the function declaration.

int vsprintf(char *buf, const char *fmt, va_list args);

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

# 3450a859 23-Oct-2016 Vagrant Cascadian <vagrant@debian.org>

Fix spelling of "resetting".

Cover-Letter: Fixes several spelling errors for the words "resetting",
"extended", "occur", and "multiple".

Signed-off-by: Vagrant Cascadian <vagrant@debian.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# f272f1fc 05-Jul-2016 Maxime Ripard <maxime.ripard@free-electrons.com>

vsprintf: Include stdarg for va_list

vsprintf.h doesn't include the stdarg.h file, which means that it relies on
the files that include vsprintf.h to include stdarg.h as well.

Add an explicit include to avoid build errors when simply including that
file.

Acked-by: Simon Glass <sjg@chromium.org>
Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>

# 947c626d 14-Jan-2016 Tom Rini <trini@konsulko.com>

vsprintf.c: Always enable CONFIG_SYS_VSNPRINTF

Enabling this function always removes some class of string saftey issues.
The size change here in general is about 400 bytes and this seems a reasonable
trade-off.

Cc: Peng Fan <peng.fan@nxp.com>
Cc: Peter Robinson <pbrobinson@gmail.com>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Adrian Alonso <aalonso@freescale.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# c4af6732 23-Jun-2015 Simon Glass <sjg@chromium.org>

lib: Add function to extract a number from the end of a string

Split out the code in fdtdec which finds a number at the end of a string. It
can be useful in other situations.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 09c32807 26-Apr-2015 Heiko Schocher <hs@denx.de>

mtd, nand: Move common functions from cmd_nand.c to common place

Move common functions from cmd_nand.c (for calculating offset
and size from cmdline paramter) to common place, so they could
used from other commands which use mtd partitions.

For onenand the arg_off_size() is left in common/cmd_onenand.c.
It should use now the common arg_off() function, but as I could
not test onenand I let it there ...

Signed-off-by: Heiko Schocher <hs@denx.de>
Acked-by: Scott Wood <scottwood@freescale.com>
Reviewed-by: Jagannadh Teki <jteki@openedev.com>

# 66312374 27-Feb-2015 Simon Glass <sjg@chromium.org>

dm: Add a panic_str() function to reduce code size

The printf() in panic() adds about 1.5KB of code size to SPL when compiled
with Thumb-2. Provide a smaller version that does not support printf()-style
arguments and use it in two commonly compiled places.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 3765b3e7 07-Oct-2013 Wolfgang Denk <wd@denx.de>

Coding Style cleanup: remove trailing white space

Signed-off-by: Wolfgang Denk <wd@denx.de>

# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>

# b8bcaa3a 11-Jun-2013 Simon Glass <sjg@chromium.org>

Add function to print a number with grouped digits

Move bootstage's numbering printing code into a generic place so that it can
be used by tracing also.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 71ec92b6 02-Nov-2011 Simon Glass <sjg@chromium.org>

vsprintf: Move function documentation into header file

Now that this is not in common.h, perhaps it is acceptable to move this
documentation into the header file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 046a37bd 02-Nov-2011 Sonny Rao <sonnyrao@chromium.org>

Add safe vsnprintf and snprintf library functions

From: Sonny Rao <sonnyrao@chromium.org>

These functions are useful in U-Boot because they allow a graceful failure
rather than an unpredictable stack overflow when printf() buffers are
exceeded.

Mostly copied from the Linux kernel. I copied vscnprintf and
scnprintf so we can change printf and vprintf to use the safe
implementation but still return the correct values.

(Simon Glass <sjg@chromium.org> modified this commit a little)

Signed-off-by: Sonny Rao <sonnyrao@chromium.org>

# 9785c905 02-Nov-2011 Simon Glass <sjg@chromium.org>

Move vsprintf functions into their own header

common.h is very large, so before changing the vsprintf functions, move the
prototypes into their own header file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>


# f7d6b896 15-Sep-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

vsprintf.h: include <linux/types.h>

This header uses ulong, size_t, loff_t.
Include <linux/types.h> to make this header self-contained.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# de2de319 06-Sep-2017 Heinrich Schuchardt <xypron.glpk@gmx.de>

vsprintf: vsprintf does not have parameter size

The inline documentation of vsprintf mentions a parameter size
which does not exist in the function declaration.

int vsprintf(char *buf, const char *fmt, va_list args);

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>


# 3450a859 23-Oct-2016 Vagrant Cascadian <vagrant@debian.org>

Fix spelling of "resetting".

Cover-Letter: Fixes several spelling errors for the words "resetting",
"extended", "occur", and "multiple".

Signed-off-by: Vagrant Cascadian <vagrant@debian.org>
Reviewed-by: Simon Glass <sjg@chromium.org>


# f272f1fc 05-Jul-2016 Maxime Ripard <maxime.ripard@free-electrons.com>

vsprintf: Include stdarg for va_list

vsprintf.h doesn't include the stdarg.h file, which means that it relies on
the files that include vsprintf.h to include stdarg.h as well.

Add an explicit include to avoid build errors when simply including that
file.

Acked-by: Simon Glass <sjg@chromium.org>
Acked-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>


# 947c626d 14-Jan-2016 Tom Rini <trini@konsulko.com>

vsprintf.c: Always enable CONFIG_SYS_VSNPRINTF

Enabling this function always removes some class of string saftey issues.
The size change here in general is about 400 bytes and this seems a reasonable
trade-off.

Cc: Peng Fan <peng.fan@nxp.com>
Cc: Peter Robinson <pbrobinson@gmail.com>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Adrian Alonso <aalonso@freescale.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Tom Rini <trini@konsulko.com>


# c4af6732 23-Jun-2015 Simon Glass <sjg@chromium.org>

lib: Add function to extract a number from the end of a string

Split out the code in fdtdec which finds a number at the end of a string. It
can be useful in other situations.

Signed-off-by: Simon Glass <sjg@chromium.org>


# 09c32807 26-Apr-2015 Heiko Schocher <hs@denx.de>

mtd, nand: Move common functions from cmd_nand.c to common place

Move common functions from cmd_nand.c (for calculating offset
and size from cmdline paramter) to common place, so they could
used from other commands which use mtd partitions.

For onenand the arg_off_size() is left in common/cmd_onenand.c.
It should use now the common arg_off() function, but as I could
not test onenand I let it there ...

Signed-off-by: Heiko Schocher <hs@denx.de>
Acked-by: Scott Wood <scottwood@freescale.com>
Reviewed-by: Jagannadh Teki <jteki@openedev.com>


# 66312374 27-Feb-2015 Simon Glass <sjg@chromium.org>

dm: Add a panic_str() function to reduce code size

The printf() in panic() adds about 1.5KB of code size to SPL when compiled
with Thumb-2. Provide a smaller version that does not support printf()-style
arguments and use it in two commonly compiled places.

Signed-off-by: Simon Glass <sjg@chromium.org>


# 3765b3e7 07-Oct-2013 Wolfgang Denk <wd@denx.de>

Coding Style cleanup: remove trailing white space

Signed-off-by: Wolfgang Denk <wd@denx.de>


# 1a459660 08-Jul-2013 Wolfgang Denk <wd@denx.de>

Add GPL-2.0+ SPDX-License-Identifier to source files

Signed-off-by: Wolfgang Denk <wd@denx.de>
[trini: Fixup common/cmd_io.c]
Signed-off-by: Tom Rini <trini@ti.com>


# b8bcaa3a 11-Jun-2013 Simon Glass <sjg@chromium.org>

Add function to print a number with grouped digits

Move bootstage's numbering printing code into a generic place so that it can
be used by tracing also.

Signed-off-by: Simon Glass <sjg@chromium.org>


# 71ec92b6 02-Nov-2011 Simon Glass <sjg@chromium.org>

vsprintf: Move function documentation into header file

Now that this is not in common.h, perhaps it is acceptable to move this
documentation into the header file.

Signed-off-by: Simon Glass <sjg@chromium.org>


# 046a37bd 02-Nov-2011 Sonny Rao <sonnyrao@chromium.org>

Add safe vsnprintf and snprintf library functions

From: Sonny Rao <sonnyrao@chromium.org>

These functions are useful in U-Boot because they allow a graceful failure
rather than an unpredictable stack overflow when printf() buffers are
exceeded.

Mostly copied from the Linux kernel. I copied vscnprintf and
scnprintf so we can change printf and vprintf to use the safe
implementation but still return the correct values.

(Simon Glass <sjg@chromium.org> modified this commit a little)

Signed-off-by: Sonny Rao <sonnyrao@chromium.org>


# 9785c905 02-Nov-2011 Simon Glass <sjg@chromium.org>

Move vsprintf functions into their own header

common.h is very large, so before changing the vsprintf functions, move the
prototypes into their own header file.

Signed-off-by: Simon Glass <sjg@chromium.org>