diff options
| author | Piotr Wilczek <p.wilczek@samsung.com> | 2013-01-27 22:59:24 +0000 | 
|---|---|---|
| committer | Tom Rini <trini@ti.com> | 2013-02-19 17:01:26 -0500 | 
| commit | 7df54d316e70e2d6ae080ef98aa9d2388bbb8af9 (patch) | |
| tree | ef54472e87f03f989e5aa944f764736e3d68637b /lib/vsprintf.c | |
| parent | 7b395232da84ae59bd32985bf944a0a9f417a543 (diff) | |
| download | olio-uboot-2014.01-7df54d316e70e2d6ae080ef98aa9d2388bbb8af9.tar.xz olio-uboot-2014.01-7df54d316e70e2d6ae080ef98aa9d2388bbb8af9.zip | |
vsprintf: add ustrtoll function
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>
Diffstat (limited to 'lib/vsprintf.c')
| -rw-r--r-- | lib/vsprintf.c | 23 | 
1 files changed, 23 insertions, 0 deletions
| diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 3c432f876..533a96b85 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -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)  { |