linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [wireless] wireless:  Keep phy name consistent across module reloads.
@ 2010-09-21 23:57 greearb
  2010-09-24 21:02 ` Johannes Berg
  0 siblings, 1 reply; 11+ messages in thread
From: greearb @ 2010-09-21 23:57 UTC (permalink / raw)
  To: linux-wireless; +Cc: Ben Greear

From: Ben Greear <greearb@candelatech.com>

It adds needless pain to user-space scripts to change the name
of the phy on each module reload.  Instead, find the first
index.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
:100644 100644 9c21ebf... 8226ba7... M	net/wireless/core.c
 net/wireless/core.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/net/wireless/core.c b/net/wireless/core.c
index 9c21ebf..8226ba7 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -319,8 +319,7 @@ static void cfg80211_event_work(struct work_struct *work)
 
 struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv)
 {
-	static int wiphy_counter;
-
+	int i;
 	struct cfg80211_registered_device *rdev;
 	int alloc_size;
 
@@ -342,12 +341,18 @@ struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv)
 
 	mutex_lock(&cfg80211_mutex);
 
-	rdev->wiphy_idx = wiphy_counter++;
+	/* 64k wiphy devices is enough for anyone! */
+	for (i = 0; i < 0xFFFF; i++) {
+		if (!cfg80211_rdev_by_wiphy_idx(i))
+			break;
+	}
+	if (i == 0xFFFF)
+		i = -1; /* invalid */
+	rdev->wiphy_idx = i;
 
 	if (unlikely(!wiphy_idx_valid(rdev->wiphy_idx))) {
-		wiphy_counter--;
 		mutex_unlock(&cfg80211_mutex);
-		/* ugh, wrapped! */
+		/* ugh, too many devices already! */
 		kfree(rdev);
 		return NULL;
 	}
-- 
1.7.2.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-09-27 20:44 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-21 23:57 [wireless] wireless: Keep phy name consistent across module reloads greearb
2010-09-24 21:02 ` Johannes Berg
2010-09-24 21:10   ` Ben Greear
2010-09-24 21:18     ` Johannes Berg
2010-09-24 21:25       ` Ben Greear
2010-09-24 21:31         ` Johannes Berg
2010-09-24 21:33           ` Ben Greear
2010-09-24 22:21           ` Ben Greear
2010-09-24 22:25             ` Johannes Berg
2010-09-24 22:37               ` Ben Greear
2010-09-27 20:41   ` wireless-next-2.6 rebased -- " John W. Linville

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).