2、的联系,并添加bus为device定义的属性,然后会调用bus_probe_device()。bus_probe_device()会试图为已挂在总线上的该设备寻找对应的驱动。我们的故事就从这里开始。[cpp] viewplaincopyprint?1./** 2. * bus_probe_device - probe drivers for a new device 3. * @dev: device to probe 4. * 5. * - Automatically probe for a d
3、river if the bus allows it. 6. */ 7.void bus_probe_device(struct device *dev) 8.{ 9. struct bus_type *bus = dev->bus; 10. int ret; 11. 12. if (bus && bus->p->drivers_autoprobe) { 13. ret = device_attach(dev); 14. WARN_ON
5、_autoprobe属性文件主动禁止,bus总是允许自动探测的,所有的bus都是如此。[cpp] viewplaincopyprint?1./** 2. * device_attach - try to attach device to a driver. 3. * @dev: device. 1. * 2. * Walk the list of drivers that the bus has and call 3. * driver_probe_device() for each pair.
6、If a compatible 4. * pair is found, break out and return. 5. * 6. * Returns 1 if the device was bound to a driver; 7. * 0 if no matching driver was found; 8. * -ENODEV if the device is not registered. 9. * 10. * When called for a USB interface, @dev->
7、parent->sem must be held. 11. */ 12.int device_attach(struct device *dev) 13.{ 14. int ret = 0; 15. 16. down(&dev->sem); 17. if (dev->driver) { 18. ret = device_bind_driver(dev); 19. if (ret == 0) 20. ret = 1