Page MenuHomeFreeBSD

pci: Add pci_find_class_from
ClosedPublic

Authored by manu on Dec 10 2020, 6:19 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 24 2024, 11:01 AM
Unknown Object (File)
Feb 24 2024, 11:00 AM
Unknown Object (File)
Feb 24 2024, 11:00 AM
Unknown Object (File)
Feb 24 2024, 10:42 AM
Unknown Object (File)
Dec 23 2023, 12:11 AM
Unknown Object (File)
Dec 14 2023, 10:07 PM
Unknown Object (File)
Jul 1 2023, 2:31 PM
Unknown Object (File)
Jul 1 2023, 2:30 PM
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.