Chinaunix首页 | 论坛 | 博客
  • 博客访问: 660702
  • 博文数量: 516
  • 博客积分: 4119
  • 博客等级: 上校
  • 技术积分: 4288
  • 用 户 组: 普通用户
  • 注册时间: 2012-10-30 17:29
文章分类

全部博文(516)

文章存档

2014年(4)

2013年(160)

2012年(352)

分类: LINUX

2012-11-12 14:05:12

linux系统中的每个设备由一个struct device描述:

struct device{

char bus_id{BUS_ID_SIZE}; //在总线上唯一标示该设备的字符串(设备的名字)

struct bus_type *bus; //设备所在总线

struct device_driver *drive; //管理该设备的驱动

..............

}

设备注册

int device_register(struct device *dev)

注销设备

void device_unregister(struct device *dev)

一条总线也是一个设备,也必须按设备注册

设备本身也有属性的,和总线属性相似、

设备属性由struct device_attribute描述:

struct device_attribute

{

struct attribute attr;

ssize_t(*show)(struct dvice *dev,struct device_attribute *attr.char *buf);

ssize_t(*store)(struct device *dev,struct device_attribute *attr, const char *buf,size_t count);

}

创建设备属性文件

int device_create_file(struct device *device,struct device_attribute *entry)

删除属性文件

void device_remove_file(struct device *dev,struct device_attribute *attr)

阅读(263) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~