*/
static void update_world_regdomain(const struct ieee80211_regdomain *rd)
{
- BUG_ON(!last_request);
+ WARN_ON(!last_request);
reset_regdomains(false);
*/
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;
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),
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)
}
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;
}
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)
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,
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);
}
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;
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, ®_rule, regd);
(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 */
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(®_mutex);
{
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);
{
struct regulatory_request *request;
- BUG_ON(!alpha2);
+ if (WARN_ON(!alpha2))
+ return -EINVAL;
request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL);
if (!request)
{
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)
reg_set_request_processed();
kfree(rd);
- mutex_unlock(®_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);
reg_set_request_processed();
+ out:
mutex_unlock(®_mutex);
return r;