|
@@ -53,21 +53,25 @@ struct wiphy *wiphy_new(struct cfg80211_ops *ops, int sizeof_priv)
|
|
|
|
|
|
mutex_lock(&cfg80211_drv_mutex);
|
|
mutex_lock(&cfg80211_drv_mutex);
|
|
|
|
|
|
- if (unlikely(wiphy_counter<0)) {
|
|
|
|
|
|
+ drv->idx = wiphy_counter;
|
|
|
|
+
|
|
|
|
+ /* now increase counter for the next device unless
|
|
|
|
+ * it has wrapped previously */
|
|
|
|
+ if (wiphy_counter >= 0)
|
|
|
|
+ wiphy_counter++;
|
|
|
|
+
|
|
|
|
+ mutex_unlock(&cfg80211_drv_mutex);
|
|
|
|
+
|
|
|
|
+ if (unlikely(drv->idx < 0)) {
|
|
/* ugh, wrapped! */
|
|
/* ugh, wrapped! */
|
|
kfree(drv);
|
|
kfree(drv);
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
- drv->idx = wiphy_counter;
|
|
|
|
|
|
|
|
/* give it a proper name */
|
|
/* give it a proper name */
|
|
snprintf(drv->wiphy.dev.bus_id, BUS_ID_SIZE,
|
|
snprintf(drv->wiphy.dev.bus_id, BUS_ID_SIZE,
|
|
PHY_NAME "%d", drv->idx);
|
|
PHY_NAME "%d", drv->idx);
|
|
|
|
|
|
- /* now increase counter for the next time */
|
|
|
|
- wiphy_counter++;
|
|
|
|
- mutex_unlock(&cfg80211_drv_mutex);
|
|
|
|
-
|
|
|
|
mutex_init(&drv->mtx);
|
|
mutex_init(&drv->mtx);
|
|
mutex_init(&drv->devlist_mtx);
|
|
mutex_init(&drv->devlist_mtx);
|
|
INIT_LIST_HEAD(&drv->netdev_list);
|
|
INIT_LIST_HEAD(&drv->netdev_list);
|