LDD3 linux设备驱动程序学习之lddbus

来源:互联网 发布:java aes 32位key 编辑:程序博客网 时间:2024/06/05 10:05

1. struct device不再包含bus_id,取而代之的是.init_name,修改ldd_bus

[cpp] view plain copy
  1. struct device ldd_bus = {  
  2.       .init_name = "ldd0",  
  3.       .release = ldd_bus_release  
修改函数register_ldd_device如下:
   将strncpy(ldddev->dev.bus_id, ldddev->name, BUS_ID_SIZE);
替换为:
   ldddev->dev.init_name = ldddev->name;


修改函数ldd_match如下:
   return !(strncmp(dev->bus_id, driver->name, strlen(driver->name));
修改为
   return !strncmp(dev->init_name, driver->name, strlen(driver->name));

2. 结构体struct bus_type已经改变,不再包含hotplug,取而代之的是uevent,故修改
结构体ldd_bus_type如下:

[cpp] view plain copy
  1. struct bus_type ldd_bus_type = {  
  2.         .name = "ldd",  
  3.         .match = ldd_match,  
  4.         .uevent = ldd_uevent,  
  5. };  
而原来的函数ldd_hotplug用ldd_event来取代如下:

[cpp] view plain copy
  1. static int ldd_uevent(struct device *dev, struct kobj_uevent_env *env) {  
  2.     env->envp[0] = evn->buf;  
  3.     if (snprintf(env->buf, env->buflen, "LDDBUS_VERSION=%s", Version) >= env->buflen)  
  4.        return -ENOMEM;  
  5.    env->envp[1] = NULL;  
  6.    return 0;  

原创粉丝点击