bonding: convert arp_validate to use the new option API
[firefly-linux-kernel-4.4.55.git] / drivers / net / bonding / bond_sysfs.c
index d81638c33fdb3f42e6eac70a349db8bf524831dd..e1a4b633013fbdf14fd797c87949967e379a1ba2 100644 (file)
@@ -325,10 +325,12 @@ static ssize_t bonding_show_arp_validate(struct device *d,
                                         char *buf)
 {
        struct bonding *bond = to_bond(d);
+       struct bond_opt_value *val;
 
-       return sprintf(buf, "%s %d\n",
-                      arp_validate_tbl[bond->params.arp_validate].modename,
-                      bond->params.arp_validate);
+       val = bond_opt_get_val(BOND_OPT_ARP_VALIDATE,
+                              bond->params.arp_validate);
+
+       return sprintf(buf, "%s %d\n", val->string, bond->params.arp_validate);
 }
 
 static ssize_t bonding_store_arp_validate(struct device *d,
@@ -336,23 +338,12 @@ static ssize_t bonding_store_arp_validate(struct device *d,
                                          const char *buf, size_t count)
 {
        struct bonding *bond = to_bond(d);
-       int new_value, ret;
-
-       new_value = bond_parse_parm(buf, arp_validate_tbl);
-       if (new_value < 0) {
-               pr_err("%s: Ignoring invalid arp_validate value %s\n",
-                      bond->dev->name, buf);
-               return -EINVAL;
-       }
-       if (!rtnl_trylock())
-               return restart_syscall();
+       int ret;
 
-       ret = bond_option_arp_validate_set(bond, new_value);
+       ret = bond_opt_tryset_rtnl(bond, BOND_OPT_ARP_VALIDATE, (char *)buf);
        if (!ret)
                ret = count;
 
-       rtnl_unlock();
-
        return ret;
 }