linux设备模型中ktype的用法
[11-20 15:53:34] 来源:http://www.88dzw.com arm嵌入式 阅读:8153次
文章摘要:attr->attr.owner = parent_class->owner;attr->show = show_dev;error = class_device_create_file(class_dev, attr);static ssize_t show_dev(struct class_device *class_dev, char *buf){return print_dev_t(buf, class_dev->devt);//上文中将打印出“252:0”}class_dev->uevent_attr.attr.name = "uevent&q
linux设备模型中ktype的用法,标签:arm嵌入式系统,arm系统,http://www.88dzw.comattr->attr.owner = parent_class->owner;
attr->show = show_dev;
error = class_device_create_file(class_dev, attr);
static ssize_t show_dev(struct class_device *class_dev, char *buf)
{
return print_dev_t(buf, class_dev->devt);//上文中将打印出“252:0”
}
class_dev->uevent_attr.attr.name = "uevent";
class_dev->uevent_attr.attr.mode = S_IWUSR;
class_dev->uevent_attr.attr.owner = parent_class->owner;
class_dev->uevent_attr.store = store_uevent;
error = class_device_create_file(class_dev, &class_dev->uevent_attr);
static ssize_t store_uevent(struct class_device *class_dev,
const char *buf, size_t count)
{
kobject_uevent(&class_dev->kobj, KOBJ_ADD);
return count;
}
可以看出无论写入什么值都会触发KOBJ_ADD事件,内核调用kobject_uevent函数发送netlink message给用户空间用户层,用户空间可以用udev通过取到此事件,从而处理热插拔事件。
“www.88dzw.com提供”
《linux设备模型中ktype的用法》相关文章
- › 基于Linux下USB主机接口设计
- › 基于嵌入式Linux的TFT LCD IP及驱动的设计
- › 基于Linux平台的FPGA驱动开发
- › Linux PC和51系列单片机串行通信的设计
- › 利用MLD自动化操作系统移植降低 Linux 的成本
- › ColdFire单片机在 Clinux上的应用
- 在百度中搜索相关文章:linux设备模型中ktype的用法
- 在谷歌中搜索相关文章:linux设备模型中ktype的用法
- 在soso中搜索相关文章:linux设备模型中ktype的用法
- 在搜狗中搜索相关文章:linux设备模型中ktype的用法