From patchwork Fri Jan 17 09:11:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gang ZHAO X-Patchwork-Id: 3502871 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 07E009F2E9 for ; Fri, 17 Jan 2014 09:12:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 239922015D for ; Fri, 17 Jan 2014 09:12:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 46CB020158 for ; Fri, 17 Jan 2014 09:12:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751920AbaAQJMY (ORCPT ); Fri, 17 Jan 2014 04:12:24 -0500 Received: from mail-pb0-f50.google.com ([209.85.160.50]:45781 "EHLO mail-pb0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751701AbaAQJMT (ORCPT ); Fri, 17 Jan 2014 04:12:19 -0500 Received: by mail-pb0-f50.google.com with SMTP id rq2so3868244pbb.9 for ; Fri, 17 Jan 2014 01:12:18 -0800 (PST) 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 :mime-version:content-type:content-transfer-encoding; bh=lqMn71BKXvfyAfjpCkiLmPa44dHH5ZsGnKz/c2KhX4w=; b=0rI/qCEtTWVGYoPVFkG9hm60f8aF0FNT6xVRwQTtrAdDa7QN+TegfQXVSZaszGz3+4 9kznh1t8qFzLDsS4CL4jrwTCT0zbU1BMbPlEKfj0946rOnZCHiJLhYC8X9HFNu7XBaho BHtyRkR2R7FnvM1MObAbueoU3resl81LyhykHiwIjTbBy1OC/gW6BB+6DR60zgldQ21u twxuoPdNHWOfijGKDYIGjxpHcJzxqZgcwQVdpZvyBttu0gYxjuDxoiCEe6YCd2X6f94G KiIzRgoZAD6cuAWIHdcjZWfnc4sI6wp1I6+wHiBuN5I1OW9MUM3TZ/x+2OUHe+2Elltu Ft5g== X-Received: by 10.66.139.196 with SMTP id ra4mr802642pab.103.1389949938825; Fri, 17 Jan 2014 01:12:18 -0800 (PST) Received: from localhost.localdomain ([175.153.40.45]) by mx.google.com with ESMTPSA id id1sm21090114pbc.11.2014.01.17.01.12.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Jan 2014 01:12:17 -0800 (PST) From: ZHAO Gang To: Stefano Brivio Cc: Luca Coelho , =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= , "John W. Linville" , , Subject: [PATCH v2] b43: use kernel api to replace b43 specific helper function Date: Fri, 17 Jan 2014 17:11:46 +0800 Message-Id: <8b96c31da0f8a23b8e99ed790e462bd933925041.1389947627.git.gamerh2o@gmail.com> X-Mailer: git-send-email 1.8.4.2 In-Reply-To: References: MIME-Version: 1.0 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.1 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 The b43_freq_to_channel_{2,5}ghz() should be changed to b43_channel_to_freq{2,5}ghz() if we want to use b43 helper function, but a better way is to use kernel api ieee80211_channel_to_frequency() and remove these unnecessary helper function. Signed-off-by: ZHAO Gang --- v2: combine two patches to one. suggested by Luca Coelho and Rafa? Mi?ecki drivers/net/wireless/b43/main.h | 35 ----------------------------------- drivers/net/wireless/b43/xmit.c | 12 ++++++------ 2 files changed, 6 insertions(+), 41 deletions(-) diff --git a/drivers/net/wireless/b43/main.h b/drivers/net/wireless/b43/main.h index abac25e..f476fc3 100644 --- a/drivers/net/wireless/b43/main.h +++ b/drivers/net/wireless/b43/main.h @@ -58,41 +58,6 @@ enum b43_verbosity { #endif }; - -/* Lightweight function to convert a frequency (in Mhz) to a channel number. */ -static inline u8 b43_freq_to_channel_5ghz(int freq) -{ - return ((freq - 5000) / 5); -} -static inline u8 b43_freq_to_channel_2ghz(int freq) -{ - u8 channel; - - if (freq == 2484) - channel = 14; - else - channel = (freq - 2407) / 5; - - return channel; -} - -/* Lightweight function to convert a channel number to a frequency (in Mhz). */ -static inline int b43_channel_to_freq_5ghz(u8 channel) -{ - return (5000 + (5 * channel)); -} -static inline int b43_channel_to_freq_2ghz(u8 channel) -{ - int freq; - - if (channel == 14) - freq = 2484; - else - freq = 2407 + (5 * channel); - - return freq; -} - static inline int b43_is_cck_rate(int rate) { return (rate == B43_CCK_RATE_1MB || diff --git a/drivers/net/wireless/b43/xmit.c b/drivers/net/wireless/b43/xmit.c index 4ae63f4..218a0f3 100644 --- a/drivers/net/wireless/b43/xmit.c +++ b/drivers/net/wireless/b43/xmit.c @@ -806,7 +806,8 @@ void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr) B43_WARN_ON(1); /* FIXME: We don't really know which value the "chanid" contains. * So the following assignment might be wrong. */ - status.freq = b43_channel_to_freq_5ghz(chanid); + status.freq = + ieee80211_channel_to_frequency(chanid, status.band); break; case B43_PHYTYPE_G: status.band = IEEE80211_BAND_2GHZ; @@ -819,13 +820,12 @@ void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr) case B43_PHYTYPE_HT: /* chanid is the SHM channel cookie. Which is the plain * channel number in b43. */ - if (chanstat & B43_RX_CHAN_5GHZ) { + if (chanstat & B43_RX_CHAN_5GHZ) status.band = IEEE80211_BAND_5GHZ; - status.freq = b43_freq_to_channel_5ghz(chanid); - } else { + else status.band = IEEE80211_BAND_2GHZ; - status.freq = b43_freq_to_channel_2ghz(chanid); - } + status.freq = + ieee80211_channel_to_frequency(chanid, status.band); break; default: B43_WARN_ON(1);