[LTP] [PATCH v3 2/4] tst_kconfig: load and unload kernel modules for CONFIG_*=m
Andrea Cervesato
andrea.cervesato@suse.com
Mon Oct 12 18:09:29 CEST 2026
Hi Li,
> +static const char *module_name_for_config(const char *cfg)
> +{
> + size_t i;
> +
> + for (i = 0; config_module_maps[i].config; i++) {
> + if (!strcmp(config_module_maps[i].config, cfg))
> + return config_module_maps[i].module_name;
> + }
> +
> + return NULL;
> +}
This is used only once, we don't need to define a new function.
We can leave it inside kconfig_module_record().
> +
> +static void kconfig_module_record(const char *cfg)
> +{
> + unsigned int i;
> + const char *mod = module_name_for_config(cfg);
> +
> + if (!mod)
> + return;
> +
> + if (tst_module_is_loaded(mod))
> + return;
> +
> + for (i = 0; i < loaded_module_count; i++) {
> + if (!strcmp(loaded_modules[i], mod))
> + return;
> + }
> +
> + if (loaded_module_count < MAX_LOADED_MODULES)
> + loaded_modules[loaded_module_count++] = mod;
> +}
> +
> static inline int kconfig_parse_line(const char *line,
> struct tst_kconfig_var *vars,
> unsigned int vars_len)
> @@ -268,6 +307,8 @@ out:
> vars[i].choice = 'm';
> kconfig_runtime_check(&vars[i]);
> kconfig_module_check(&vars[i]);
> + if (vars[i].choice == 'm')
This is better to have it inside kconfig_module_record() at the
very beginning as a gate.
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
More information about the ltp
mailing list