Before registering a PCI driver, we have to initialize struct pci_driver
and pass it to pci_register_driver
. One of fields of the structure is a pointer to driver's probe
function.
My question is - when the kernel calls driver's probe routine. Is it guaranteed to be right after the call to pci_register_driver
or may happen any other time? What is determining this behaviour?
UPDATE
pci_register_driver
is a macro expanded into __pci_register_driver
, which in turn calls driver_register
, and driver_register
calls bus_add_driver
.
There's a following code in bus_add_driver
:
if (drv->bus->p->drivers_autoprobe) {
error = driver_attach(drv);
if (error)
goto out_unregister;
}
driver_attach
will call bus_for_each_dev
with argument __driver_attach
, which will invoke driver_probe_device
And driver_probe_device
ultimately calls really_probe
:
if (dev->bus->probe) {
ret = dev->bus->probe(dev);
The one thing I'm not sure about, is if the flag drivers_autoprobe
gets set for pci_bus.