Commit 1f0d54cd authored by Michal Kazior's avatar Michal Kazior Committed by Johannes Berg

mac80211: split ieee80211_free_chanctx()

The function did a little too much. Split it up so
the code can be easily reused in the future.
Signed-off-by: default avatarMichal Kazior <michal.kazior@tieto.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent ed68ebca
...@@ -431,14 +431,11 @@ ieee80211_new_chanctx(struct ieee80211_local *local, ...@@ -431,14 +431,11 @@ ieee80211_new_chanctx(struct ieee80211_local *local,
return ctx; return ctx;
} }
static void ieee80211_free_chanctx(struct ieee80211_local *local, static void ieee80211_del_chanctx(struct ieee80211_local *local,
struct ieee80211_chanctx *ctx) struct ieee80211_chanctx *ctx)
{ {
bool check_single_channel = false;
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_held(&local->chanctx_mtx);
WARN_ON_ONCE(ctx->refcount != 0);
if (!local->use_chanctx) { if (!local->use_chanctx) {
struct cfg80211_chan_def *chandef = &local->_oper_chandef; struct cfg80211_chan_def *chandef = &local->_oper_chandef;
chandef->width = NL80211_CHAN_WIDTH_20_NOHT; chandef->width = NL80211_CHAN_WIDTH_20_NOHT;
...@@ -448,8 +445,9 @@ static void ieee80211_free_chanctx(struct ieee80211_local *local, ...@@ -448,8 +445,9 @@ static void ieee80211_free_chanctx(struct ieee80211_local *local,
/* NOTE: Disabling radar is only valid here for /* NOTE: Disabling radar is only valid here for
* single channel context. To be sure, check it ... * single channel context. To be sure, check it ...
*/ */
if (local->hw.conf.radar_enabled) WARN_ON(local->hw.conf.radar_enabled &&
check_single_channel = true; !list_empty(&local->chanctx_list));
local->hw.conf.radar_enabled = false; local->hw.conf.radar_enabled = false;
ieee80211_hw_config(local, 0); ieee80211_hw_config(local, 0);
...@@ -457,13 +455,19 @@ static void ieee80211_free_chanctx(struct ieee80211_local *local, ...@@ -457,13 +455,19 @@ static void ieee80211_free_chanctx(struct ieee80211_local *local,
drv_remove_chanctx(local, ctx); drv_remove_chanctx(local, ctx);
} }
list_del_rcu(&ctx->list); ieee80211_recalc_idle(local);
kfree_rcu(ctx, rcu_head); }
/* throw a warning if this wasn't the only channel context. */ static void ieee80211_free_chanctx(struct ieee80211_local *local,
WARN_ON(check_single_channel && !list_empty(&local->chanctx_list)); struct ieee80211_chanctx *ctx)
{
lockdep_assert_held(&local->chanctx_mtx);
ieee80211_recalc_idle(local); WARN_ON_ONCE(ctx->refcount != 0);
list_del_rcu(&ctx->list);
ieee80211_del_chanctx(local, ctx);
kfree_rcu(ctx, rcu_head);
} }
static void ieee80211_recalc_chanctx_chantype(struct ieee80211_local *local, static void ieee80211_recalc_chanctx_chantype(struct ieee80211_local *local,
......
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