Search Linux Wireless

[PATCH] d80211: optimise if_alloc() name creation.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The code to do guess and check for creating a sub-device name is unnecessary.
dev_alloc_name() is optimized to do this already.

Signed-off-by: Stephen Hemminger <shemminger@xxxxxxxxxxxxxxxxxxxx>

---
 net/d80211/ieee80211_iface.c |   23 ++++++++---------------
 1 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/net/d80211/ieee80211_iface.c b/net/d80211/ieee80211_iface.c
index 618d29b..de8358c 100644
--- a/net/d80211/ieee80211_iface.c
+++ b/net/d80211/ieee80211_iface.c
@@ -40,11 +40,10 @@ static void ieee80211_if_sdata_deinit(st
 int ieee80211_if_add(struct net_device *dev, const char *name,
 		     int format, struct net_device **new_dev)
 {
-	struct net_device *ndev, *tmp_dev;
+	struct net_device *ndev;
 	struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
 	struct ieee80211_sub_if_data *sdata = NULL;
 	int ret;
-	int i;
 
 	ASSERT_RTNL();
 	ndev = *new_dev = alloc_netdev(sizeof(struct ieee80211_sub_if_data),
@@ -52,23 +51,17 @@ int ieee80211_if_add(struct net_device *
 	if (!ndev)
 		return -ENOMEM;
 
-	if (strlen(name) == 0) {
-		i = 0;
-		do {
-			snprintf(ndev->name, sizeof(ndev->name), "%s.%d",
-				 dev->name, i++);
-			tmp_dev = dev_get_by_name(ndev->name);
-			if (!tmp_dev)
-				break;
-			dev_put(tmp_dev);
-		} while (i < 10000);
-	} else if (format) {
+	if (*name == '\0') {
+		snprintf(ndev->name, IFNAMSIZ, "%s.%%d", dev->name);
+		format = 1;
+	}
+
+	if (format) {
 		ret = dev_alloc_name(ndev, name);
 		if (ret < 0)
 			goto fail;
-	} else {
+	} else
 		snprintf(ndev->name, IFNAMSIZ, "%s", name);
-	}
 
 	memcpy(ndev->dev_addr, local->hw.wiphy->perm_addr, ETH_ALEN);
 	ndev->base_addr = dev->base_addr;
-- 
1.4.1

-
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux