aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/mac80211_hwsim.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2014-01-06 16:56:30 -0500
committerJohannes Berg <johannes.berg@intel.com>2014-01-10 14:12:58 -0500
commit2d68992b6079cd5bdfff85251c3c670ce1560d5c (patch)
tree2456560eb608c74ed248fb847b13e4ae19ab1c40 /drivers/net/wireless/mac80211_hwsim.c
parent8133841045b81639495dc5ca1bcab45d279661ab (diff)
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: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'drivers/net/wireless/mac80211_hwsim.c')
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 59caa10a33f0..8df3d5e8e87a 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -217,6 +217,7 @@ static const struct ieee80211_rate hwsim_rates[] = {
217 217
218static spinlock_t hwsim_radio_lock; 218static spinlock_t hwsim_radio_lock;
219static struct list_head hwsim_radios; 219static struct list_head hwsim_radios;
220static int hwsim_radio_idx;
220 221
221struct mac80211_hwsim_data { 222struct mac80211_hwsim_data {
222 struct list_head list; 223 struct list_head list;
@@ -2126,7 +2127,7 @@ static const struct ieee80211_iface_combination hwsim_if_comb[] = {
2126 } 2127 }
2127}; 2128};
2128 2129
2129static int __init mac80211_hwsim_create_radio(int idx) 2130static int __init mac80211_hwsim_create_radio(void)
2130{ 2131{
2131 int err; 2132 int err;
2132 u8 addr[ETH_ALEN]; 2133 u8 addr[ETH_ALEN];
@@ -2134,6 +2135,11 @@ static int __init mac80211_hwsim_create_radio(int idx)
2134 struct ieee80211_hw *hw; 2135 struct ieee80211_hw *hw;
2135 enum ieee80211_band band; 2136 enum ieee80211_band band;
2136 const struct ieee80211_ops *ops = &mac80211_hwsim_ops; 2137 const struct ieee80211_ops *ops = &mac80211_hwsim_ops;
2138 int idx;
2139
2140 spin_lock_bh(&hwsim_radio_lock);
2141 idx = hwsim_radio_idx++;
2142 spin_unlock_bh(&hwsim_radio_lock);
2137 2143
2138 if (channels > 1) 2144 if (channels > 1)
2139 ops = &mac80211_hwsim_mchan_ops; 2145 ops = &mac80211_hwsim_mchan_ops;
@@ -2375,7 +2381,7 @@ static int __init init_mac80211_hwsim(void)
2375 } 2381 }
2376 2382
2377 for (i = 0; i < radios; i++) { 2383 for (i = 0; i < radios; i++) {
2378 err = mac80211_hwsim_create_radio(i); 2384 err = mac80211_hwsim_create_radio();
2379 if (err) 2385 if (err)
2380 goto out_free_radios; 2386 goto out_free_radios;
2381 } 2387 }