All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH 1/4] lib/igt_kmod: simplify check for loaded module
@ 2019-04-04 22:39 Lucas De Marchi
  2019-04-04 22:39 ` [igt-dev] [PATCH 2/4] gem_exec_parallel: do not special case the default Lucas De Marchi
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Lucas De Marchi @ 2019-04-04 22:39 UTC (permalink / raw)
  To: igt-dev; +Cc: Lucas De Marchi

No need to go through the list of loaded modules and check one by one.
We can just check if it's in "live" state or if it's builtin.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 lib/igt_kmod.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
index 91662eb3..8d5ac788 100644
--- a/lib/igt_kmod.c
+++ b/lib/igt_kmod.c
@@ -119,25 +119,18 @@ bool
 igt_kmod_is_loaded(const char *mod_name)
 {
 	struct kmod_ctx *ctx = kmod_ctx();
-	struct kmod_list *mod, *list;
+	enum kmod_module_initstate state;
+	struct kmod_module *kmod;
 	bool ret = false;
 
-	if (kmod_module_new_from_loaded(ctx, &list) < 0)
+	if (kmod_module_new_from_name(ctx, mod_name, &kmod) < 0)
 		goto out;
 
-	kmod_list_foreach(mod, list) {
-		struct kmod_module *kmod = kmod_module_get_module(mod);
-		const char *kmod_name = kmod_module_get_name(kmod);
+	state = kmod_module_get_initstate(kmod);
+	ret = state == KMOD_MODULE_LIVE || state == KMOD_MODULE_BUILTIN;
 
-		if (!strcmp(kmod_name, mod_name)) {
-			kmod_module_unref(kmod);
-			ret = true;
-			break;
-		}
-		kmod_module_unref(kmod);
-	}
-	kmod_module_unref_list(list);
 out:
+	kmod_module_unref(kmod);
 	return ret;
 }
 
-- 
2.21.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-04-30 17:09 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-04 22:39 [igt-dev] [PATCH 1/4] lib/igt_kmod: simplify check for loaded module Lucas De Marchi
2019-04-04 22:39 ` [igt-dev] [PATCH 2/4] gem_exec_parallel: do not special case the default Lucas De Marchi
2019-04-04 22:57   ` Chris Wilson
2019-04-04 22:39 ` [igt-dev] [PATCH 3/4] lib: add igt_allow_unlimited_files() Lucas De Marchi
2019-04-04 23:00   ` Chris Wilson
2019-04-04 22:39 ` [igt-dev] [PATCH 4/4] gem_exec_parallel: allow unlimited open files Lucas De Marchi
2019-04-04 23:01   ` Chris Wilson
2019-04-04 23:19 ` [igt-dev] [PATCH 1/4] lib/igt_kmod: simplify check for loaded module Chris Wilson
2019-04-05 16:33   ` Lucas De Marchi
2019-04-04 23:39 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [1/4] " Patchwork
2019-04-05 19:29 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-04-08 11:56   ` Petri Latvala
2019-04-30 17:09     ` Lucas De Marchi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.