feature: split module in two file

This commit is contained in:
RouxAntoine 2024-04-20 23:51:25 +02:00
parent 250977e7f8
commit 4e40010210
Signed by: antoine
GPG Key ID: 098FB66FC0475E70
3 changed files with 18 additions and 13 deletions

View File

@ -1,4 +1,5 @@
obj-m += hello.o
hello-objs := hello-1.o hello-2.o
KDIR := /usr/src/linux-headers-$(shell uname -r)

17
hello-1.c Normal file
View File

@ -0,0 +1,17 @@
#include <linux/init.h> /* Needed for the __init, __initdata and __exit macros. */
#include <linux/module.h> /* for all kernel modules */
#include <linux/printk.h> /* Needed for pr_info() */
static int intInitData __initdata = 3;
static int __init start_module(void) /* module entry point */
{
pr_info("Hello , user %d !\n", intInitData);
return 0;
}
module_init(start_module);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("My first cool kernel module");
MODULE_AUTHOR("user");

View File

@ -1,30 +1,17 @@
#include <linux/init.h> /* Needed for the __init, __initdata and __exit macros. */
#include <linux/module.h> /* for all kernel modules */
#include <linux/kernel.h> /* for KERN_INFO */
#include <linux/printk.h> /* Needed for pr_info() */
#include <linux/moduleparam.h> /* Needed for module_param() */
static int intInitData __initdata = 3;
static int intParameter = 420;
module_param(intParameter, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
MODULE_PARM_DESC(intParameter, "An integer");
static int __init start_module(void) /* module entry point */
{
pr_info("Hello , user %d !\n", intInitData);
return 0;
}
static void __exit exit_module(void) /* module exit point */
{
printk(KERN_INFO "Goodbye , user param %d!\n", intParameter);
return;
}
module_init(start_module);
module_exit(exit_module);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("My first cool kernel module");
MODULE_AUTHOR("user");