summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2018-10-02 13:02:22 -0400
committerTom Rini <trini@konsulko.com>2018-10-02 17:01:46 -0400
commit592cd5defd4f71d34ffcbd8dd3326bc10f662e20 (patch)
tree0824c4d2c60d79b7be18ba82209d899e4d4f8c34 /lib
parent2ba8bf207481cfb319f54a1bef67f6f068831a58 (diff)
parentb3bec2525604d6b42bb9e7fd719c84b022447db3 (diff)
Merge branch 'master' of git://git.denx.de/u-boot-spi
This is the PR for SPI-NAND changes along with few spi changes. [trini: Re-sync changes for ls1012afrwy_qspi*_defconfig] Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/strto.c36
1 files changed, 16 insertions, 20 deletions
diff --git a/lib/strto.c b/lib/strto.c
index 7f6076909a..55ff9f7437 100644
--- a/lib/strto.c
+++ b/lib/strto.c
@@ -85,22 +85,20 @@ long simple_strtol(const char *cp, char **endp, unsigned int base)
unsigned long ustrtoul(const char *cp, char **endp, unsigned int base)
{
unsigned long result = simple_strtoul(cp, endp, base);
- switch (**endp) {
- case 'G':
+ switch (tolower(**endp)) {
+ case 'g':
result *= 1024;
/* fall through */
- case 'M':
+ 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;
- }
+ (*endp)++;
+ if (**endp == 'i')
+ (*endp)++;
+ if (**endp == 'B')
+ (*endp)++;
}
return result;
}
@@ -108,22 +106,20 @@ unsigned long ustrtoul(const char *cp, char **endp, unsigned int base)
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':
+ switch (tolower(**endp)) {
+ case 'g':
result *= 1024;
/* fall through */
- case 'M':
+ 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;
- }
+ (*endp)++;
+ if (**endp == 'i')
+ (*endp)++;
+ if (**endp == 'B')
+ (*endp)++;
}
return result;
}