* [PATCH] HID: use IS_REACHABLE(CONFIG_HID_KUNIT_TEST) for inlined KUnit tests
@ 2026-12-04 2:05 Pengpeng Hou
2026-12-04 2:31 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-12-04 2:05 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires; +Cc: linux-input, Pengpeng Hou
The HID input and UC-Logic KUnit sources are included by their
respective drivers. With HID, UC-Logic and the test option modular, the
ordinary ifdefs omit the embedded suites from those modules.
Select the includes using IS_REACHABLE. This changes inclusion in the
existing hosts; it does not introduce a separate test module for a
built-in host.
The issue was found by our static-analysis tool and manually reviewed.
Fixes: a64cbf3ce631 ("HID: uclogic: Refactor UGEE v2 string descriptor parsing")
Fixes: a251d6576d2a ("HID: uclogic: Handle wireless device reconnection")
Fixes: a608dc1c0639 ("HID: input: map battery system charging")
Signed-off-by: Pengpeng Hou <hppiscas@163.com>
---
The original patch was prepared with Gemini. Codex assisted with this
review and revision (Assisted-by: gpt 5).
Built hid-input.o, hid-uclogic-core.o, hid-uclogic-params.o on x86-64
with GCC 11.4 and W=1 (CONFIG_HID=m, CONFIG_HID_UCLOGIC=m,
CONFIG_HID_KUNIT_TEST=m, CONFIG_KUNIT=m). With the same configuration
the 3 affected suite symbols were absent before the change and present
afterwards. The suites were not run.
drivers/hid/hid-input.c | 2 +-
drivers/hid/hid-uclogic-core.c | 2 +-
drivers/hid/hid-uclogic-params.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index a4d3536c7af29ad8613be998ba31788992090ca2..c97490fa3f8c9b5142a6e402f9c807f80d245289 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -2478,6 +2478,6 @@ void hidinput_reset_resume(struct hid_device *hid)
}
EXPORT_SYMBOL_GPL(hidinput_reset_resume);
-#ifdef CONFIG_HID_KUNIT_TEST
+#if IS_REACHABLE(CONFIG_HID_KUNIT_TEST)
#include "hid-input-test.c"
#endif
diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c
index eea4238b9421384b2eb4cb455b79a9ab3076efbb..821cc4a72d84809dd258b22d88fa5db966a4369a 100644
--- a/drivers/hid/hid-uclogic-core.c
+++ b/drivers/hid/hid-uclogic-core.c
@@ -657,6 +657,6 @@ MODULE_DESCRIPTION("HID driver for UC-Logic devices not fully compliant with HID
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("HID driver for UC-Logic devices not fully compliant with HID standard");
-#ifdef CONFIG_HID_KUNIT_TEST
+#if IS_REACHABLE(CONFIG_HID_KUNIT_TEST)
#include "hid-uclogic-core-test.c"
#endif
diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c
index ed16f50f21edc8f7fc16f1144eee21253247d402..8c5617bca7a17ec5255faaf5869f697135d3736f 100644
--- a/drivers/hid/hid-uclogic-params.c
+++ b/drivers/hid/hid-uclogic-params.c
@@ -2019,6 +2019,6 @@ cleanup:
return rc;
}
-#ifdef CONFIG_HID_KUNIT_TEST
+#if IS_REACHABLE(CONFIG_HID_KUNIT_TEST)
#include "hid-uclogic-params-test.c"
#endif
base-commit: d06ce6f1eb5eeffd4ebcfde345dc34a98131d106
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] HID: use IS_REACHABLE(CONFIG_HID_KUNIT_TEST) for inlined KUnit tests
2026-12-04 2:05 [PATCH] HID: use IS_REACHABLE(CONFIG_HID_KUNIT_TEST) for inlined KUnit tests Pengpeng Hou
@ 2026-12-04 2:31 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-04 2:31 UTC (permalink / raw)
To: Pengpeng Hou; +Cc: linux-input, dmitry.torokhov
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] HID: IS_REACHABLE() embeds KUnit tests and MODULE_* tags in
hid/uclogic
--
commit 56471648f10e8fd31480b4cebd55002c586cb470
Author: Pengpeng Hou <hppiscas@163.com>
HID: use IS_REACHABLE(CONFIG_HID_KUNIT_TEST) for inlined KUnit tests
This patch replaces #ifdef CONFIG_HID_KUNIT_TEST with
IS_REACHABLE(CONFIG_HID_KUNIT_TEST) in hid-input.c, hid-uclogic-core.c,
and hid-uclogic-params.c so the included KUnit test files are compiled
when both the drivers and CONFIG_HID_KUNIT_TEST are built as modules.
> diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
> index a4d3536c7af29..c97490fa3f8c9 100644
> --- a/drivers/hid/hid-input.c
> +++ b/drivers/hid/hid-input.c
> @@ -2478,6 +2478,6 @@ void hidinput_reset_resume(struct hid_device *hid)
> }
> EXPORT_SYMBOL_GPL(hidinput_reset_resume);
>
> -#ifdef CONFIG_HID_KUNIT_TEST
> +#if IS_REACHABLE(CONFIG_HID_KUNIT_TEST)
> #include "hid-input-test.c"
> #endif
> diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c
> index eea4238b94213..821cc4a72d848 100644
> --- a/drivers/hid/hid-uclogic-core.c
> +++ b/drivers/hid/hid-uclogic-core.c
> @@ -657,6 +657,6 @@ MODULE_DESCRIPTION("HID driver for UC-Logic devices not fully compliant with HID
> MODULE_LICENSE("GPL");
> MODULE_DESCRIPTION("HID driver for UC-Logic devices not fully compliant with HID standard");
>
> -#ifdef CONFIG_HID_KUNIT_TEST
> +#if IS_REACHABLE(CONFIG_HID_KUNIT_TEST)
> #include "hid-uclogic-core-test.c"
> #endif
> diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c
> index ed16f50f21edc..8c5617bca7a17 100644
> --- a/drivers/hid/hid-uclogic-params.c
> +++ b/drivers/hid/hid-uclogic-params.c
> @@ -2019,6 +2019,6 @@ int uclogic_params_init(struct uclogic_params *params,
> return rc;
> }
>
> -#ifdef CONFIG_HID_KUNIT_TEST
> +#if IS_REACHABLE(CONFIG_HID_KUNIT_TEST)
> #include "hid-uclogic-params-test.c"
> #endif
[Severity: Medium]
Should these KUnit test files be embedded directly into hid.ko and
hid-uclogic.ko via IS_REACHABLE()?
In modular builds such as allmodconfig or CONFIG_KUNIT_ALL_TESTS=m, this
gives core hid.ko and hid-uclogic.ko a hard runtime dependency on kunit.ko.
kunit_module_notify() then runs the embedded suites whenever hid.ko or
hid-uclogic.ko loads, and the tests cannot be run or unloaded independently.
All three included test files also contain standalone MODULE_DESCRIPTION(),
MODULE_LICENSE(), and MODULE_AUTHOR() macros, which end up in hid.ko and
hid-uclogic.ko modinfo alongside the drivers' own metadata.
Meanwhile, with the default CONFIG_HID=y and CONFIG_HID_KUNIT_TEST=m,
IS_REACHABLE(CONFIG_HID_KUNIT_TEST) still evaluates to 0 and omits all
three suites.
Instead of embedding tests in host modules, expose the static helpers with
VISIBLE_IF_KUNIT and EXPORT_SYMBOL_IF_KUNIT and build separate modules, as
in Documentation/dev-tools/kunit/usage.rst and f4ceb2a044f6 ("HID: uclogic:
Avoid linking common code into multiple modules").
--
Sashiko AI review · https://sashiko.dev/#/patchset/179634995880.74470.16564934617135542670@163.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-04 2:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 2:05 [PATCH] HID: use IS_REACHABLE(CONFIG_HID_KUNIT_TEST) for inlined KUnit tests Pengpeng Hou
2026-12-04 2:31 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox