Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 351734
b: refs/heads/master
c: fdc9d7b
h: refs/heads/master
v: v3
  • Loading branch information
Johannes Berg committed Jan 3, 2013
1 parent 96366a5 commit dbdced1
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 61 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f41737669d2f4c07c09e90767498243e142171f9
refs/heads/master: fdc9d7b2863ce67f51ed64f89e5b20f3077be569
2 changes: 0 additions & 2 deletions trunk/net/wireless/nl80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -4309,8 +4309,6 @@ static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info)
}
}

BUG_ON(rule_idx != num_rules);

r = set_regdom(rd);
rd = NULL;

Expand Down
95 changes: 37 additions & 58 deletions trunk/net/wireless/reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ static void reset_regdomains(bool full_reset)
*/
static void update_world_regdomain(const struct ieee80211_regdomain *rd)
{
BUG_ON(!last_request);
WARN_ON(!last_request);

reset_regdomains(false);

Expand Down Expand Up @@ -804,27 +804,20 @@ static void chan_reg_rule_print_dbg(struct ieee80211_channel *chan,
*/
static void handle_channel(struct wiphy *wiphy,
enum nl80211_reg_initiator initiator,
enum ieee80211_band band,
unsigned int chan_idx)
struct ieee80211_channel *chan)
{
int r;
u32 flags, bw_flags = 0;
u32 desired_bw_khz = MHZ_TO_KHZ(20);
const struct ieee80211_reg_rule *reg_rule = NULL;
const struct ieee80211_power_rule *power_rule = NULL;
const struct ieee80211_freq_range *freq_range = NULL;
struct ieee80211_supported_band *sband;
struct ieee80211_channel *chan;
struct wiphy *request_wiphy = NULL;

assert_cfg80211_lock();

request_wiphy = wiphy_idx_to_wiphy(last_request->wiphy_idx);

sband = wiphy->bands[band];
BUG_ON(chan_idx >= sband->n_channels);
chan = &sband->channels[chan_idx];

flags = chan->orig_flags;

r = freq_reg_info(wiphy, MHZ_TO_KHZ(chan->center_freq),
Expand Down Expand Up @@ -897,17 +890,17 @@ static void handle_channel(struct wiphy *wiphy,
chan->max_power = chan->max_reg_power;
}

static void handle_band(struct wiphy *wiphy, enum ieee80211_band band,
enum nl80211_reg_initiator initiator)
static void handle_band(struct wiphy *wiphy,
enum nl80211_reg_initiator initiator,
struct ieee80211_supported_band *sband)
{
unsigned int i;
struct ieee80211_supported_band *sband;

BUG_ON(!wiphy->bands[band]);
sband = wiphy->bands[band];
if (!sband)
return;

for (i = 0; i < sband->n_channels; i++)
handle_channel(wiphy, initiator, band, i);
handle_channel(wiphy, initiator, &sband->channels[i]);
}

static bool reg_request_cell_base(struct regulatory_request *request)
Expand Down Expand Up @@ -1116,20 +1109,14 @@ static bool is_ht40_allowed(struct ieee80211_channel *chan)
}

static void reg_process_ht_flags_channel(struct wiphy *wiphy,
enum ieee80211_band band,
unsigned int chan_idx)
struct ieee80211_channel *channel)
{
struct ieee80211_supported_band *sband;
struct ieee80211_channel *channel;
struct ieee80211_supported_band *sband = wiphy->bands[channel->band];
struct ieee80211_channel *channel_before = NULL, *channel_after = NULL;
unsigned int i;

assert_cfg80211_lock();

sband = wiphy->bands[band];
BUG_ON(chan_idx >= sband->n_channels);
channel = &sband->channels[chan_idx];

if (!is_ht40_allowed(channel)) {
channel->flags |= IEEE80211_CHAN_NO_HT40;
return;
Expand Down Expand Up @@ -1165,16 +1152,15 @@ static void reg_process_ht_flags_channel(struct wiphy *wiphy,
}

static void reg_process_ht_flags_band(struct wiphy *wiphy,
enum ieee80211_band band)
struct ieee80211_supported_band *sband)
{
unsigned int i;
struct ieee80211_supported_band *sband;

BUG_ON(!wiphy->bands[band]);
sband = wiphy->bands[band];
if (!sband)
return;

for (i = 0; i < sband->n_channels; i++)
reg_process_ht_flags_channel(wiphy, band, i);
reg_process_ht_flags_channel(wiphy, &sband->channels[i]);
}

static void reg_process_ht_flags(struct wiphy *wiphy)
Expand All @@ -1184,11 +1170,8 @@ static void reg_process_ht_flags(struct wiphy *wiphy)
if (!wiphy)
return;

for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
if (wiphy->bands[band])
reg_process_ht_flags_band(wiphy, band);
}

for (band = 0; band < IEEE80211_NUM_BANDS; band++)
reg_process_ht_flags_band(wiphy, wiphy->bands[band]);
}

static void wiphy_update_regulatory(struct wiphy *wiphy,
Expand All @@ -1203,10 +1186,8 @@ static void wiphy_update_regulatory(struct wiphy *wiphy,

last_request->dfs_region = cfg80211_regdomain->dfs_region;

for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
if (wiphy->bands[band])
handle_band(wiphy, band, initiator);
}
for (band = 0; band < IEEE80211_NUM_BANDS; band++)
handle_band(wiphy, initiator, wiphy->bands[band]);

reg_process_beacons(wiphy);
reg_process_ht_flags(wiphy);
Expand Down Expand Up @@ -1236,8 +1217,7 @@ static void update_all_wiphy_regulatory(enum nl80211_reg_initiator initiator)
}

static void handle_channel_custom(struct wiphy *wiphy,
enum ieee80211_band band,
unsigned int chan_idx,
struct ieee80211_channel *chan,
const struct ieee80211_regdomain *regd)
{
int r;
Expand All @@ -1246,15 +1226,9 @@ static void handle_channel_custom(struct wiphy *wiphy,
const struct ieee80211_reg_rule *reg_rule = NULL;
const struct ieee80211_power_rule *power_rule = NULL;
const struct ieee80211_freq_range *freq_range = NULL;
struct ieee80211_supported_band *sband;
struct ieee80211_channel *chan;

assert_reg_lock();

sband = wiphy->bands[band];
BUG_ON(chan_idx >= sband->n_channels);
chan = &sband->channels[chan_idx];

r = freq_reg_info_regd(wiphy, MHZ_TO_KHZ(chan->center_freq),
desired_bw_khz, &reg_rule, regd);

Expand All @@ -1279,17 +1253,17 @@ static void handle_channel_custom(struct wiphy *wiphy,
(int) MBM_TO_DBM(power_rule->max_eirp);
}

static void handle_band_custom(struct wiphy *wiphy, enum ieee80211_band band,
static void handle_band_custom(struct wiphy *wiphy,
struct ieee80211_supported_band *sband,
const struct ieee80211_regdomain *regd)
{
unsigned int i;
struct ieee80211_supported_band *sband;

BUG_ON(!wiphy->bands[band]);
sband = wiphy->bands[band];
if (!sband)
return;

for (i = 0; i < sband->n_channels; i++)
handle_channel_custom(wiphy, band, i, regd);
handle_channel_custom(wiphy, &sband->channels[i], regd);
}

/* Used by drivers prior to wiphy registration */
Expand All @@ -1303,7 +1277,7 @@ void wiphy_apply_custom_regulatory(struct wiphy *wiphy,
for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
if (!wiphy->bands[band])
continue;
handle_band_custom(wiphy, band, regd);
handle_band_custom(wiphy, wiphy->bands[band], regd);
bands_set++;
}
mutex_unlock(&reg_mutex);
Expand Down Expand Up @@ -1537,7 +1511,8 @@ static void reg_process_hint(struct regulatory_request *reg_request,
{
struct wiphy *wiphy = NULL;

BUG_ON(!reg_request->alpha2);
if (WARN_ON(!reg_request->alpha2))
return;

if (reg_request->wiphy_idx != WIPHY_IDX_INVALID)
wiphy = wiphy_idx_to_wiphy(reg_request->wiphy_idx);
Expand Down Expand Up @@ -1678,7 +1653,8 @@ int regulatory_hint_user(const char *alpha2,
{
struct regulatory_request *request;

BUG_ON(!alpha2);
if (WARN_ON(!alpha2))
return -EINVAL;

request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL);
if (!request)
Expand All @@ -1700,8 +1676,8 @@ int regulatory_hint(struct wiphy *wiphy, const char *alpha2)
{
struct regulatory_request *request;

BUG_ON(!alpha2);
BUG_ON(!wiphy);
if (WARN_ON(!alpha2 || !wiphy))
return -EINVAL;

request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL);
if (!request)
Expand Down Expand Up @@ -2239,12 +2215,14 @@ int set_regdom(const struct ieee80211_regdomain *rd)
reg_set_request_processed();

kfree(rd);
mutex_unlock(&reg_mutex);
return r;
goto out;
}

/* This would make this whole thing pointless */
BUG_ON(!last_request->intersect && rd != cfg80211_regdomain);
if (WARN_ON(!last_request->intersect && rd != cfg80211_regdomain)) {
r = -EINVAL;
goto out;
}

/* update all wiphys now with the new established regulatory domain */
update_all_wiphy_regulatory(last_request->initiator);
Expand All @@ -2255,6 +2233,7 @@ int set_regdom(const struct ieee80211_regdomain *rd)

reg_set_request_processed();

out:
mutex_unlock(&reg_mutex);

return r;
Expand Down

0 comments on commit dbdced1

Please sign in to comment.