linux设备驱动子系统,Linux设备驱动之我看Linux设备模型( 类子系统篇)

struct class_device {

struct list_headnode;/*for internal use by the driver core only*/

struct kobjectkobj;/*for internal use by the driver core only*/

struct class* class;/*指向该设备所属的类,必须*/

dev_tdevt;/* dev_t, creates the sysfs "dev",for internal use by the driver core only*/

struct class_device_attribute *devt_attr;/*for internal use by the driver core only*/

struct class_device_attribute uevent_attr;

struct device* dev;/*指向此设备相关的device结构体,可选。若不为NULL,应是一个从类入口到/sys/devices下相应入口的符号连接,以便用户空间查找设备入口*/

void* class_data;/*私有数据指针*/

struct class_device*parent;/* parent of this child device, if there is one */

struct attribute_group ** groups;/* optional groups */

void(*release)(struct class_device *dev);

int(*uevent)(struct class_device *dev, char **envp,int num_envp, char *buffer, int buffer_size);

charclass_id[BUS_ID_SIZE];/*此类中的唯一的名字*/

};

/*类设备注册函数:*/

int class_device_register(struct class_device *cd);

void class_device_unregister(struct class_device *cd);

/*重命名一个已经注册的类设备入口:*/

int class_device_rename(struct class_device *cd, char *new_name);

/*类设备入口属性:*/

struct class_device_attribute {

struct attribute attr;

ssize_t (*show)(struct class_device *cls, char *buf);

ssize_t (*store)(struct class_device *cls, const char *buf,

size_t count);

};

CLASS_DEVICE_ATTR(_name, _mode, _show, _store);

/*创建和删除除struct class中设备默认属性外的属性*/

int class_device_create_file(struct class_device *cls, const struct class_device_attribute *attr);

void class_device_remove_file(struct class_device *cls, const struct class_device_attribute *attr);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值