mirror of
https://github.com/u-boot/u-boot.git
synced 2024-11-23 12:14:32 +08:00
lib: provide function hextoull()
We often convert hexadecimal strings to hextoull(). Provide a wrapper function to simple_strtoull() that does not require specifying the radix. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
This commit is contained in:
parent
e2635570e0
commit
8ff37ec010
@ -44,6 +44,19 @@ ulong simple_strtoul(const char *cp, char **endp, unsigned int base);
|
||||
*/
|
||||
unsigned long hextoul(const char *cp, char **endp);
|
||||
|
||||
/**
|
||||
* hex_strtoull - convert a string in hex to an unsigned long long
|
||||
*
|
||||
* @cp: The string to be converted
|
||||
* @endp: Updated to point to the first character not converted
|
||||
* Return: value decoded from string (0 if invalid)
|
||||
*
|
||||
* Converts a hex string to an unsigned long long. If there are invalid
|
||||
* characters at the end these are ignored. In the worst case, if all characters
|
||||
* are invalid, 0 is returned
|
||||
*/
|
||||
unsigned long long hextoull(const char *cp, char **endp);
|
||||
|
||||
/**
|
||||
* dec_strtoul - convert a string in decimal to an unsigned long
|
||||
*
|
||||
|
@ -78,6 +78,11 @@ ulong hextoul(const char *cp, char **endp)
|
||||
return simple_strtoul(cp, endp, 16);
|
||||
}
|
||||
|
||||
unsigned long long hextoull(const char *cp, char **endp)
|
||||
{
|
||||
return simple_strtoull(cp, endp, 16);
|
||||
}
|
||||
|
||||
ulong dectoul(const char *cp, char **endp)
|
||||
{
|
||||
return simple_strtoul(cp, endp, 10);
|
||||
|
Loading…
Reference in New Issue
Block a user