How does the probe function gets called on a PCI device driver?
Henrique Montenegro
typoon at gmail.com
Sat Jan 30 11:27:49 EST 2016
Hello list,
I am reading through the e1000 driver and trying to figure out how the
probe function on it gets called.
The driver initialization function calls pci_register_driver:
----------------------------------------------------------------------------->8
static struct pci_driver e1000_driver = {
.name = e1000_driver_name,
.id_table = e1000_pci_tbl,
.probe = e1000_probe,
.remove = e1000_remove,
// ...
};
static int __init e1000_init_module(void)
{
// ...
ret = pci_register_driver(&e1000_driver);
// ...
}
----------------------------------------------------------------------------->8
And pci_register_driver is defined as (on linux/pci.h):
----------------------------------------------------------------------------->8
#define pci_register_driver(driver) \
__pci_register_driver(driver, THIS_MODULE, KBUILD_MODNAME)
----------------------------------------------------------------------------->8
Function __pci_register_driver is defined as (drivers/pci/pci-driver.c):
----------------------------------------------------------------------------->8
int __pci_register_driver(struct pci_driver *drv, struct module *owner,
const char *mod_name)
{
/* initialize common driver fields */
drv->driver.name = drv->name;
drv->driver.bus = &pci_bus_type;
drv->driver.owner = owner;
drv->driver.mod_name = mod_name;
spin_lock_init(&drv->dynids.lock);
INIT_LIST_HEAD(&drv->dynids.list);
/* register with core */
return driver_register(&drv->driver);
}
EXPORT_SYMBOL(__pci_register_driver);
----------------------------------------------------------------------------->8
This is the point where I am getting lost. I can't figure out how the Kernel
will know about the functions defined in the e1000_driver struct mentioned
before, since it does not seem to pass a reference to it anywhere.
How does the kernel know where the probe function for this module is in this
case? To be honest, for any driver that calls pci_register_driver, how will
the
kernel know where the probe function is since it does not seem like it is
being passed to driver_register?
Thanks for the help!
Henrique
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160130/6474d7ac/attachment.html
More information about the Kernelnewbies
mailing list