From patchwork Sat Apr 19 16:32:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gang ZHAO X-Patchwork-Id: 4020211 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 E8823BFF02 for ; Sat, 19 Apr 2014 16:34:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D39E9201DC for ; Sat, 19 Apr 2014 16:34:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AB729201D5 for ; Sat, 19 Apr 2014 16:34:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754604AbaDSQeC (ORCPT ); Sat, 19 Apr 2014 12:34:02 -0400 Received: from mail-pb0-f47.google.com ([209.85.160.47]:34217 "EHLO mail-pb0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752448AbaDSQeA (ORCPT ); Sat, 19 Apr 2014 12:34:00 -0400 Received: by mail-pb0-f47.google.com with SMTP id up15so2384290pbc.34 for ; Sat, 19 Apr 2014 09:34:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=kR2QSxguJH47Eb7jzG/XkCMBcbb2jvQdrm6at4UKC44=; b=lCLB3AeWIqJ6qrXQOrk8+VSMdlVnrEiAxSZYUQAj7PrwhR6RFfeXQnWeJfu0w49/WQ LQ2b9fglBhdNVpQYEjrPRF3nmyPY4Pgk2VOPrRdOJeO5qpcSClWHVve2xm6b0HlqgBNU oZK1YcwWD8Cjuolw/g+FMRep+fjd9vA5i5i23og/gwq0jpOlpt2CJp2K/ks7+/zgSgCQ qCW9LCty/kg5ULiF2a/9ZuHJQ4AGYerPGvixZal27KZYFcPkSd/gVpl0P6ptN6JSBaQT 9oqzNMbA8lNzpSDfWK3bjrzFvfMgS8HoJ+zoI5WBHBP5Ydg4fLxJbqzN/wBwt/O1R3d0 lQ/w== X-Received: by 10.69.2.2 with SMTP id bk2mr28333815pbd.75.1397925240234; Sat, 19 Apr 2014 09:34:00 -0700 (PDT) Received: from localhost.localdomain ([175.153.40.107]) by mx.google.com with ESMTPSA id e6sm67112715pbg.4.2014.04.19.09.33.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Apr 2014 09:33:59 -0700 (PDT) From: "Zhao, Gang" To: Cc: Johannes Berg Subject: [PATCH 2/3] cfg80211/mac80211: rename cfg80211_chandef_dfs_required() Date: Sun, 20 Apr 2014 00:32:38 +0800 Message-Id: <2cb4d1718de3cbda2d9a26b4da3100ded10ae730.1397924746.git.gamerh2o@gmail.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: References: In-Reply-To: References: 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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 Change the name to cfg80211_chandef_dfs_check to emphasize that the function isn't a yes/no function, its return value must be fully checked. Also rename the helper function's name to cfg80211_do_chandef_dfs_check for consistency. Variable width needn't to be checked for sanity, since above cfg80211_chandef_valid() already checked the sanity of chandef->width. Signed-off-by: Zhao, Gang --- include/net/cfg80211.h | 6 +++--- net/mac80211/ibss.c | 12 ++++++------ net/mac80211/mesh.c | 4 ++-- net/wireless/chan.c | 32 +++++++++++++++----------------- net/wireless/mesh.c | 2 +- net/wireless/nl80211.c | 8 ++++---- net/wireless/trace.h | 2 +- 7 files changed, 32 insertions(+), 34 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 6eb2420..54d4f67 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -438,13 +438,13 @@ bool cfg80211_chandef_usable(struct wiphy *wiphy, u32 prohibited_flags); /** - * cfg80211_chandef_dfs_required - checks if radar detection is required + * cfg80211_chandef_dfs_check - checks if radar detection is required * @wiphy: the wiphy to validate against * @chandef: the channel definition to check * Return: 1 if radar detection is required, 0 if it is not, < 0 on error */ -int cfg80211_chandef_dfs_required(struct wiphy *wiphy, - const struct cfg80211_chan_def *chandef); +int cfg80211_chandef_dfs_check(struct wiphy *wiphy, + const struct cfg80211_chan_def *chandef); /** * ieee80211_chandef_rate_flags - returns rate flags for a channel diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index 06d2878..18dd2e2 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c @@ -281,8 +281,8 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, } } - err = cfg80211_chandef_dfs_required(sdata->local->hw.wiphy, - &chandef); + err = cfg80211_chandef_dfs_check(sdata->local->hw.wiphy, + &chandef); if (err < 0) { sdata_info(sdata, "Failed to join IBSS, invalid chandef\n"); @@ -774,8 +774,8 @@ static void ieee80211_ibss_csa_mark_radar(struct ieee80211_sub_if_data *sdata) /* if the current channel is a DFS channel, mark the channel as * unavailable. */ - err = cfg80211_chandef_dfs_required(sdata->local->hw.wiphy, - &ifibss->chandef); + err = cfg80211_chandef_dfs_check(sdata->local->hw.wiphy, + &ifibss->chandef); if (err > 0) cfg80211_radar_event(sdata->local->hw.wiphy, &ifibss->chandef, GFP_ATOMIC); @@ -872,8 +872,8 @@ ieee80211_ibss_process_chanswitch(struct ieee80211_sub_if_data *sdata, goto disconnect; } - err = cfg80211_chandef_dfs_required(sdata->local->hw.wiphy, - ¶ms.chandef); + err = cfg80211_chandef_dfs_check(sdata->local->hw.wiphy, + ¶ms.chandef); if (err < 0) goto disconnect; if (err) { diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index f70e9cd..33cf125 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c @@ -902,8 +902,8 @@ ieee80211_mesh_process_chnswitch(struct ieee80211_sub_if_data *sdata, return false; } - err = cfg80211_chandef_dfs_required(sdata->local->hw.wiphy, - ¶ms.chandef); + err = cfg80211_chandef_dfs_check(sdata->local->hw.wiphy, + ¶ms.chandef); if (err < 0) return false; if (err) { diff --git a/net/wireless/chan.c b/net/wireless/chan.c index 2cfff9e..aaf24fc 100644 --- a/net/wireless/chan.c +++ b/net/wireless/chan.c @@ -303,9 +303,9 @@ static u32 cfg80211_get_end_freq(u32 center_freq, return end_freq; } -static int cfg80211_get_chans_dfs_required(struct wiphy *wiphy, - u32 center_freq, - u32 bandwidth) +static int cfg80211_do_chandef_dfs_check(struct wiphy *wiphy, + u32 center_freq, + u32 bandwidth) { struct ieee80211_channel *c; u32 freq, start_freq, end_freq; @@ -325,8 +325,8 @@ static int cfg80211_get_chans_dfs_required(struct wiphy *wiphy, } -int cfg80211_chandef_dfs_required(struct wiphy *wiphy, - const struct cfg80211_chan_def *chandef) +int cfg80211_chandef_dfs_check(struct wiphy *wiphy, + const struct cfg80211_chan_def *chandef) { int width; int r; @@ -335,21 +335,19 @@ int cfg80211_chandef_dfs_required(struct wiphy *wiphy, return -EINVAL; width = cfg80211_chandef_get_width(chandef); - if (width < 0) - return -EINVAL; - r = cfg80211_get_chans_dfs_required(wiphy, chandef->center_freq1, - width); + r = cfg80211_do_chandef_dfs_check(wiphy, chandef->center_freq1, + width); if (r) return r; if (!chandef->center_freq2) return 0; - return cfg80211_get_chans_dfs_required(wiphy, chandef->center_freq2, - width); + return cfg80211_do_chandef_dfs_check(wiphy, chandef->center_freq2, + width); } -EXPORT_SYMBOL(cfg80211_chandef_dfs_required); +EXPORT_SYMBOL(cfg80211_chandef_dfs_check); static int cfg80211_get_chans_dfs_usable(struct wiphy *wiphy, u32 center_freq, @@ -671,7 +669,7 @@ bool cfg80211_reg_can_beacon(struct wiphy *wiphy, trace_cfg80211_reg_can_beacon(wiphy, chandef); - if (cfg80211_chandef_dfs_required(wiphy, chandef) > 0 && + if (cfg80211_chandef_dfs_check(wiphy, chandef) > 0 && cfg80211_chandef_dfs_available(wiphy, chandef)) { /* We can skip IEEE80211_CHAN_NO_IR if chandef dfs available */ prohibited_flags = IEEE80211_CHAN_DISABLED; @@ -743,8 +741,8 @@ cfg80211_get_chan_state(struct wireless_dev *wdev, *chan = wdev->chandef.chan; *chanmode = CHAN_MODE_SHARED; - if (cfg80211_chandef_dfs_required(wdev->wiphy, - &wdev->chandef) > 0) + if (cfg80211_chandef_dfs_check(wdev->wiphy, + &wdev->chandef) > 0) *radar_detect |= BIT(wdev->chandef.width); } return; @@ -753,8 +751,8 @@ cfg80211_get_chan_state(struct wireless_dev *wdev, *chan = wdev->chandef.chan; *chanmode = CHAN_MODE_SHARED; - if (cfg80211_chandef_dfs_required(wdev->wiphy, - &wdev->chandef) > 0) + if (cfg80211_chandef_dfs_check(wdev->wiphy, + &wdev->chandef) > 0) *radar_detect |= BIT(wdev->chandef.width); } return; diff --git a/net/wireless/mesh.c b/net/wireless/mesh.c index 5af5cc6..d196a7c 100644 --- a/net/wireless/mesh.c +++ b/net/wireless/mesh.c @@ -178,7 +178,7 @@ int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev, if (!cfg80211_reg_can_beacon(&rdev->wiphy, &setup->chandef)) return -EINVAL; - err = cfg80211_chandef_dfs_required(wdev->wiphy, &setup->chandef); + err = cfg80211_chandef_dfs_check(wdev->wiphy, &setup->chandef); if (err < 0) return err; if (err) diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index b6b2f6f..305ede8 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -3261,7 +3261,7 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info) if (!cfg80211_reg_can_beacon(&rdev->wiphy, ¶ms.chandef)) return -EINVAL; - err = cfg80211_chandef_dfs_required(wdev->wiphy, ¶ms.chandef); + err = cfg80211_chandef_dfs_check(wdev->wiphy, ¶ms.chandef); if (err < 0) return err; if (err) { @@ -5796,7 +5796,7 @@ static int nl80211_start_radar_detection(struct sk_buff *skb, if (wdev->cac_started) return -EBUSY; - err = cfg80211_chandef_dfs_required(wdev->wiphy, &chandef); + err = cfg80211_chandef_dfs_check(wdev->wiphy, &chandef); if (err < 0) return err; @@ -5936,8 +5936,8 @@ skip_beacons: case NL80211_IFTYPE_P2P_GO: case NL80211_IFTYPE_ADHOC: case NL80211_IFTYPE_MESH_POINT: - err = cfg80211_chandef_dfs_required(wdev->wiphy, - ¶ms.chandef); + err = cfg80211_chandef_dfs_check(wdev->wiphy, + ¶ms.chandef); if (err < 0) return err; if (err) { diff --git a/net/wireless/trace.h b/net/wireless/trace.h index aabccf1..80770f4 100644 --- a/net/wireless/trace.h +++ b/net/wireless/trace.h @@ -2207,7 +2207,7 @@ TRACE_EVENT(cfg80211_reg_can_beacon, WIPHY_PR_ARG, CHAN_DEF_PR_ARG) ); -TRACE_EVENT(cfg80211_chandef_dfs_required, +TRACE_EVENT(cfg80211_chandef_dfs_check, TP_PROTO(struct wiphy *wiphy, struct cfg80211_chan_def *chandef), TP_ARGS(wiphy, chandef), TP_STRUCT__entry(