------------------------字符设备驱动程序------------------------------
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#include <linux/ioctl.h>
#include <linux/mm.h>
#include <asm/uaccess.h>
#include <linux/blkdev.h>
MODULE_DESCRIPTION(
"a test of char device driver"
);
MODULE_AUTHOR(
"Jerry"
);
MODULE_LICENSE(
"GPL"
);
#define CDRIVER_NAME "simple_chrdev"
int
CDRIVER_MAJOR=0;
int
CDRIVER_MINOR=0;
int
count=1;
static
struct
class
*simple_class;
loff_t simple_llseek(
struct
file *filp,loff_t off,
int
whence);
int
simple_ioctl(
struct
inode *inode,
struct
file *filp,unsigned
int
cmd,unsigned
long
arg);
int
simple_open(
struct
inode *inode,
struct
file *filp);
int
simple_release(
struct
inode *inode,
struct
file *filp);
static
ssize_t simple_read(
struct
file *filp,
char
*buffer,
size_t
count, loff_t *ppos)
{
int
ret;
int
data = 0xdc;
ret=copy_to_user(buffer, (
char
*)&data,
sizeof
(data));
if