Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

wifi: cfg80211: Add KHZ_PER_GHZ to units.h and reuse

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>

authored by

Andy Shevchenko and committed by
Johannes Berg
f79ab5d2 ba4b1fa3

+7 -5
+4 -1
include/linux/units.h
··· 24 24 #define NANOHZ_PER_HZ 1000000000UL 25 25 #define MICROHZ_PER_HZ 1000000UL 26 26 #define MILLIHZ_PER_HZ 1000UL 27 + 27 28 #define HZ_PER_KHZ 1000UL 28 - #define KHZ_PER_MHZ 1000UL 29 29 #define HZ_PER_MHZ 1000000UL 30 + 31 + #define KHZ_PER_MHZ 1000UL 32 + #define KHZ_PER_GHZ 1000000UL 30 33 31 34 #define MILLIWATT_PER_WATT 1000UL 32 35 #define MICROWATT_PER_MILLIWATT 1000UL
+3 -4
net/wireless/reg.c
··· 57 57 #include <linux/verification.h> 58 58 #include <linux/moduleparam.h> 59 59 #include <linux/firmware.h> 60 + #include <linux/units.h> 61 + 60 62 #include <net/cfg80211.h> 61 63 #include "core.h" 62 64 #include "reg.h" ··· 1291 1289 static bool freq_in_rule_band(const struct ieee80211_freq_range *freq_range, 1292 1290 u32 freq_khz) 1293 1291 { 1294 - #define ONE_GHZ_IN_KHZ 1000000 1295 1292 /* 1296 1293 * From 802.11ad: directional multi-gigabit (DMG): 1297 1294 * Pertaining to operation in a frequency band containing a channel 1298 1295 * with the Channel starting frequency above 45 GHz. 1299 1296 */ 1300 - u32 limit = freq_khz > 45 * ONE_GHZ_IN_KHZ ? 1301 - 20 * ONE_GHZ_IN_KHZ : 2 * ONE_GHZ_IN_KHZ; 1297 + u32 limit = freq_khz > 45 * KHZ_PER_GHZ ? 20 * KHZ_PER_GHZ : 2 * KHZ_PER_GHZ; 1302 1298 if (abs(freq_khz - freq_range->start_freq_khz) <= limit) 1303 1299 return true; 1304 1300 if (abs(freq_khz - freq_range->end_freq_khz) <= limit) 1305 1301 return true; 1306 1302 return false; 1307 - #undef ONE_GHZ_IN_KHZ 1308 1303 } 1309 1304 1310 1305 /*