[LTP] [PATCH v8 2/4] tst_kconfig: load and unload kernel modules for CONFIG_*=m
Cyril Hrubis
chrubis@suse.cz
Wed Nov 25 11:48:58 CET 2026
Hi!
> +void tst_kconfig_module_unload(void)
> +{
> + const char *name;
> +
> + if (!loaded_module_count)
> + return;
This if is not really needed here.
> + while (loaded_module_count > 0) {
> + name = loaded_modules[--loaded_module_count];
> +
> + tst_res(TDEBUG, "Unloading module '%s'", name);
> +
> + if (!syscall(__NR_delete_module, name, O_NONBLOCK))
> + continue;
> +
> + switch (errno) {
> + case ENOENT: /* already unloaded */
> + case EWOULDBLOCK: /* in use */
> + case EBUSY: /* still loading or unloading */
> + case ENOSYS: /* no CONFIG_MODULE_UNLOAD */
> + break;
> + default:
> + tst_res(TWARN | TERRNO, "Failed to unload module '%s'", name);
> + }
> + }
> +
> + loaded_module_count = 0;
> +}
> +
> static size_t array_len(const char *const kconfigs[])
> {
> size_t i = 0;
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list