From d3131de76b1b1a4d95f145846bd61f96e72f0411 Mon Sep 17 00:00:00 2001 From: Nikolay Aleksandrov Date: Wed, 22 Jan 2014 14:53:27 +0100 Subject: bonding: convert lacp_rate to use the new option API This patch adds the necessary changes so lacp_rate would use the new bonding option API. Also some trivial/style error fixes. Signed-off-by: Nikolay Aleksandrov Signed-off-by: David S. Miller --- drivers/net/bonding/bond_sysfs.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'drivers/net/bonding/bond_sysfs.c') diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index b873a88c3e2e..a0a54d035c52 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c @@ -548,10 +548,11 @@ static ssize_t bonding_show_lacp(struct device *d, char *buf) { struct bonding *bond = to_bond(d); + struct bond_opt_value *val; - return sprintf(buf, "%s %d\n", - bond_lacp_tbl[bond->params.lacp_fast].modename, - bond->params.lacp_fast); + val = bond_opt_get_val(BOND_OPT_LACP_RATE, bond->params.lacp_fast); + + return sprintf(buf, "%s %d\n", val->string, bond->params.lacp_fast); } static ssize_t bonding_store_lacp(struct device *d, @@ -559,23 +560,12 @@ static ssize_t bonding_store_lacp(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, bond_lacp_tbl); - if (new_value < 0) { - pr_err("%s: Ignoring invalid LACP rate value %.*s.\n", - bond->dev->name, (int)strlen(buf) - 1, buf); - return -EINVAL; - } - - if (!rtnl_trylock()) - return restart_syscall(); + int ret; - ret = bond_option_lacp_rate_set(bond, new_value); + ret = bond_opt_tryset_rtnl(bond, BOND_OPT_LACP_RATE, (char *)buf); if (!ret) ret = count; - rtnl_unlock(); return ret; } static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, -- cgit