feature: split module in two file
This commit is contained in:
parent
250977e7f8
commit
4e40010210
1
Makefile
1
Makefile
@ -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
17
hello-1.c
Normal 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");
|
@ -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");
|
Loading…
Reference in New Issue
Block a user