MIPS: BCM47XX: trim the nvram values for parsing
authorHauke Mehrtens <hauke@hauke-m.de>
Wed, 26 Dec 2012 19:53:26 +0000 (19:53 +0000)
committerJohn Crispin <blogic@openwrt.org>
Fri, 15 Feb 2013 18:01:57 +0000 (19:01 +0100)
Some nvram values on some devices have a newline character at the end
of the value, that caused read errors. Trim the string before reading
the number.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Patchwork: http://patchwork.linux-mips.org/patch/4745/
Signed-off-by: John Crispin <blogic@openwrt.org>
arch/mips/bcm47xx/sprom.c

index 89b9bf46b13bf44f810a012863bead71e527b94f..38492301a7b54ab3772a0221bbd9e370f27e14d4 100644 (file)
@@ -71,7 +71,7 @@ static void nvram_read_ ## type (const char *prefix,                  \
                            fallback);                                  \
        if (err < 0)                                                    \
                return;                                                 \
-       err = kstrto ## type (buf, 0, &var);                            \
+       err = kstrto ## type(strim(buf), 0, &var);                      \
        if (err) {                                                      \
                pr_warn("can not parse nvram name %s%s%s with value %s got %i\n",       \
                        prefix, name, postfix, buf, err);               \
@@ -99,7 +99,7 @@ static void nvram_read_u32_2(const char *prefix, const char *name,
        err = get_nvram_var(prefix, NULL, name, buf, sizeof(buf), fallback);
        if (err < 0)
                return;
-       err = kstrtou32(buf, 0, &val);
+       err = kstrtou32(strim(buf), 0, &val);
        if (err) {
                pr_warn("can not parse nvram name %s%s with value %s got %i\n",
                        prefix, name, buf, err);
@@ -120,7 +120,7 @@ static void nvram_read_leddc(const char *prefix, const char *name,
        err = get_nvram_var(prefix, NULL, name, buf, sizeof(buf), fallback);
        if (err < 0)
                return;
-       err = kstrtou32(buf, 0, &val);
+       err = kstrtou32(strim(buf), 0, &val);
        if (err) {
                pr_warn("can not parse nvram name %s%s with value %s got %i\n",
                        prefix, name, buf, err);
This page took 0.026016 seconds and 5 git commands to generate.