Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp284729ybb; Tue, 31 Mar 2020 23:22:29 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvdZXkDTUgKqhENJU2tnc2fiZCwuM/YV+C3H6CGDT1zzqG8Wbz6n2HcirB4cMsqOxJ/lcbu X-Received: by 2002:a9d:548:: with SMTP id 66mr14163525otw.227.1585722149248; Tue, 31 Mar 2020 23:22:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585722149; cv=none; d=google.com; s=arc-20160816; b=f8bnZfFWF6RsTkeytGuvm17FBXcEvcmI/g6EcTrVldhVvtTsVH8f+GMnJOyHV1PM+8 uNCWv2xh0LKg98uS+4Sj1IkLfOueZpM/rdlj5R+ZMZr/9x3SowWj0vP1iz44ulky2OHQ EQ4U6EOweXJ1sGxEYI1q1BJLVtYvUNW/lQOFoPcrChhJ+qPr4Fim/D7tFGltEFIZw0XN dKFLI9b2bmG62i7ml76kjthyCgo4ixEnH0VzABoM8chEibhhX+mHeEeaA6sPaZi0BMG4 DqvKLiTAOjk6RwxxZTHrzOLs/ZrXhaRREtIompTIz/jnIva7adduMg40vfcKpCFTszPk PIVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=DREPR33o9XDGluZP4IOP1QIUpeWeUCcoXxmyThgSotU=; b=Xk7roi1hj03n9ZqO1r9ivBOZZhciz77gJAx0ym0TMUF7WP3Xi2oozrmsCZzJ3ejIyR jRznP6aNcjbRNsZEZanFLuLZoAn/hoOxot3di5Q3bu5hLpDAFkta0nuMrXEuD+YGC8qp GA1k/wjsPy/rCGGiL0nRlqSf9P5VHfzqYUzRZ3CIC5VlPpzRfR7jsQXt91x/Hl8+H7IT yh8mX0ho+uMyycefg+VT79Hy27RP7Ar5eUnQUDiJsyEoWTOaTnn3j0zNBTLFJ54mHya4 oO5GZjL+2voWSOeCWR6dsdQd+EYt6UrarmGUj2uVdns6hf7Xdd1YX5kEC7Gp+2nU0PF2 ElvA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w83si511337oie.244.2020.03.31.23.22.10; Tue, 31 Mar 2020 23:22:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731807AbgDAGV4 (ORCPT + 99 others); Wed, 1 Apr 2020 02:21:56 -0400 Received: from mail.adapt-ip.com ([173.164.178.19]:36606 "EHLO web.adapt-ip.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731683AbgDAGV4 (ORCPT ); Wed, 1 Apr 2020 02:21:56 -0400 Received: from localhost (localhost [127.0.0.1]) by web.adapt-ip.com (Postfix) with ESMTP id DC0394E16C7; Wed, 1 Apr 2020 06:21:55 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at web.adapt-ip.com Received: from web.adapt-ip.com ([127.0.0.1]) by localhost (web.adapt-ip.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id sN1L9Wmjgx8d; Wed, 1 Apr 2020 06:21:52 +0000 (UTC) Received: from atlas.campbell.adapt-ip.com (gateway.adapt-ip.com [173.164.178.20]) (Authenticated sender: thomas@adapt-ip.com) by web.adapt-ip.com (Postfix) with ESMTPSA id 01BE64F790F; Wed, 1 Apr 2020 06:21:51 +0000 (UTC) From: Thomas Pedersen To: Johannes Berg Cc: linux-wireless , Thomas Pedersen Subject: [RFC 1/7] ieee80211: share 802.11 unit conversion helpers Date: Tue, 31 Mar 2020 23:21:44 -0700 Message-Id: <20200401062150.3324-2-thomas@adapt-ip.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200401062150.3324-1-thomas@adapt-ip.com> References: <20200401062150.3324-1-thomas@adapt-ip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org MHZ_TO_KHZ, and KHZ_TO_MHZ are useful to drivers and elsewhere so export these in the common ieee80211 header. Move the power helpers also because we might as well. Signed-off-by: Thomas Pedersen --- include/linux/ieee80211.h | 11 +++++++++++ include/net/regulatory.h | 7 ------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h index 16268ef1cbcc..02493062a5df 100644 --- a/include/linux/ieee80211.h +++ b/include/linux/ieee80211.h @@ -3323,6 +3323,17 @@ static inline int ieee80211_get_tdls_action(struct sk_buff *skb, u32 hdr_size) #define TU_TO_JIFFIES(x) (usecs_to_jiffies((x) * 1024)) #define TU_TO_EXP_TIME(x) (jiffies + TU_TO_JIFFIES(x)) +/* convert frequencies */ +#define MHZ_TO_KHZ(freq) ((freq) * 1000) +#define KHZ_TO_MHZ(freq) ((freq) / 1000) +#define HZ_TO_KHZ(freq) ((freq) / 1000) + +/* convert powers */ +#define DBI_TO_MBI(gain) ((gain) * 100) +#define MBI_TO_DBI(gain) ((gain) / 100) +#define DBM_TO_MBM(gain) ((gain) * 100) +#define MBM_TO_DBM(gain) ((gain) / 100) + /** * ieee80211_action_contains_tpc - checks if the frame contains TPC element * @skb: the skb containing the frame, length will be checked diff --git a/include/net/regulatory.h b/include/net/regulatory.h index 3469750df0f4..09a3099886e5 100644 --- a/include/net/regulatory.h +++ b/include/net/regulatory.h @@ -231,13 +231,6 @@ struct ieee80211_regdomain { struct ieee80211_reg_rule reg_rules[]; }; -#define MHZ_TO_KHZ(freq) ((freq) * 1000) -#define KHZ_TO_MHZ(freq) ((freq) / 1000) -#define DBI_TO_MBI(gain) ((gain) * 100) -#define MBI_TO_DBI(gain) ((gain) / 100) -#define DBM_TO_MBM(gain) ((gain) * 100) -#define MBM_TO_DBM(gain) ((gain) / 100) - #define REG_RULE_EXT(start, end, bw, gain, eirp, dfs_cac, reg_flags) \ { \ .freq_range.start_freq_khz = MHZ_TO_KHZ(start), \ -- 2.20.1