]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
vsprintf: add ustrtoll function
authorPiotr Wilczek <p.wilczek@samsung.com>
Sun, 27 Jan 2013 22:59:24 +0000 (22:59 +0000)
committerTom Rini <trini@ti.com>
Tue, 19 Feb 2013 22:01:26 +0000 (17:01 -0500)
Add 'ustrtoull' function to convert size from string (ex: 1GiB)
to unsigned long long type

Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
include/exports.h
lib/vsprintf.c

index 6cf31aa5e794c0c6fb186bb6ee3705136cc40a2b..41d5085e16c27017d7e02540c3aacfa2090e994a 100644 (file)
@@ -24,6 +24,7 @@ int setenv (const char *varname, const char *varvalue);
 long simple_strtol(const char *cp,char **endp,unsigned int base);
 int strcmp(const char * cs,const char * ct);
 unsigned long ustrtoul(const char *cp, char **endp, unsigned int base);
+unsigned long long ustrtoull(const char *cp, char **endp, unsigned int base);
 #if defined(CONFIG_CMD_I2C)
 int i2c_write (uchar, uint, int , uchar* , int);
 int i2c_read (uchar, uint, int , uchar* , int);
index 3c432f8764fb7cf679e4e7260247eee6d9938853..533a96b85e3629a765ba807a594f8509fab9f68a 100644 (file)
@@ -126,6 +126,29 @@ unsigned long ustrtoul(const char *cp, char **endp, unsigned int base)
        return result;
 }
 
+unsigned long long ustrtoull(const char *cp, char **endp, unsigned int base)
+{
+       unsigned long long result = simple_strtoull(cp, endp, base);
+       switch (**endp) {
+       case 'G':
+               result *= 1024;
+               /* fall through */
+       case 'M':
+               result *= 1024;
+               /* fall through */
+       case 'K':
+       case 'k':
+               result *= 1024;
+               if ((*endp)[1] == 'i') {
+                       if ((*endp)[2] == 'B')
+                               (*endp) += 3;
+                       else
+                               (*endp) += 2;
+               }
+       }
+       return result;
+}
+
 unsigned long long simple_strtoull(const char *cp, char **endp,
                                        unsigned int base)
 {