[Accel-config] [PATCH v1 5/6] accel-config: Make idxd_mdev module optional

ramesh.thomas at intel.com
Newsgroups dev.linux.lists.accel-config
Message-ID <[email protected]>
From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Add conditional load and unload of idxd_mdev and make existence
of the module optional.

Signed-off-by: Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 test/libaccfg.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/test/libaccfg.c b/test/libaccfg.c
index 88108a9..031b7fa 100644
--- a/test/libaccfg.c
+++ b/test/libaccfg.c
@@ -1067,12 +1067,16 @@ static int idxd_kmod_init(struct kmod_ctx **ctx, struct kmod_module **mod,
 	if (rc == -ENOENT)
 		rc = kmod_module_probe_insert_module(*mdev_mod, 0, NULL, NULL, NULL,
 				NULL);
-	if (rc >= 0)
-		rc = kmod_module_get_initstate(*mod);
-
 	if (rc < 0) {
-		kmod_module_unref(*mod);
 		kmod_module_unref(*mdev_mod);
+		*mdev_mod = NULL;
+	}
+	rc = kmod_module_get_initstate(*mod);
+	if (rc == -ENOENT)
+		rc = kmod_module_probe_insert_module(*mod, 0, NULL, NULL, NULL,
+				NULL);
+	if (rc < 0) {
+		kmod_module_unref(*mod);
 		kmod_unref(*ctx);
 	}
 
@@ -1140,10 +1144,13 @@ int test_libaccfg(int loglevel, struct accfg_test *test,
 
 	test_cleanup(ctx);
 
-	kmod_module_remove_module(mdev_mod, 0);
-	kmod_module_probe_insert_module(mdev_mod, 0, NULL, NULL, NULL, NULL);
+	if (mdev_mod) {
+		kmod_module_remove_module(mdev_mod, 0);
+		kmod_module_unref(mdev_mod);
+	}
+	kmod_module_remove_module(mod, 0);
+	kmod_module_probe_insert_module(mod, 0, NULL, NULL, NULL, NULL);
 	kmod_module_unref(mod);
-	kmod_module_unref(mdev_mod);
 	kmod_unref(kmod_ctx);
 
 	return result;
-- 
2.26.2
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.