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>
This commit is contained in:
@@ -10,8 +10,33 @@
|
||||
#include <stdarg.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
/**
|
||||
* simple_strtoul - convert a string to an unsigned long
|
||||
*
|
||||
* @param cp The string to be converted
|
||||
* @param endp Updated to point to the first character not converted
|
||||
* @param base The number base to use
|
||||
* @return value decoded from string (0 if invalid)
|
||||
*
|
||||
* Converts a string to an unsigned long. If there are invalid characters at
|
||||
* the end these are ignored. In the worst case, if all characters are invalid,
|
||||
* 0 is returned
|
||||
*/
|
||||
ulong simple_strtoul(const char *cp, char **endp, unsigned int base);
|
||||
|
||||
/**
|
||||
* hex_strtoul - convert a string in hex to an unsigned long
|
||||
*
|
||||
* @param cp The string to be converted
|
||||
* @param 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. 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 hextoul(const char *cp, char **endp);
|
||||
|
||||
/**
|
||||
* strict_strtoul - convert a string to an unsigned long strictly
|
||||
* @param cp The string to be converted
|
||||
@@ -30,9 +55,6 @@ ulong simple_strtoul(const char *cp, char **endp, unsigned int base);
|
||||
*
|
||||
* echo will append a newline to the tail.
|
||||
*
|
||||
* simple_strtoul just ignores the successive invalid characters and
|
||||
* return the converted value of prefix part of the string.
|
||||
*
|
||||
* Copied this function from Linux 2.6.38 commit ID:
|
||||
* 521cb40b0c44418a4fd36dc633f575813d59a43d
|
||||
*
|
||||
|
Reference in New Issue
Block a user