分类: LINUX
2013-03-14 10:30:57
platform_driver_register(struct platform_driver *drv)注册后如何找到驱动匹配的设备 struct platform_driver { int (*probe)(struct platform_device *); int (*remove)(struct platform_device *); void (*shutdown)(struct platform_device *); int (*suspend)(struct platform_device *, pm_message_t state); int (*suspend_late)(struct platform_device *, pm_message_t state); int (*resume_early)(struct platform_device *); int (*resume)(struct platform_device *); struct device_driver driver; }; struct platform_driver 的结构成员如上,那么注册了一个struct platform_driver *drv,内核怎么知道那个设备是该驱动想驱动的呢,在什么条件下才会调用该platform_driver *drv的PROBE函数呢?struct device_driver { const char * name; struct bus_type * bus; struct kobject kobj; struct klist klist_devices; struct klist_node knode_bus; struct module * owner; const char * mod_name; /* used for built-in modules */ struct module_kobject * mkobj; int (*probe) (struct device * dev); int (*remove) (struct device * dev); void (*shutdown) (struct device * dev); int (*suspend) (struct device * dev, pm_message_t state); int (*resume) (struct device * dev); }; struct device_driver 里的name成员是设备的名字还是改设备DRIVER的名字?这里有两个PROBE函数,是不是先调用struct device_driver 里的PROBE,然后在调用struct platform_driver里的PROBE函数 |