wifi: cfg80211: simplify cfg80211_chandef_compatible()
authorJohannes Berg <johannes.berg@intel.com>
Mon, 29 Jan 2024 18:34:47 +0000 (19:34 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 8 Feb 2024 12:07:38 +0000 (13:07 +0100)
commit8f251a0a1566e3e1da0f1d9322c8ffae808a7509
tree10fef1e9013c21821b8135183245c1672bda3948
parentb9d908dc3a294d25c7d6c2f54ca3987cbd98f040
wifi: cfg80211: simplify cfg80211_chandef_compatible()

Simplify cfg80211_chandef_compatible() a bit by switching
c1 and c2 around so that c1 is always the narrower one
(once they're not identical or narrow/S1G). Then we can
just check the various primary channels and exit with the
wider one (c2), or NULL.

Also refactor the primary 40/80/160 function to not have
all the calculations hard-coded, and use a wrapper around
it to check primary 40/80/160 compatibility.

While at it, add some kunit tests for this functionality.

Also expose the new cfg80211_chandef_primary_freq() to
drivers, mac80211 will use it.

Link: https://msgid.link/20240129194108.be3e6eccaba3.I8399c2ff1435d7378e5837794cb5aa6dd2ee1416@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/net/cfg80211.h
net/wireless/chan.c
net/wireless/tests/Makefile
net/wireless/tests/chan.c [new file with mode: 0644]