[Lkw] [PATCH] nvme-cmb: create an initial stub module

Marco AR marcoalrey at gmail.com
Fri Sep 15 10:02:30 EDT 2023


Linux modules have init and exit handlers that are called when a module
is loaded and unloaded.  While for a minimal module one of them would
be enough, having only an init handler but not exit one will make the
module unloadable, so we do both.

Signed-off-by: Marco AR <marcoalrey at gmail.com>
---
 drivers/block/nvme-cmb.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/block/nvme-cmb.c b/drivers/block/nvme-cmb.c
index 617d2db9cb94..5394b4e771d6 100644
--- a/drivers/block/nvme-cmb.c
+++ b/drivers/block/nvme-cmb.c
@@ -1,3 +1,19 @@
+#include <linux/init.h>
 #include <linux/module.h>
+#include <linux/kernel.h>
 
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("Dual BSD/GPL");
+
+static int __init nvme_cmb_init(void)
+{
+	 pr_info("loading nvme-cmb module\n");
+	 return 0;
+}
+
+static void __exit nvme_cmb_exit(void)
+{
+	 pr_info("unloading nvme-cmb module\n");
+}
+
+module_init(nvme_cmb_init);
+module_exit(nvme_cmb_exit);
-- 
2.39.2




More information about the LKW mailing list