From patchwork Tue Mar 18 13:53:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 3853581 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3C2309F369 for ; Wed, 19 Mar 2014 17:45:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 57C1A20035 for ; Wed, 19 Mar 2014 17:45:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6AF712011B for ; Wed, 19 Mar 2014 17:45:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755052AbaCRN7b (ORCPT ); Tue, 18 Mar 2014 09:59:31 -0400 Received: from mail-ee0-f53.google.com ([74.125.83.53]:46040 "EHLO mail-ee0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754645AbaCRN7T (ORCPT ); Tue, 18 Mar 2014 09:59:19 -0400 Received: by mail-ee0-f53.google.com with SMTP id b57so4722382eek.40 for ; Tue, 18 Mar 2014 06:59:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tieto.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bIh0Ah3rtIOendpCD9Tpa0/gbHM0I8mfHbapMJyzVDQ=; b=zm5/Q0NZekYaU7rZzOK4m1auObzzvBtlwvbqfWAHDTCO3GaMI0w+aiW0qxii6gNE/D 4R5BXZaElQr2ScarM4T/EZPNNi756ROWQAc05rvqRrS73A5KGodU2qcANOjqHOtaZN7N grL+U8YjLXk7z+oPnz28AKjGgipKpE+uA3Ef4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bIh0Ah3rtIOendpCD9Tpa0/gbHM0I8mfHbapMJyzVDQ=; b=To1Mb/fUu36yxiBkQq9JHR65W/TF8P6r+FrhfvkC4MCL6B8hr3iW2k2/3oczbjmBzR 4TUeeDGO4Ninmf4IwJpy8CJuWgxpWuR5P49dzXHwIKoczdyeJ59FxPtjFj8JfkOxck5/ gJ1cMe1OPZi4RnTKkaPlRIqfLvIf1y8fAXGNHhrxeGE5k+SqQpryJUgTOuJLjbG3FKsh Mf7ypWdQ1A7sOHkTRkqtEXCM5Gp3POA2jRwCBIMCk0IR1Oh8x3YhIrRGALanmOcfAtmw 8U6HdwMlX9dBfUemZmZ6Rk6VTaMAxXUllI19CJI8gQo3AeXu/jarxovWg0QTwZ8nTr+V fiLg== X-Gm-Message-State: ALoCoQm2G5Wdzdd75XeHjn44PkX/BwUnpv4YX5Oa3nd32JsWdnhUsepeLI2lCIyGlLNw+wxfawou78iZ8n+19F0rNvzCXiq78WknEZytI9Cgipotb2zpaZU= X-Received: by 10.14.203.199 with SMTP id f47mr3098227eeo.75.1395151158833; Tue, 18 Mar 2014 06:59:18 -0700 (PDT) Received: from localhost.localdomain ([91.198.246.8]) by mx.google.com with ESMTPSA id x45sm35223167eeu.23.2014.03.18.06.59.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Mar 2014 06:59:18 -0700 (PDT) From: Michal Kazior To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, Michal Kazior Subject: [RFC 10/21] mac80211: split ieee80211_free_chanctx() Date: Tue, 18 Mar 2014 14:53:13 +0100 Message-Id: <1395150804-24090-11-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1395150804-24090-1-git-send-email-michal.kazior@tieto.com> References: <1395150804-24090-1-git-send-email-michal.kazior@tieto.com> X-DomainID: tieto.com Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- net/mac80211/chan.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index 1982e33..623df6f 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c @@ -433,14 +433,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; @@ -450,8 +447,9 @@ 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); @@ -459,13 +457,19 @@ static void ieee80211_free_chanctx(struct ieee80211_local *local, 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,