mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

Clean up the existing export namespace code along the same lines of
commit 33def8498f
("treewide: Convert macro and uses of __section(foo)
to __section("foo")") and for the same reason, it is not desired for the
namespace argument to be a macro expansion itself.
Scripted using
git grep -l -e MODULE_IMPORT_NS -e EXPORT_SYMBOL_NS | while read file;
do
awk -i inplace '
/^#define EXPORT_SYMBOL_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/^#define MODULE_IMPORT_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/MODULE_IMPORT_NS/ {
$0 = gensub(/MODULE_IMPORT_NS\(([^)]*)\)/, "MODULE_IMPORT_NS(\"\\1\")", "g");
}
/EXPORT_SYMBOL_NS/ {
if ($0 ~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+),/) {
if ($0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/ &&
$0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(\)/ &&
$0 !~ /^my/) {
getline line;
gsub(/[[:space:]]*\\$/, "");
gsub(/[[:space:]]/, "", line);
$0 = $0 " " line;
}
$0 = gensub(/(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/,
"\\1(\\2, \"\\3\")", "g");
}
}
{ print }' $file;
done
Requested-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://mail.google.com/mail/u/2/#inbox/FMfcgzQXKWgMmjdFwwdsfgxzKpVHWPlc
Acked-by: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
228 lines
4.9 KiB
C
228 lines
4.9 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* KUnit tests for channel helper functions
|
|
*
|
|
* Copyright (C) 2023-2024 Intel Corporation
|
|
*/
|
|
#include <net/cfg80211.h>
|
|
#include <kunit/test.h>
|
|
|
|
MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING");
|
|
|
|
static struct ieee80211_channel chan_6ghz_1 = {
|
|
.band = NL80211_BAND_6GHZ,
|
|
.center_freq = 5955,
|
|
};
|
|
|
|
static struct ieee80211_channel chan_6ghz_5 = {
|
|
.band = NL80211_BAND_6GHZ,
|
|
.center_freq = 5975,
|
|
};
|
|
|
|
static struct ieee80211_channel chan_6ghz_105 = {
|
|
.band = NL80211_BAND_6GHZ,
|
|
.center_freq = 6475,
|
|
};
|
|
|
|
static const struct chandef_compat_case {
|
|
const char *desc;
|
|
/* leave c1 empty for tests for identical */
|
|
struct cfg80211_chan_def c1, c2;
|
|
/* we test both ways around, so c2 should always be the compat one */
|
|
bool compat;
|
|
} chandef_compat_cases[] = {
|
|
{
|
|
.desc = "identical non-HT",
|
|
.c2 = {
|
|
.width = NL80211_CHAN_WIDTH_20_NOHT,
|
|
.chan = &chan_6ghz_1,
|
|
.center_freq1 = 5955,
|
|
},
|
|
.compat = true,
|
|
},
|
|
{
|
|
.desc = "identical 20 MHz",
|
|
.c2 = {
|
|
.width = NL80211_CHAN_WIDTH_20,
|
|
.chan = &chan_6ghz_1,
|
|
.center_freq1 = 5955,
|
|
},
|
|
.compat = true,
|
|
},
|
|
{
|
|
.desc = "identical 40 MHz",
|
|
.c2 = {
|
|
.width = NL80211_CHAN_WIDTH_40,
|
|
.chan = &chan_6ghz_1,
|
|
.center_freq1 = 5955 + 10,
|
|
},
|
|
.compat = true,
|
|
},
|
|
{
|
|
.desc = "identical 80 MHz",
|
|
.c2 = {
|
|
.width = NL80211_CHAN_WIDTH_80,
|
|
.chan = &chan_6ghz_1,
|
|
.center_freq1 = 5955 + 10 + 20,
|
|
},
|
|
.compat = true,
|
|
},
|
|
{
|
|
.desc = "identical 160 MHz",
|
|
.c2 = {
|
|
.width = NL80211_CHAN_WIDTH_160,
|
|
.chan = &chan_6ghz_1,
|
|
.center_freq1 = 5955 + 10 + 20 + 40,
|
|
},
|
|
.compat = true,
|
|
},
|
|
{
|
|
.desc = "identical 320 MHz",
|
|
.c2 = {
|
|
.width = NL80211_CHAN_WIDTH_320,
|
|
.chan = &chan_6ghz_1,
|
|
.center_freq1 = 5955 + 10 + 20 + 40 + 80,
|
|
},
|
|
.compat = true,
|
|
},
|
|
{
|
|
.desc = "20 MHz in 320 MHz\n",
|
|
.c1 = {
|
|
.width = NL80211_CHAN_WIDTH_20,
|
|
.chan = &chan_6ghz_1,
|
|
.center_freq1 = 5955,
|
|
},
|
|
.c2 = {
|
|
.width = NL80211_CHAN_WIDTH_320,
|
|
.chan = &chan_6ghz_1,
|
|
.center_freq1 = 5955 + 10 + 20 + 40 + 80,
|
|
},
|
|
.compat = true,
|
|
},
|
|
{
|
|
.desc = "different 20 MHz",
|
|
.c1 = {
|
|
.width = NL80211_CHAN_WIDTH_20,
|
|
.chan = &chan_6ghz_1,
|
|
.center_freq1 = 5955,
|
|
},
|
|
.c2 = {
|
|
.width = NL80211_CHAN_WIDTH_20,
|
|
.chan = &chan_6ghz_5,
|
|
.center_freq1 = 5975,
|
|
},
|
|
},
|
|
{
|
|
.desc = "different primary 320 MHz",
|
|
.c1 = {
|
|
.width = NL80211_CHAN_WIDTH_320,
|
|
.chan = &chan_6ghz_105,
|
|
.center_freq1 = 6475 + 110,
|
|
},
|
|
.c2 = {
|
|
.width = NL80211_CHAN_WIDTH_320,
|
|
.chan = &chan_6ghz_105,
|
|
.center_freq1 = 6475 - 50,
|
|
},
|
|
},
|
|
{
|
|
/* similar to previous test but one has lower BW */
|
|
.desc = "matching primary 160 MHz",
|
|
.c1 = {
|
|
.width = NL80211_CHAN_WIDTH_160,
|
|
.chan = &chan_6ghz_105,
|
|
.center_freq1 = 6475 + 30,
|
|
},
|
|
.c2 = {
|
|
.width = NL80211_CHAN_WIDTH_320,
|
|
.chan = &chan_6ghz_105,
|
|
.center_freq1 = 6475 - 50,
|
|
},
|
|
.compat = true,
|
|
},
|
|
{
|
|
.desc = "matching primary 160 MHz & punctured secondary 160 Mhz",
|
|
.c1 = {
|
|
.width = NL80211_CHAN_WIDTH_160,
|
|
.chan = &chan_6ghz_105,
|
|
.center_freq1 = 6475 + 30,
|
|
},
|
|
.c2 = {
|
|
.width = NL80211_CHAN_WIDTH_320,
|
|
.chan = &chan_6ghz_105,
|
|
.center_freq1 = 6475 - 50,
|
|
.punctured = 0xf,
|
|
},
|
|
.compat = true,
|
|
},
|
|
{
|
|
.desc = "matching primary 160 MHz & punctured matching",
|
|
.c1 = {
|
|
.width = NL80211_CHAN_WIDTH_160,
|
|
.chan = &chan_6ghz_105,
|
|
.center_freq1 = 6475 + 30,
|
|
.punctured = 0xc0,
|
|
},
|
|
.c2 = {
|
|
.width = NL80211_CHAN_WIDTH_320,
|
|
.chan = &chan_6ghz_105,
|
|
.center_freq1 = 6475 - 50,
|
|
.punctured = 0xc000,
|
|
},
|
|
.compat = true,
|
|
},
|
|
{
|
|
.desc = "matching primary 160 MHz & punctured not matching",
|
|
.c1 = {
|
|
.width = NL80211_CHAN_WIDTH_160,
|
|
.chan = &chan_6ghz_105,
|
|
.center_freq1 = 6475 + 30,
|
|
.punctured = 0x80,
|
|
},
|
|
.c2 = {
|
|
.width = NL80211_CHAN_WIDTH_320,
|
|
.chan = &chan_6ghz_105,
|
|
.center_freq1 = 6475 - 50,
|
|
.punctured = 0xc000,
|
|
},
|
|
},
|
|
};
|
|
|
|
KUNIT_ARRAY_PARAM_DESC(chandef_compat, chandef_compat_cases, desc)
|
|
|
|
static void test_chandef_compat(struct kunit *test)
|
|
{
|
|
const struct chandef_compat_case *params = test->param_value;
|
|
const struct cfg80211_chan_def *ret, *expect;
|
|
struct cfg80211_chan_def c1 = params->c1;
|
|
|
|
/* tests with identical ones */
|
|
if (!params->c1.chan)
|
|
c1 = params->c2;
|
|
|
|
KUNIT_EXPECT_EQ(test, cfg80211_chandef_valid(&c1), true);
|
|
KUNIT_EXPECT_EQ(test, cfg80211_chandef_valid(¶ms->c2), true);
|
|
|
|
expect = params->compat ? ¶ms->c2 : NULL;
|
|
|
|
ret = cfg80211_chandef_compatible(&c1, ¶ms->c2);
|
|
KUNIT_EXPECT_PTR_EQ(test, ret, expect);
|
|
|
|
if (!params->c1.chan)
|
|
expect = &c1;
|
|
|
|
ret = cfg80211_chandef_compatible(¶ms->c2, &c1);
|
|
KUNIT_EXPECT_PTR_EQ(test, ret, expect);
|
|
}
|
|
|
|
static struct kunit_case chandef_compat_test_cases[] = {
|
|
KUNIT_CASE_PARAM(test_chandef_compat, chandef_compat_gen_params),
|
|
{}
|
|
};
|
|
|
|
static struct kunit_suite chandef_compat = {
|
|
.name = "cfg80211-chandef-compat",
|
|
.test_cases = chandef_compat_test_cases,
|
|
};
|
|
|
|
kunit_test_suite(chandef_compat);
|