From e499461275023e20c4aecb6a546e7e213631b99f Mon Sep 17 00:00:00 2001 From: Nikolay Aleksandrov Date: Wed, 22 Jan 2014 14:53:26 +0100 Subject: bonding: convert updelay to use the new option API This patch adds the necessary changes so updelay would use the new bonding option API. Also some trivial style fixes. Signed-off-by: Nikolay Aleksandrov Signed-off-by: David S. Miller --- drivers/net/bonding/bond_options.c | 39 +++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'drivers/net/bonding/bond_options.c') diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c index 03514f7e17b9..9cc21628032f 100644 --- a/drivers/net/bonding/bond_options.c +++ b/drivers/net/bonding/bond_options.c @@ -142,6 +142,14 @@ static struct bond_option bond_opts[] = { .values = bond_intmax_tbl, .set = bond_option_downdelay_set }, + [BOND_OPT_UPDELAY] = { + .id = BOND_OPT_UPDELAY, + .name = "updelay", + .desc = "Delay before considering link up, in milliseconds", + .values = bond_intmax_tbl, + .set = bond_option_updelay_set + }, + { } }; @@ -558,31 +566,24 @@ int bond_option_miimon_set(struct bonding *bond, int miimon) return 0; } -int bond_option_updelay_set(struct bonding *bond, int updelay) +int bond_option_updelay_set(struct bonding *bond, struct bond_opt_value *newval) { - if (!(bond->params.miimon)) { + if (!bond->params.miimon) { pr_err("%s: Unable to set up delay as MII monitoring is disabled\n", bond->dev->name); return -EPERM; } - - if (updelay < 0) { - pr_err("%s: Invalid up delay value %d not in range %d-%d; rejected.\n", - bond->dev->name, updelay, 0, INT_MAX); - return -EINVAL; - } else { - if ((updelay % bond->params.miimon) != 0) { - pr_warn("%s: Warning: up delay (%d) is not a multiple of miimon (%d), updelay rounded to %d ms\n", - bond->dev->name, updelay, - bond->params.miimon, - (updelay / bond->params.miimon) * - bond->params.miimon); - } - bond->params.updelay = updelay / bond->params.miimon; - pr_info("%s: Setting up delay to %d.\n", - bond->dev->name, - bond->params.updelay * bond->params.miimon); + if ((newval->value % bond->params.miimon) != 0) { + pr_warn("%s: Warning: up delay (%llu) is not a multiple of miimon (%d), updelay rounded to %llu ms\n", + bond->dev->name, newval->value, + bond->params.miimon, + (newval->value / bond->params.miimon) * + bond->params.miimon); } + bond->params.updelay = newval->value / bond->params.miimon; + pr_info("%s: Setting up delay to %d.\n", + bond->dev->name, + bond->params.updelay * bond->params.miimon); return 0; } -- cgit v1.2.1