linux-mips
[Top] [All Lists]

[PATCH] MIPS: BCM47XX: trim the nvram values for parsing

To: john@phrozen.org, ralf@linux-mips.org
Subject: [PATCH] MIPS: BCM47XX: trim the nvram values for parsing
From: Hauke Mehrtens <hauke@hauke-m.de>
Date: Wed, 26 Dec 2012 21:53:26 +0100
Cc: linux-mips@linux-mips.org, zajec5@gmail.com, Hauke Mehrtens <hauke@hauke-m.de>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Sender: linux-mips-bounce@linux-mips.org
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>
---
 arch/mips/bcm47xx/sprom.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/mips/bcm47xx/sprom.c b/arch/mips/bcm47xx/sprom.c
index 89b9bf4..3849230 100644
--- a/arch/mips/bcm47xx/sprom.c
+++ b/arch/mips/bcm47xx/sprom.c
@@ -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);
-- 
1.7.10.4


<Prev in Thread] Current Thread [Next in Thread>
  • [PATCH] MIPS: BCM47XX: trim the nvram values for parsing, Hauke Mehrtens <=