From patchwork Mon Mar 31 10:39:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 3913621 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 63C48BF540 for ; Mon, 31 Mar 2014 11:43:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8577C203AD for ; Mon, 31 Mar 2014 11:43:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A7773203AC for ; Mon, 31 Mar 2014 11:43:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753041AbaCaLn2 (ORCPT ); Mon, 31 Mar 2014 07:43:28 -0400 Received: from mail-we0-f176.google.com ([74.125.82.176]:47994 "EHLO mail-we0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752980AbaCaLnY (ORCPT ); Mon, 31 Mar 2014 07:43:24 -0400 Received: by mail-we0-f176.google.com with SMTP id x48so4687809wes.35 for ; Mon, 31 Mar 2014 04:43:23 -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=6ayxib19+vuUWyofSEfHBOXgUjNQkJp3+qyLVyyKwPI=; b=FmAXeZUjqR8/w8cVpT6XDLjjAAdZ8lpQ0orKxI+cNyGagKLe0LYvbRb9x6v2RQbRr+ gjHNdehspCWNHz7UIyuqUTLvZRG/Ud8thbj7EFRiiBEVZlxkBHh7xLHnVY3IoN7K5gjR vdKUy80uECGSvOoHRqW1Gp4Oq+XFUHoVrme8o= 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=6ayxib19+vuUWyofSEfHBOXgUjNQkJp3+qyLVyyKwPI=; b=gVg3N1qybibhobALvcrbsqeq+2+Ta4FmAEeDk1zBIkkwFNIxQOXyfYwp80Zgxooqah HSCEjF40Qcy5rQJvoiJ1D+mXVThnyrY/yFuEnAG82EqFvO0iBd0+Jior0/2UWSERlkAp EQrVHIRbRNhrFfJ1uynsg0nPWd4VUzg30jcjJSgXWsuXN1OT4zGjtlWijc4zP01tovlI oq5QoBxRkTY7jfMvidNiU5iKrRkyytU7SREd2YTCPbveL2nzJfeFatYfpaw4Rq8pzHVg nFZAeU7t8F+wgBmG6u2aGcge2P7PhzskBS9pMzSCleQUAIJ7Xt6pkQfCLvkZBn2md5dk mj4Q== X-Gm-Message-State: ALoCoQndEBToFsxzfKVYNn9gOWEKyHK/FhlZbSRtSXtTK3xqiLet/eJZL89/TFsNLoz1cYW1Ny3mu/GAhBNu0OaPDIOtSZGdCYsY7l3JB0yE++Mw9M/5hk0= X-Received: by 10.194.5.5 with SMTP id o5mr13688174wjo.16.1396266203397; Mon, 31 Mar 2014 04:43:23 -0700 (PDT) Received: from localhost.localdomain ([91.198.246.8]) by mx.google.com with ESMTPSA id q49sm32467516eem.34.2014.03.31.04.43.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Mar 2014 04:43:22 -0700 (PDT) From: Michal Kazior To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, Michal Kazior Subject: [PATCH v3 09/13] mac80211: split ieee80211_new_chanctx() Date: Mon, 31 Mar 2014 12:39:27 +0200 Message-Id: <1396262371-6466-10-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1396262371-6466-1-git-send-email-michal.kazior@tieto.com> References: <1395409651-26120-1-git-send-email-michal.kazior@tieto.com> <1396262371-6466-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=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 a12cc23..8e207c0 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c @@ -345,19 +345,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); @@ -367,31 +365,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; }