From: Thomas Pedersen Date: Thu, 2 Apr 2020 01:18:02 +0000 (-0700) Subject: ieee80211: share 802.11 unit conversion helpers X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=746da8202f557961325acb5e5307000d82560c6e;p=carl9170fw.git ieee80211: share 802.11 unit conversion helpers 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 Link: https://lore.kernel.org/r/20200402011810.22947-2-thomas@adapt-ip.com Signed-off-by: Johannes Berg Signed-off-by: Christian Lamparter --- diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h index 0a7dae5..e0658b6 100644 --- a/include/linux/ieee80211.h +++ b/include/linux/ieee80211.h @@ -3341,6 +3341,16 @@ struct element { #define for_each_subelement_extid(sub, extid, element) \ for_each_element_extid(sub, extid, (element)->data, (element)->datalen) +/* convert frequencies */ +#define MHZ_TO_KHZ(freq) ((freq) * 1000) +#define KHZ_TO_MHZ(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) + /** * for_each_element_completed - determine if element parsing consumed all data * @element: element pointer after for_each_element() or friends