tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Inconsistencies in usage of "locators" argument to config (*ca_rescan)() functions

There appears to be come inconsistency and/or confusion regarding the usage of the “locators” argument passed to the (*ca_rescan)() functions.

Background: drochner@ added this rescan mechanism back in 2004 to support driver modules providing cfdata, to facilitate correct device->driver matching when driver modules are loaded.

It appears as though sys/dev/pci/pci.c uses it as intended:

- pci_attach() creates “wildcard” locators and passes them to pcirescan().

- Takes passes these “wildcard” locators on to pci_enumerate_bus(), which uses them to filter which PCI device locations to enumerate.  Eventually, pci_probe_device() is called.  Note, the “locators” array is no longer passed through .. it was meant only to filter where on the bus to look.

- pci_probe_device() looks for a device at the requested location, and if it finds one, it constructs a *new* locators array that indicates the actual location, and passes *that* to config_found() (in mainline, config_found_sm_loc()).  The sub match routine pci uses is config_stdsubmatch().

- config_stdsubmatch() uses the locators in the cfdata it receives to check if that spec (i.e. the user-specified location) matches the data in the locators array passed by pci_probe_device().

This appears to be the original intended use.  However, a bunch of the (*ca_rescan)() routines do not use it properly.  “Since I’m here already (for other reasons), …” I’ll go ahead and audit these routines and fix them up.  But I wanted to confirm that my understanding of “how it’s supposed to work” is correct.

(It’s really amazing how fast copy-paste can propagate an anti-pattern…)


-- thorpej

Home | Main Index | Thread Index | Old Index