From patchwork Tue Mar 18 13:53:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 3853561 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5194FBF540 for ; Wed, 19 Mar 2014 17:45:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 769DE20035 for ; Wed, 19 Mar 2014 17:45:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C6F6E2011B for ; Wed, 19 Mar 2014 17:45:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755004AbaCRN7a (ORCPT ); Tue, 18 Mar 2014 09:59:30 -0400 Received: from mail-ee0-f41.google.com ([74.125.83.41]:52526 "EHLO mail-ee0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754640AbaCRN7S (ORCPT ); Tue, 18 Mar 2014 09:59:18 -0400 Received: by mail-ee0-f41.google.com with SMTP id t10so5448614eei.0 for ; Tue, 18 Mar 2014 06:59:17 -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=L7NnOXfZj3qRtvjihqKBZiD9y0BtHfdXD0IyfusQEIw=; b=DGVxOazuFJ6tCsxCNeR8M7nMfeWW71bDvBH9UvePhzzADahugwgkofWLf0cxHYoBnx j7HZ4ZPqGyNnalo8p9x+Ttt1bp+zGFCFGWT8sHnsX1ASjktmU+BT8U7UPndRqiLJLnB1 k9OWjm1MEuRcl7wFptGsVxNBskem6mj5h0U+w= 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=L7NnOXfZj3qRtvjihqKBZiD9y0BtHfdXD0IyfusQEIw=; b=ks5xQfWmGIpXLj91Qm4XYJwXsLFwDSNaMAXjxmN1XCv+J6heJnM606dplJRdL2lY60 w/emwkIScVwqudXJR/pRLcOPClmF+r9jxkp+6OQF+cwyBwhBOgPcjZmCL7ogNi2wxBEq mOj0LL7sgjcmRJA6GLv+tEVu6Kv4ZoNqZlY8kphXsxYNFHdR7tgBEvUJ13aJ0sPR2kQD jVBt+fHCWrH5LwPsLJLDUZSXTjU3+fjzQMvJp2nyGqr/hexzG06hvNea54C/qM3+C8iV eIU3lCCee4l0lELc+ZNe3SDN+7oWuTjQnXrk3v/IArTRbEHpOh0Zo9yIG4A84dsbJsqi ORNA== X-Gm-Message-State: ALoCoQnLv71S6n9GpK1TCiX7EJPLXmMctmzhEfmBlIRM1MMAlmfukdLTDMG5RuujvhVFoQ6LbJY+s/wqOcQgy7gwLvbQVVHKYgxwbkN59js+fgqKwKD1hvQ= X-Received: by 10.15.33.70 with SMTP id b46mr2629444eev.107.1395151157449; Tue, 18 Mar 2014 06:59:17 -0700 (PDT) Received: from localhost.localdomain ([91.198.246.8]) by mx.google.com with ESMTPSA id x45sm35223167eeu.23.2014.03.18.06.59.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Mar 2014 06:59:16 -0700 (PDT) From: Michal Kazior To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, Michal Kazior Subject: [RFC 09/21] mac80211: split ieee80211_new_chanctx() Date: Tue, 18 Mar 2014 14:53:12 +0100 Message-Id: <1395150804-24090-10-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 | 56 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index f6d8610..1982e33 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c @@ -353,19 +353,17 @@ static bool ieee80211_is_radar_required(struct ieee80211_local *local) } static struct ieee80211_chanctx * -ieee80211_new_chanctx(struct ieee80211_local *local, - const struct cfg80211_chan_def *chandef, - enum ieee80211_chanctx_mode mode) +ieee80211_alloc_chanctx(struct ieee80211_local *local, + const struct cfg80211_chan_def *chandef, + enum ieee80211_chanctx_mode mode) { struct ieee80211_chanctx *ctx; - u32 changed; - int err; lockdep_assert_held(&local->chanctx_mtx); ctx = kzalloc(sizeof(*ctx) + local->hw.chanctx_data_size, GFP_KERNEL); if (!ctx) - return ERR_PTR(-ENOMEM); + return NULL; INIT_LIST_HEAD(&ctx->assigned_vifs); INIT_LIST_HEAD(&ctx->reserved_vifs); @@ -375,31 +373,63 @@ ieee80211_new_chanctx(struct ieee80211_local *local, ctx->mode = mode; ctx->conf.radar_enabled = ieee80211_is_radar_required(local); ieee80211_recalc_chanctx_min_def(local, ctx); + + return ctx; +} + +static int ieee80211_add_chanctx(struct ieee80211_local *local, + struct ieee80211_chanctx *ctx) +{ + u32 changed; + int err; + + lockdep_assert_held(&local->mtx); + lockdep_assert_held(&local->chanctx_mtx); + if (!local->use_chanctx) local->hw.conf.radar_enabled = ctx->conf.radar_enabled; - /* we hold the mutex to prevent idle from changing */ - lockdep_assert_held(&local->mtx); /* turn idle off *before* setting channel -- some drivers need that */ changed = ieee80211_idle_off(local); if (changed) ieee80211_hw_config(local, changed); if (!local->use_chanctx) { - local->_oper_chandef = *chandef; + local->_oper_chandef = ctx->conf.def; ieee80211_hw_config(local, 0); } else { err = drv_add_chanctx(local, ctx); if (err) { - kfree(ctx); ieee80211_recalc_idle(local); - return ERR_PTR(err); + return err; } } - /* and keep the mutex held until the new chanctx is on the list */ - list_add_rcu(&ctx->list, &local->chanctx_list); + return 0; +} + +static struct ieee80211_chanctx * +ieee80211_new_chanctx(struct ieee80211_local *local, + const struct cfg80211_chan_def *chandef, + enum ieee80211_chanctx_mode mode) +{ + struct ieee80211_chanctx *ctx; + int err; + + lockdep_assert_held(&local->mtx); + lockdep_assert_held(&local->chanctx_mtx); + + ctx = ieee80211_alloc_chanctx(local, chandef, mode); + if (!ctx) + return ERR_PTR(-ENOMEM); + err = ieee80211_add_chanctx(local, ctx); + if (err) { + kfree(ctx); + return ERR_PTR(err); + } + + list_add_rcu(&ctx->list, &local->chanctx_list); return ctx; }