wifi: cfg80211: Add KHZ_PER_GHZ to units.h and reuse
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 15 Feb 2024 15:41:36 +0000 (17:41 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 21 Feb 2024 14:19:03 +0000 (15:19 +0100)
The KHZ_PER_GHZ might be used by others (with the name aligned
with similar constants). Define it in units.h and convert
wireless to use it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://msgid.link/20240215154136.630029-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/linux/units.h
net/wireless/reg.c

index 45110daaf8d3260ced995b66ba62669e8b29ddfa..00e15de33eca2f870d2e2e4301ed6d5aedcec4f0 100644 (file)
 #define NANOHZ_PER_HZ          1000000000UL
 #define MICROHZ_PER_HZ         1000000UL
 #define MILLIHZ_PER_HZ         1000UL
+
 #define HZ_PER_KHZ             1000UL
-#define KHZ_PER_MHZ            1000UL
 #define HZ_PER_MHZ             1000000UL
 
+#define KHZ_PER_MHZ            1000UL
+#define KHZ_PER_GHZ            1000000UL
+
 #define MILLIWATT_PER_WATT     1000UL
 #define MICROWATT_PER_MILLIWATT        1000UL
 #define MICROWATT_PER_WATT     1000000UL
index 50cadbad485fb927c85e709a9ca1293d4b273763..753f8e9aa4b1959cb8e98c03132c5c07bd903a43 100644 (file)
@@ -57,6 +57,8 @@
 #include <linux/verification.h>
 #include <linux/moduleparam.h>
 #include <linux/firmware.h>
+#include <linux/units.h>
+
 #include <net/cfg80211.h>
 #include "core.h"
 #include "reg.h"
@@ -1289,20 +1291,17 @@ static bool is_valid_rd(const struct ieee80211_regdomain *rd)
 static bool freq_in_rule_band(const struct ieee80211_freq_range *freq_range,
                              u32 freq_khz)
 {
-#define ONE_GHZ_IN_KHZ 1000000
        /*
         * From 802.11ad: directional multi-gigabit (DMG):
         * Pertaining to operation in a frequency band containing a channel
         * with the Channel starting frequency above 45 GHz.
         */
-       u32 limit = freq_khz > 45 * ONE_GHZ_IN_KHZ ?
-                       20 * ONE_GHZ_IN_KHZ : 2 * ONE_GHZ_IN_KHZ;
+       u32 limit = freq_khz > 45 * KHZ_PER_GHZ ? 20 * KHZ_PER_GHZ : 2 * KHZ_PER_GHZ;
        if (abs(freq_khz - freq_range->start_freq_khz) <= limit)
                return true;
        if (abs(freq_khz - freq_range->end_freq_khz) <= limit)
                return true;
        return false;
-#undef ONE_GHZ_IN_KHZ
 }
 
 /*