diff options
-rw-r--r-- | net/wireless/core.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/net/wireless/core.c b/net/wireless/core.c index 532e1e09e028..24a21add0ba6 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c | |||
@@ -53,21 +53,25 @@ struct wiphy *wiphy_new(struct cfg80211_ops *ops, int sizeof_priv) | |||
53 | 53 | ||
54 | mutex_lock(&cfg80211_drv_mutex); | 54 | mutex_lock(&cfg80211_drv_mutex); |
55 | 55 | ||
56 | if (unlikely(wiphy_counter<0)) { | 56 | drv->idx = wiphy_counter; |
57 | |||
58 | /* now increase counter for the next device unless | ||
59 | * it has wrapped previously */ | ||
60 | if (wiphy_counter >= 0) | ||
61 | wiphy_counter++; | ||
62 | |||
63 | mutex_unlock(&cfg80211_drv_mutex); | ||
64 | |||
65 | if (unlikely(drv->idx < 0)) { | ||
57 | /* ugh, wrapped! */ | 66 | /* ugh, wrapped! */ |
58 | kfree(drv); | 67 | kfree(drv); |
59 | return NULL; | 68 | return NULL; |
60 | } | 69 | } |
61 | drv->idx = wiphy_counter; | ||
62 | 70 | ||
63 | /* give it a proper name */ | 71 | /* give it a proper name */ |
64 | snprintf(drv->wiphy.dev.bus_id, BUS_ID_SIZE, | 72 | snprintf(drv->wiphy.dev.bus_id, BUS_ID_SIZE, |
65 | PHY_NAME "%d", drv->idx); | 73 | PHY_NAME "%d", drv->idx); |
66 | 74 | ||
67 | /* now increase counter for the next time */ | ||
68 | wiphy_counter++; | ||
69 | mutex_unlock(&cfg80211_drv_mutex); | ||
70 | |||
71 | mutex_init(&drv->mtx); | 75 | mutex_init(&drv->mtx); |
72 | mutex_init(&drv->devlist_mtx); | 76 | mutex_init(&drv->devlist_mtx); |
73 | INIT_LIST_HEAD(&drv->netdev_list); | 77 | INIT_LIST_HEAD(&drv->netdev_list); |