字符驱动框架hellop

来源:互联网 发布:非农数据大于预期 编辑:程序博客网 时间:2024/05/16 04:45

文件放在/linux-3.0/drivers/char/hellop

***********************************************************

hellop.c

 

#include<linux/init.h>
#include<linux/module.h>

#include<linux/moduleparam.h>

static char *whom = "world";
static int howmany = 1;
module_param(howmany,int,0);
module_param(whom,charp,0);

static int hellop_init(void)
{
        int i;
        for(i=0;i<howmany;i++){
                printk("++++++++my_hello,%s\n",whom);
        }
        return 0;
}
static void hellop_exit(void)
{
        printk("Goodbye ,this is cruel world!\n");
}
module_init(hellop_init);
module_exit(hellop_exit);
MODULE_LICENSE("GPL");
~                 

*********************************************************

本层Makefile:

obj-$(CONFIG_HELLOP) += hellop.o

*********************************************************

本层Kconfig

config HELLOP
        tristate "This is my_hellop module"
*******************************************************

上层Makefile

obj-$(CONFIG_HELLOP)            += hellop.o

 

*******************************************************

上层Kconfig

source "drivers/char/hellop/Kconfig"

*******************************************************

/linux-3.0目录下.config

CONFIG_HELLOP=y


***************************************************

 

效果:make menuconfig

字符设备驱动中可以看到”This is my_hellop module“选相

0 0