introduce strtoull_suffix function
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
3e503822c7
commit
76281a16fb
|
@ -160,6 +160,7 @@ int parse_area_spec(const char *str, ulong *start, ulong *size);
|
|||
|
||||
/* Just like simple_strtoul(), but this one honors a K/M/G suffix */
|
||||
unsigned long strtoul_suffix(const char *str, char **endp, int base);
|
||||
unsigned long long strtoull_suffix(const char *str, char **endp, int base);
|
||||
|
||||
void start_barebox(void);
|
||||
void shutdown_barebox(void);
|
||||
|
|
14
lib/misc.c
14
lib/misc.c
|
@ -27,15 +27,15 @@
|
|||
#include <linux/ctype.h>
|
||||
|
||||
/*
|
||||
* Like simple_strtoul() but handles an optional G, M, K or k
|
||||
* Like simple_strtoull() but handles an optional G, M, K or k
|
||||
* suffix for Gigabyte, Megabyte or Kilobyte
|
||||
*/
|
||||
unsigned long strtoul_suffix(const char *str, char **endp, int base)
|
||||
unsigned long long strtoull_suffix(const char *str, char **endp, int base)
|
||||
{
|
||||
unsigned long val;
|
||||
unsigned long long val;
|
||||
char *end;
|
||||
|
||||
val = simple_strtoul(str, &end, base);
|
||||
val = simple_strtoull(str, &end, base);
|
||||
|
||||
switch (*end) {
|
||||
case 'G':
|
||||
|
@ -55,6 +55,12 @@ unsigned long strtoul_suffix(const char *str, char **endp, int base)
|
|||
|
||||
return val;
|
||||
}
|
||||
EXPORT_SYMBOL(strtoull_suffix);
|
||||
|
||||
unsigned long strtoul_suffix(const char *str, char **endp, int base)
|
||||
{
|
||||
return strtoull_suffix(str, endp, base);
|
||||
}
|
||||
EXPORT_SYMBOL(strtoul_suffix);
|
||||
|
||||
/*
|
||||
|
|
|
@ -83,6 +83,7 @@ unsigned long long simple_strtoull (const char *cp, char **endp, unsigned int ba
|
|||
*endp = (char *) cp;
|
||||
return result;
|
||||
}
|
||||
EXPORT_SYMBOL(simple_strtoll);
|
||||
|
||||
/* we use this so that we can do without the ctype library */
|
||||
#define is_digit(c) ((c) >= '0' && (c) <= '9')
|
||||
|
|
Loading…
Reference in New Issue