Commit 2d68992b authored by Johannes Berg's avatar Johannes Berg

mac80211_hwsim: assign index from separate counter

To later allow dynamic registration, assign the index for the
struct device and MAC address from a new free-running counter.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 81338410
...@@ -217,6 +217,7 @@ static const struct ieee80211_rate hwsim_rates[] = { ...@@ -217,6 +217,7 @@ static const struct ieee80211_rate hwsim_rates[] = {
static spinlock_t hwsim_radio_lock; static spinlock_t hwsim_radio_lock;
static struct list_head hwsim_radios; static struct list_head hwsim_radios;
static int hwsim_radio_idx;
struct mac80211_hwsim_data { struct mac80211_hwsim_data {
struct list_head list; struct list_head list;
...@@ -2126,7 +2127,7 @@ static const struct ieee80211_iface_combination hwsim_if_comb[] = { ...@@ -2126,7 +2127,7 @@ static const struct ieee80211_iface_combination hwsim_if_comb[] = {
} }
}; };
static int __init mac80211_hwsim_create_radio(int idx) static int __init mac80211_hwsim_create_radio(void)
{ {
int err; int err;
u8 addr[ETH_ALEN]; u8 addr[ETH_ALEN];
...@@ -2134,6 +2135,11 @@ static int __init mac80211_hwsim_create_radio(int idx) ...@@ -2134,6 +2135,11 @@ static int __init mac80211_hwsim_create_radio(int idx)
struct ieee80211_hw *hw; struct ieee80211_hw *hw;
enum ieee80211_band band; enum ieee80211_band band;
const struct ieee80211_ops *ops = &mac80211_hwsim_ops; const struct ieee80211_ops *ops = &mac80211_hwsim_ops;
int idx;
spin_lock_bh(&hwsim_radio_lock);
idx = hwsim_radio_idx++;
spin_unlock_bh(&hwsim_radio_lock);
if (channels > 1) if (channels > 1)
ops = &mac80211_hwsim_mchan_ops; ops = &mac80211_hwsim_mchan_ops;
...@@ -2375,7 +2381,7 @@ static int __init init_mac80211_hwsim(void) ...@@ -2375,7 +2381,7 @@ static int __init init_mac80211_hwsim(void)
} }
for (i = 0; i < radios; i++) { for (i = 0; i < radios; i++) {
err = mac80211_hwsim_create_radio(i); err = mac80211_hwsim_create_radio();
if (err) if (err)
goto out_free_radios; goto out_free_radios;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment