aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless
diff options
context:
space:
mode:
Diffstat (limited to 'net/wireless')
-rw-r--r--net/wireless/core.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/net/wireless/core.c b/net/wireless/core.c
index d6940085d59c..5cadbeb76a14 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -34,7 +34,6 @@ MODULE_DESCRIPTION("wireless configuration support");
34 * often because we need to do it for each command */ 34 * often because we need to do it for each command */
35LIST_HEAD(cfg80211_drv_list); 35LIST_HEAD(cfg80211_drv_list);
36DEFINE_MUTEX(cfg80211_drv_mutex); 36DEFINE_MUTEX(cfg80211_drv_mutex);
37static int wiphy_counter;
38 37
39/* for debugfs */ 38/* for debugfs */
40static struct dentry *ieee80211_debugfs_dir; 39static struct dentry *ieee80211_debugfs_dir;
@@ -206,6 +205,8 @@ out_unlock:
206 205
207struct wiphy *wiphy_new(struct cfg80211_ops *ops, int sizeof_priv) 206struct wiphy *wiphy_new(struct cfg80211_ops *ops, int sizeof_priv)
208{ 207{
208 static int wiphy_counter;
209
209 struct cfg80211_registered_device *drv; 210 struct cfg80211_registered_device *drv;
210 int alloc_size; 211 int alloc_size;
211 212
@@ -222,21 +223,18 @@ struct wiphy *wiphy_new(struct cfg80211_ops *ops, int sizeof_priv)
222 223
223 mutex_lock(&cfg80211_drv_mutex); 224 mutex_lock(&cfg80211_drv_mutex);
224 225
225 drv->idx = wiphy_counter; 226 drv->idx = wiphy_counter++;
226
227 /* now increase counter for the next device unless
228 * it has wrapped previously */
229 if (wiphy_counter >= 0)
230 wiphy_counter++;
231
232 mutex_unlock(&cfg80211_drv_mutex);
233 227
234 if (unlikely(drv->idx < 0)) { 228 if (unlikely(drv->idx < 0)) {
229 wiphy_counter--;
230 mutex_unlock(&cfg80211_drv_mutex);
235 /* ugh, wrapped! */ 231 /* ugh, wrapped! */
236 kfree(drv); 232 kfree(drv);
237 return NULL; 233 return NULL;
238 } 234 }
239 235
236 mutex_unlock(&cfg80211_drv_mutex);
237
240 /* give it a proper name */ 238 /* give it a proper name */
241 snprintf(drv->wiphy.dev.bus_id, BUS_ID_SIZE, 239 snprintf(drv->wiphy.dev.bus_id, BUS_ID_SIZE,
242 PHY_NAME "%d", drv->idx); 240 PHY_NAME "%d", drv->idx);