398 struct klist_node knode_bus;
399 struct device * parent;
400
401 struct kobject kobj;
402 char bus_id[BUS_ID_SIZE]; /* position on parent bus */
403 struct device_type *type;
404 unsigned is_registered:1;
405 struct device_attribute uevent_attr;
406 struct device_attribute *devt_attr;
407
408 struct semaphore sem; /* semaphore to synchronize calls to
409 * its driver.
410 */
411
412 struct bus_type * bus; /* type of bus device is on */
413 struct device_driver *driver; /* which driver has allocated this
414 device */
415 void *driver_data; /* data private to the driver */
416 void *platform_data; /* Platform specific data, device
417 core doesn't touch it */
418 struct dev_pm_info power;
420 #ifdef CONFIG_NUMA
421 int numa_node; /* NUMA node this device is close to */
422 #endif
423 u64 *dma_mask; /* dma mask (if dma'able device) */
424 u64 coherent_dma_mask;/* Like dma_mask, but for
425 alloc_coherent mappings as
426 not all hardware supports
427 64 bit addresses for consistent
428 allocations such descriptors. */
429
430 struct list_head dma_pools; /* dma pools (if dma'ble) */
431
432 struct dma_coherent_mem *dma_mem; /* internal for coherent mem
433 override */
434 /* arch specific additions */
435 struct dev_archdata archdata;
436
437 spinlock_t devres_lock;
438 struct list_head devres_head;
439
440 /* class_device migration path */
441 struct list_head node;
442 struct class *class;
443 dev_t devt; /* dev_t, creates the sysfs "dev" */
444 struct attribute_group **groups; /* optional groups */
445 int uevent_suppress;
446
447 void (*release)(struct device * dev);
448 };
120 struct device_driver {
121 const char * name;
122 struct bus_type * bus;
123
124 struct completion unloaded;
125 struct kobject kobj;
126 struct klist klist_devices;
127 struct klist_node knode_bus;
128
129 struct module * owner;
130 const char * mod_name; /* used for built-in modules */
131 struct module_kobject * mkobj;
132
133 int (*probe) (struct device * dev);
134 int (*remove) (struct device * dev);
135 void (*shutdown) (struct device * dev);
136 int (*suspend) (struct device * dev, pm_message_t state);
137 int (*resume) (struct device * dev);
138
139 unsigned int multithread_probe:1;
140 };
注册驱动程序:
driver_register(&i2c_adapter_driver);
i2c_adapter_driver内嵌了一个kobject,也就是说它将以一个kobject的模型挂接在系统的模型树里,在sysfs中,作为一个目录节点。
kobject_set_name(i2c_adapter_driver.kobject, i2c_adatpter_driver.name)
i2c_adapter_driver.kobject.kset = i2c_adapter_driver.bus->sub_sys.kset
add_list_tail(i2c_adapter_driver.kobject, i2c_adapter_driver.kobject.kset.klist)