From: Roger Chen Date: Mon, 11 Jul 2016 03:12:37 +0000 (+0800) Subject: net: phy: fix sysfs operation for writing PHY's registers X-Git-Tag: firefly_0821_release~2184 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=6faf2288fb6aa039c3238bdbb4561294bbd150a6;p=firefly-linux-kernel-4.4.55.git net: phy: fix sysfs operation for writing PHY's registers Change-Id: Ic6cc82c8eb8e20572e77ae703755440012cd3f46 Signed-off-by: Roger Chen --- diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index c9a62692c1ea..cb40734d61e3 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -675,21 +675,28 @@ phy_registers_store(struct device *dev, const char *buf, size_t count) { struct phy_device *phydev = to_phy_device(dev); - long long index, val; + int index, val; int i; + char tmp[32]; for (i = 0; i < count; i++) { if (*(buf + i) == ' ') break; } - if (!kstrtoll(buf, 0, &index)) { - pr_err("Please input like1: \n"); + memset(tmp, 0, sizeof(tmp)); + strncpy(tmp, buf, i); + if (kstrtoint(tmp, 0, &index)) { + pr_err("wrong register index input\n"); + pr_err("usage: \n"); return count; } - if (!kstrtoll(buf + i + 1, 0, &val)) { - pr_err("Please input like2: \n"); + memset(tmp, 0, sizeof(tmp)); + strncpy(tmp, buf + i + 1, strlen(buf) - i - 1); + if (kstrtoint(tmp, 0, &val)) { + pr_err("wrong register value input\n"); + pr_err("usage: \n"); return count; }