Page MenuHomeFreeBSD

pci: Add pci_find_class_from
ClosedPublic

Authored by manu on Dec 10 2020, 6:19 PM.
Tags
None
Referenced Files
F149926939: D27549.id.diff
Sat, Mar 28, 4:14 AM
F149860455: D27549.id.diff
Fri, Mar 27, 4:08 PM
F149847175: D27549.diff
Fri, Mar 27, 1:44 PM
Unknown Object (File)
Fri, Mar 27, 2:10 AM
Unknown Object (File)
Sun, Mar 22, 4:34 AM
Unknown Object (File)
Fri, Mar 20, 2:04 AM
Unknown Object (File)
Tue, Mar 17, 5:15 AM
Unknown Object (File)
Thu, Mar 5, 10:31 AM
Subscribers

Details

Summary

pci_find_class_from help finding one or multiple device matching
a class and subclass.
If the from argument is not null we will first loop in the device list
until we find the matching device and only then start to check if the
class/subclass matches.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb added inline comments.
sys/dev/pci/pci.c
497

I assume this isn't a hot path, so this approach is fine vs trying to restart the iteration from the existing device. That is, you could perhaps write this as:

if (from == NULL)
    return (pci_find_class(class, subclass);

dinfo = device_get_ivars(from);
for (; dinfo != NULL; info = STAILQ_NEXT(dinfo, pci_links) {
    if (dinfo->cfg.baseclass == class &&
...

But I think your current approach is fine assuming it's only used in things like attach, and it's a bit more robust against bogus input arguments.

This revision is now accepted and ready to land.Dec 17 2020, 7:13 PM
This revision was automatically updated to reflect the committed changes.