当前位置: 技术问答>linux和unix
求教:初遇字符驱动编程问题
来源: 互联网 发布时间:2015-11-26
本文导语: RedHat9 内核2.4.20-8 以下附上源码和编译信息 #define MODULE #define _KERNEL_ ...
RedHat9 内核2.4.20-8
以下附上源码和编译信息
#define MODULE
#define _KERNEL_
#include
#include
#include
#include
/*int init_module(void);
void cleanup_module(void);
static int device_open(struct inode *,struct file *);
static int device_release(struct inode*,struct file*);
static ssize_t device_read(struct inode*,struct file *,char *,size_t);
static ssize_t device_write(struct inode*,struct file*,const char*,size_t);*/
#define SUCCESS 0
#define DEVICE_NAME "chardev"
#define BUF_LEN 80
static int Major;
static int Device_Open=0;
static char msg[BUF_LEN];
static char *msg_Ptr;
static struct file_operations fops;
int init_module(void)
{
Major=register_chrdev(0,DEVICE_NAME,&fops);
if (Major
以下附上源码和编译信息
#define MODULE
#define _KERNEL_
#include
#include
#include
#include
/*int init_module(void);
void cleanup_module(void);
static int device_open(struct inode *,struct file *);
static int device_release(struct inode*,struct file*);
static ssize_t device_read(struct inode*,struct file *,char *,size_t);
static ssize_t device_write(struct inode*,struct file*,const char*,size_t);*/
#define SUCCESS 0
#define DEVICE_NAME "chardev"
#define BUF_LEN 80
static int Major;
static int Device_Open=0;
static char msg[BUF_LEN];
static char *msg_Ptr;
static struct file_operations fops;
int init_module(void)
{
Major=register_chrdev(0,DEVICE_NAME,&fops);
if (Major