[linux]A simple driver of linux

2017-10-23 写技术

hello.c

#include <linux/init.h>
#include <linux/module.h>
static int hello_init(void){
        printk(KERN_INFO "Hello nicholas, driver is comming\n");
        return 0;
}
static void hello_exit(void){
        printk(KERN_INFO "See you, driver");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_AUTHOR("Nicholas Xiao @ log.anycle.com");
MODULE_LICENSE("Dual BSD/GPL");
MODULE_DESCRIPTION("log.anycle.com");
MODULE_ALIAS("Nicholas demo for driver");


Makefile

KVERS = $(shell uname -r)
obj-m += hello.o
default:
        make -C /lib/modules/$(KVERS)/build M=$(CURDIR) modules

标签: linux

发表评论:

Powered by anycle 湘ICP备15001973号-1