summaryrefslogtreecommitdiff
path: root/drivers/thunderbolt
diff options
context:
space:
mode:
authorMika Westerberg <mika.westerberg@linux.intel.com>2020-08-24 12:46:52 +0300
committerMika Westerberg <mika.westerberg@linux.intel.com>2020-09-16 14:57:46 +0300
commit2c6ea4e2cefe2e86af782a5b8e1070f4d434f2f2 (patch)
tree7120f7cb51581c70ed207203cccb28145740a666 /drivers/thunderbolt
parent884e4d576fdf6780a896bc9f7a2fe73fce5aa66a (diff)
thunderbolt: Allow KUnit tests to be built also when CONFIG_USB4=m
This adds a bit more build coverage for the tests even though these are not expected to be enabled by normal users and distros. In order to make this working we need to open-code kunit_test_suite() and call the relevant functions directly in the driver init/exit hook. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Diffstat (limited to 'drivers/thunderbolt')
-rw-r--r--drivers/thunderbolt/Kconfig2
-rw-r--r--drivers/thunderbolt/Makefile3
-rw-r--r--drivers/thunderbolt/domain.c4
-rw-r--r--drivers/thunderbolt/tb.h8
-rw-r--r--drivers/thunderbolt/test.c13
5 files changed, 26 insertions, 4 deletions
diff --git a/drivers/thunderbolt/Kconfig b/drivers/thunderbolt/Kconfig
index 2257c22f8ab3..afa3551633aa 100644
--- a/drivers/thunderbolt/Kconfig
+++ b/drivers/thunderbolt/Kconfig
@@ -28,5 +28,5 @@ config USB4_DEBUGFS_WRITE
config USB4_KUNIT_TEST
bool "KUnit tests"
+ depends on USB4
depends on KUNIT=y
- depends on USB4=y
diff --git a/drivers/thunderbolt/Makefile b/drivers/thunderbolt/Makefile
index 61d5dff445b6..571537371072 100644
--- a/drivers/thunderbolt/Makefile
+++ b/drivers/thunderbolt/Makefile
@@ -6,5 +6,4 @@ thunderbolt-objs += nvm.o retimer.o quirks.o
thunderbolt-${CONFIG_ACPI} += acpi.o
thunderbolt-$(CONFIG_DEBUG_FS) += debugfs.o
-
-obj-${CONFIG_USB4_KUNIT_TEST} += test.o
+thunderbolt-${CONFIG_USB4_KUNIT_TEST} += test.o
diff --git a/drivers/thunderbolt/domain.c b/drivers/thunderbolt/domain.c
index a0182bf5a5f8..f0de94f7acbf 100644
--- a/drivers/thunderbolt/domain.c
+++ b/drivers/thunderbolt/domain.c
@@ -827,6 +827,8 @@ int tb_domain_init(void)
{
int ret;
+ tb_test_init();
+
tb_debugfs_init();
ret = tb_xdomain_init();
if (ret)
@@ -841,6 +843,7 @@ err_xdomain:
tb_xdomain_exit();
err_debugfs:
tb_debugfs_exit();
+ tb_test_exit();
return ret;
}
@@ -852,4 +855,5 @@ void tb_domain_exit(void)
tb_nvm_exit();
tb_xdomain_exit();
tb_debugfs_exit();
+ tb_test_exit();
}
diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
index 8b04a9deffc7..5687bcf38a9e 100644
--- a/drivers/thunderbolt/tb.h
+++ b/drivers/thunderbolt/tb.h
@@ -1030,4 +1030,12 @@ static inline void tb_switch_debugfs_init(struct tb_switch *sw) { }
static inline void tb_switch_debugfs_remove(struct tb_switch *sw) { }
#endif
+#ifdef CONFIG_USB4_KUNIT_TEST
+int tb_test_init(void);
+void tb_test_exit(void);
+#else
+static inline int tb_test_init(void) { return 0; }
+static inline void tb_test_exit(void) { }
+#endif
+
#endif
diff --git a/drivers/thunderbolt/test.c b/drivers/thunderbolt/test.c
index a4d78811f7e2..464c2d37b992 100644
--- a/drivers/thunderbolt/test.c
+++ b/drivers/thunderbolt/test.c
@@ -1623,4 +1623,15 @@ static struct kunit_suite tb_test_suite = {
.name = "thunderbolt",
.test_cases = tb_test_cases,
};
-kunit_test_suite(tb_test_suite);
+
+static struct kunit_suite *tb_test_suites[] = { &tb_test_suite, NULL };
+
+int tb_test_init(void)
+{
+ return __kunit_test_suites_init(tb_test_suites);
+}
+
+void tb_test_exit(void)
+{
+ return __kunit_test_suites_exit(tb_test_suites);
+}