首页 > 代码库 > 驱动笔记 - 混杂设备常用函数

驱动笔记 - 混杂设备常用函数

#include <linux/miscdevice.h>
混杂设备:主设备号为10的字符设备
struct miscdevice
{
int minor; //次设备号
const char *name;
const struct file_operations *fops;
struct list_head list;
struct device *parent;
struct device *this_device;
}

混杂设备注册
int misc_register (struct miscdevice * misc);
int misc_deregister (struct miscdevice * misc);

 

例:

struct miscdevice misc = {
.minor = 12, //若需动态分配填255,不为0为静态分配
.name = DEVICE_NAME,
.fops = &dev_fops,
}

驱动笔记 - 混杂设备常用函数