Created
April 16, 2013 11:48
-
-
Save creamidea/5395322 to your computer and use it in GitHub Desktop.
在外部调用函数实例:
The linux Kernel Module Programming
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <linux/module.h> | |
#include <linux/kernel.h> | |
#include <linux/init.h> | |
#include <linux/moduleparam.h> /* Param header */ | |
#define DRIVER_AUTHOR "icecream <[email protected]>" | |
#define DRIVER_DESC "A sample driver" | |
extern void myfun(void); //这里声明外部函数 | |
static int __init export_init(void) | |
{ | |
///////////////////////////////// | |
printk("In export1: "); | |
myfun(); //这里调用函数 | |
return 0; | |
} | |
static void __exit export_exit(void) | |
{ | |
printk("Exit the driver module!\n"); | |
} | |
module_init(export_init); /* enter */ | |
module_exit(export_exit); /* out */ | |
MODULE_LICENSE("Dual BSD/GPL"); | |
MODULE_AUTHOR(DRIVER_AUTHOR); | |
MODULE_DESCRIPTION(DRIVER_DESC); | |
MODULE_ALIAS("First Module"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment