net: phy: fix sysfs operation for writing PHY's registers
authorRoger Chen <roger.chen@rock-chips.com>
Mon, 11 Jul 2016 03:12:37 +0000 (11:12 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Mon, 11 Jul 2016 03:47:13 +0000 (11:47 +0800)
Change-Id: Ic6cc82c8eb8e20572e77ae703755440012cd3f46
Signed-off-by: Roger Chen <roger.chen@rock-chips.com>
drivers/net/phy/mdio_bus.c

index c9a62692c1ea9525e4f25a385725e31a5705607f..cb40734d61e3173de4bab77ff92cca63db0be7c9 100644 (file)
@@ -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: <reg index> <value>\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: <reg index> <value>\n");
                return count;
        }
 
-       if (!kstrtoll(buf + i + 1, 0, &val)) {
-               pr_err("Please input like2: <reg index> <value>\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: <reg index> <value>\n");
                return count;
        }