Linux wireless drivers development
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@linux-foundation.org>
To: linux-wireless@vger.kernel.org
Subject: [PATCH] d80211: optimise if_alloc() name creation.
Date: Thu, 22 Feb 2007 22:39:41 -0800	[thread overview]
Message-ID: <20070222223941.7f637c2c@localhost> (raw)

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@linux-foundation.org>

---
 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


             reply	other threads:[~2007-02-23  6:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-23  6:39 Stephen Hemminger [this message]
2007-02-23 11:22 ` [PATCH] d80211: optimise if_alloc() name creation Johannes Berg
2007-02-23 16:55 ` Jiri Benc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070222223941.7f637c2c@localhost \
    --to=shemminger@linux-foundation.org \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox