Skip to content

Commit

Permalink
mac80211: split ieee80211_free_chanctx()
Browse files Browse the repository at this point in the history
The function did a little too much. Split it up so
the code can be easily reused in the future.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
Michal Kazior authored and Johannes Berg committed Apr 25, 2014
1 parent ed68ebc commit 1f0d54c
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions net/mac80211/chan.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,14 +431,11 @@ ieee80211_new_chanctx(struct ieee80211_local *local,
return ctx;
}

static void ieee80211_free_chanctx(struct ieee80211_local *local,
struct ieee80211_chanctx *ctx)
static void ieee80211_del_chanctx(struct ieee80211_local *local,
struct ieee80211_chanctx *ctx)
{
bool check_single_channel = false;
lockdep_assert_held(&local->chanctx_mtx);

WARN_ON_ONCE(ctx->refcount != 0);

if (!local->use_chanctx) {
struct cfg80211_chan_def *chandef = &local->_oper_chandef;
chandef->width = NL80211_CHAN_WIDTH_20_NOHT;
Expand All @@ -448,22 +445,29 @@ static void ieee80211_free_chanctx(struct ieee80211_local *local,
/* NOTE: Disabling radar is only valid here for
* single channel context. To be sure, check it ...
*/
if (local->hw.conf.radar_enabled)
check_single_channel = true;
WARN_ON(local->hw.conf.radar_enabled &&
!list_empty(&local->chanctx_list));

local->hw.conf.radar_enabled = false;

ieee80211_hw_config(local, 0);
} else {
drv_remove_chanctx(local, ctx);
}

list_del_rcu(&ctx->list);
kfree_rcu(ctx, rcu_head);
ieee80211_recalc_idle(local);
}

/* throw a warning if this wasn't the only channel context. */
WARN_ON(check_single_channel && !list_empty(&local->chanctx_list));
static void ieee80211_free_chanctx(struct ieee80211_local *local,
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,
Expand Down

0 comments on commit 1f0d54c

Please sign in to comment.