* [PATCH] d80211: optimise if_alloc() name creation.
@ 2007-02-23 6:39 Stephen Hemminger
2007-02-23 11:22 ` Johannes Berg
2007-02-23 16:55 ` Jiri Benc
0 siblings, 2 replies; 3+ messages in thread
From: Stephen Hemminger @ 2007-02-23 6:39 UTC (permalink / raw)
To: linux-wireless
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
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] d80211: optimise if_alloc() name creation.
2007-02-23 6:39 [PATCH] d80211: optimise if_alloc() name creation Stephen Hemminger
@ 2007-02-23 11:22 ` Johannes Berg
2007-02-23 16:55 ` Jiri Benc
1 sibling, 0 replies; 3+ messages in thread
From: Johannes Berg @ 2007-02-23 11:22 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: linux-wireless
[-- Attachment #1: Type: text/plain, Size: 295 bytes --]
On Thu, 2007-02-22 at 22:39 -0800, Stephen Hemminger wrote:
> The code to do guess and check for creating a sub-device name is unnecessary.
> dev_alloc_name() is optimized to do this already.
Ack, I thought this might be the case some time ago but then forgot to
investigate.
johannes
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] d80211: optimise if_alloc() name creation.
2007-02-23 6:39 [PATCH] d80211: optimise if_alloc() name creation Stephen Hemminger
2007-02-23 11:22 ` Johannes Berg
@ 2007-02-23 16:55 ` Jiri Benc
1 sibling, 0 replies; 3+ messages in thread
From: Jiri Benc @ 2007-02-23 16:55 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: linux-wireless
On Thu, 22 Feb 2007 22:39:41 -0800, Stephen Hemminger wrote:
> The code to do guess and check for creating a sub-device name is unnecessary.
> dev_alloc_name() is optimized to do this already.
Applied, thanks!
Jiri
--
Jiri Benc
SUSE Labs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-02-23 16:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-23 6:39 [PATCH] d80211: optimise if_alloc() name creation Stephen Hemminger
2007-02-23 11:22 ` Johannes Berg
2007-02-23 16:55 ` Jiri Benc
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox