Messages in this thread | | | Date | Wed, 10 Oct 2007 09:39:44 +0800 | From | wit <> | Subject | about probing a device |
| |
Hi, I found these routines in the kernel, does this means only one driver can be matched to a device? What if two drivers both can drive the device, like sd & sg in scsi subsystem?
static int device_attach(struct device * dev) { struct bus_type * bus = dev->bus; struct list_head * entry; int error;
if (dev->driver) { device_bind_driver(dev); return 1; }
if (bus->match) { list_for_each(entry, &bus->drivers.list) { struct device_driver * drv = to_drv(entry); error = bus_match(dev, drv); if (!error) /* success, driver matched */ return 1; if (error != -ENODEV && error != -ENXIO) /* driver matched but the probe failed */ printk(KERN_WARNING "%s: probe of %s failed with error %d\n", drv->name, dev->bus_id, error); } }
return 0; }
void driver_attach(struct device_driver * drv) { struct bus_type * bus = drv->bus; struct list_head * entry; int error;
if (!bus->match) return;
list_for_each(entry, &bus->devices.list) { struct device * dev = container_of(entry, struct device, bus_list); if (!dev->driver) { error = bus_match(dev, drv); if (error && (error != -ENODEV)) /* driver matched but the probe failed */ printk(KERN_WARNING "%s: probe of %s failed with error %d\n", drv->name, dev->bus_id, error); } } }
Thanks - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |