misc混杂设备和sysfs设备(Linux驱动8)

misc混杂设备:

说明:

混杂设备包括nvram,看门狗,ds1286时钟,lcd等.混杂设备本质还是字符设备,其功能实现于file_operations.
混杂设备主设备号为10.

变量:

struct miscdevice{
int minor;
char *name
file_operatios *fops
list_head list;
struct device *parent;
struct device *this_device;
}

函数:

misc_register(struct miscdevice *dev);
misc_unregister(struct miscdevice *dev);

sysfs设备:

说明:

sysfs设备没有在dev目录下有节点,但是可以在用户侧直接访问.通过sysfs_create_file创建的文件,每个device的attribute对应一个文件
文件通过show和store方法来存取.

变量:

sysdev_driver{
list_head entry;
(add)(struct sys_device);
(remove)(struct sys_device );
(shutdown)(struct sys_device );
(suspend)(struct sys_device );
(resume)(struct sys_device);
}

struct attribute{
const char name;
umode_t mode;
}

struct device_attribute{
struct attribute attr
ssize_t (show)(struct device *dev,struct device_attribute);
ssize_t (store)(struct device *dev,struct device_attribute);
}

struct bin_attribute{
struct attribute attr;
size
read
}

函数:

sysdev_driver_register(struct sysdev_class*,struct sysdev_driver*);

sysdev_driver_unregister(struct sysdev_class ,struct sysdev_driver);

sysdev_create_file(struct sys_device dev,struct sysdev_attribute);

sysdev_remove_file(struct sys_device dev,struct sysdev_attribute);

相关函数:

sysfs_create_file(struct kobject*obj,struct attribute *);

sysfs_remove_file(struct kobject*obj,struct attribute *);

device_create_file(struct device*dev,struct device_arrtibute*);

device_remove_file(struct device*dev,struct device_arrtibute*);

sysfs_create_bin_file(struct kobject,struct bin_attribure *);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值