当前位置: 技术问答>linux和unix
求助!自写驱动编译出错。
来源: 互联网 发布时间:2015-11-14
本文导语: 环境 red hat 9 kernel (2.4.20-8) 程序抄自《ARM & Linux 嵌入式系统教程》 代码 /**********************************************************/ #include #include #include #include #include #define DEMO_MAJOR 125 #define COMMAND1 1 #define COMMAND2 2...
环境 red hat 9 kernel (2.4.20-8)
程序抄自《ARM & Linux 嵌入式系统教程》
代码
/**********************************************************/
#include
#include
#include
#include
#include
#define DEMO_MAJOR 125
#define COMMAND1 1
#define COMMAND2 2
static int demo_init(void);
static int demo_open(struct inode *inode,struct file *file);
static int demo_close(struct inode *inode,struct file *file);
static ssize_t demo_read(struct file *file,char *buf,size_t count,loff_t *offset);
static int demo_ioctl(struct inode *inode,struct file *file,unsigned int cmd,unsigned long arg);
static void demo_cleanup(void);
int demo_param = 9;
static int demo_initialized = 0;
static volatile int demo_flag = 0;
static struct file_operations demo_fops = {
owner:THIS_MODULE,
llseek:NULL,
read:demo_read,
write:NULL,
ioctl:demo_ioctl,
open:demo_open,
release:demo_close,
};
static int demo_init(void)
{
int i;
if(demo_initialized == 1)
return 0;
i = register_chrdev(DEMO_MAJOR,"demo_drv",&demo_fops);
if(i
程序抄自《ARM & Linux 嵌入式系统教程》
代码
/**********************************************************/
#include
#include
#include
#include
#include
#define DEMO_MAJOR 125
#define COMMAND1 1
#define COMMAND2 2
static int demo_init(void);
static int demo_open(struct inode *inode,struct file *file);
static int demo_close(struct inode *inode,struct file *file);
static ssize_t demo_read(struct file *file,char *buf,size_t count,loff_t *offset);
static int demo_ioctl(struct inode *inode,struct file *file,unsigned int cmd,unsigned long arg);
static void demo_cleanup(void);
int demo_param = 9;
static int demo_initialized = 0;
static volatile int demo_flag = 0;
static struct file_operations demo_fops = {
owner:THIS_MODULE,
llseek:NULL,
read:demo_read,
write:NULL,
ioctl:demo_ioctl,
open:demo_open,
release:demo_close,
};
static int demo_init(void)
{
int i;
if(demo_initialized == 1)
return 0;
i = register_chrdev(DEMO_MAJOR,"demo_drv",&demo_fops);
if(i