电子文章 | 电子资料下载 | 家电维修 | 维修资料下载 | 加入收藏 | 全站地图
您现在所在位置:电子爱好者电子文章arm嵌入式linux设备模型中ktype的用法

linux设备模型中ktype的用法

11-20 15:53:34 | http://www.5idzw.com | arm嵌入式 | 人气:153
标签:arm嵌入式系统,arm系统,arm开发,http://www.5idzw.com linux设备模型中ktype的用法,http://www.5idzw.com

  attr->attr.mode = S_IRUGO;

  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";

  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.5idzw.com提供”



  

上一页  [1] [2] 

,linux设备模型中ktype的用法
关于《linux设备模型中ktype的用法》的更多文章