#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/cdev.h>
#include <linux/fs.h>/*包含struct file_operations,MAJOR等*/
#include <linux/slab.h>/*kmalloc*/
#include <asm/io.h>/*ioread8...*/
#include <mach/map.h>
#include <mach/regs-gpio.h>
#include <mach/gpio-bank-l.h>/*端口操作用到的三个头文件*/
#define XXX_MAJOR 125
#define DEVICE_NAME "xxx_dev"
#define CMD_1 0;
#define CMD_2 1;
int xxx_major=XXX_MAJOR;
struct XXX_DEV{
struct cdev cdev;
int value;
};
struct XXX_DEV *xxx_dev;
int xxx_open(struct inode* inode,struct file* filp)
{
struct XXX_DEV* dev;
dev=container_of(inode->i_cdev,struct XXX_DEV,cdev);
filp->private_data=dev;
return 0;
}
int xxx_release(struct inode* inode,struct file* filp)
{
return 0;
}
ssize_t xxx_read(struct file* filp,char __user *buf,size_t count,loff_t *f_pos)
{
return 0;
}
ssize_t xxx_write(struct file
Linux驱动开发--Linux字符设备驱动模板
最新推荐文章于 2021-12-23 13:12:41 发布