Skip to content

Instantly share code, notes, and snippets.

@creamidea
Created April 16, 2013 11:48
Show Gist options
  • Save creamidea/5395322 to your computer and use it in GitHub Desktop.
Save creamidea/5395322 to your computer and use it in GitHub Desktop.
在外部调用函数实例: The linux Kernel Module Programming
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/moduleparam.h> /* Param header */
#define DRIVER_AUTHOR "icecream <creamidea@gmail.com>"
#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