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>
This commit is contained in:
Simon Glass 2021-10-14 12:48:07 -06:00 committed by Tom Rini
parent 3bfb0f719a
commit 4a255ea3b6
3 changed files with 56 additions and 4 deletions

View file

@ -177,14 +177,26 @@ int vsprintf(char *buf, const char *fmt, va_list args);
* simple_itoa() - convert an unsigned integer to a string
*
* This returns a static string containing the decimal representation of the
* given value. The returned value may be overwritten by other calls to the
* same function, so should be used immediately
* given value. The returned value may be overwritten by other calls to other
* simple_... functions, so should be used immediately
*
* @val: Value to convert
* @return string containing the decimal representation of @val
*/
char *simple_itoa(ulong val);
/**
* simple_xtoa() - convert an unsigned integer to a hex string
*
* This returns a static string containing the hexadecimal representation of the
* given value. The returned value may be overwritten by other calls to other
* simple_... functions, so should be used immediately
*
* @val: Value to convert
* @return string containing the hexecimal representation of @val
*/
char *simple_xtoa(ulong num);
/**
* Format a string and place it in a buffer
*