Re: [PATCH net-next-2.6] bonding: make bonding_store_slaves simpler

Previous thread: [PATCH net-next-2.6] bonding: remove redundant checks from bonding_store_slaves V2 by Jiri Pirko on Tuesday, May 18, 2010 - 8:44 am. (2 messages)

Next thread: [PATCH 1/2] ethtool: Add generic structure and functions for named flags by Ben Hutchings on Tuesday, May 18, 2010 - 9:32 am. (2 messages)
From: Jiri Pirko
Date: Tuesday, May 18, 2010 - 8:46 am

This patch makes bonding_store_slaves function nicer and easier to understand.

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
 drivers/net/bonding/bond_sysfs.c |   66 ++++++++++++++-----------------------
 1 files changed, 25 insertions(+), 41 deletions(-)

diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 7911438..a4cbaf7 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -211,7 +211,8 @@ static ssize_t bonding_show_slaves(struct device *d,
 /*
  * Set the slaves in the current bond.  The bond interface must be
  * up for this to succeed.
- * This function is largely the same flow as bonding_update_bonds().
+ * This is supposed to be only thin wrapper for bond_enslave and bond_release.
+ * All hard work should be done there.
  */
 static ssize_t bonding_store_slaves(struct device *d,
 				    struct device_attribute *attr,
@@ -219,9 +220,8 @@ static ssize_t bonding_store_slaves(struct device *d,
 {
 	char command[IFNAMSIZ + 1] = { 0, };
 	char *ifname;
-	int i, res, ret = count;
-	struct slave *slave;
-	struct net_device *dev = NULL;
+	int res, ret = count;
+	struct net_device *dev;
 	struct bonding *bond = to_bond(d);
 
 	/* Quick sanity check -- is the bond interface up? */
@@ -230,8 +230,6 @@ static ssize_t bonding_store_slaves(struct device *d,
 			   bond->dev->name);
 	}
 
-	/* Note:  We can't hold bond->lock here, as bond_create grabs it. */
-
 	if (!rtnl_trylock())
 		return restart_syscall();
 
@@ -241,19 +239,17 @@ static ssize_t bonding_store_slaves(struct device *d,
 	    !dev_valid_name(ifname))
 		goto err_no_cmd;
 
-	if (command[0] == '+') {
-
-		/* Got a slave name in ifname. */
-
-		dev = __dev_get_by_name(dev_net(bond->dev), ifname);
-		if (!dev) {
-			pr_info("%s: Interface %s does not exist!\n",
-				bond->dev->name, ifname);
-			ret = -ENODEV;
-			goto out;
-		}
+	dev = __dev_get_by_name(dev_net(bond->dev), ifname);
+	if (!dev) {
+		pr_info("%s: ...
From: David Miller
Date: Wednesday, June 2, 2010 - 3:40 am

From: Jiri Pirko <jpirko@redhat.com>

Applied.
--

Previous thread: [PATCH net-next-2.6] bonding: remove redundant checks from bonding_store_slaves V2 by Jiri Pirko on Tuesday, May 18, 2010 - 8:44 am. (2 messages)

Next thread: [PATCH 1/2] ethtool: Add generic structure and functions for named flags by Ben Hutchings on Tuesday, May 18, 2010 - 9:32 am. (2 messages)