PCI: Add pci_get_base_class() helper
authorSui Jingfeng <suijingfeng@loongson.cn>
Fri, 25 Aug 2023 06:27:10 +0000 (14:27 +0800)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 28 Sep 2023 21:49:44 +0000 (16:49 -0500)
commitd427da2323b093a65d8317783e76ab8fad2e2ef0
tree9a4e09282f1b8585a212fa58e3013b26de7ca452
parent0bb80ecc33a8fb5a682236443c1e740d5c917d1d
PCI: Add pci_get_base_class() helper

There is no function to get all PCI devices in a system by matching
against the base class code only, ignoring the sub-class code and
the programming interface.  Add pci_get_base_class() to suit the
need.

For example, if a driver wants to process all PCI display devices in
a system, it can do so like this:

  pdev = NULL;
  while ((pdev = pci_get_base_class(PCI_BASE_CLASS_DISPLAY, pdev))) {
    do_something_for_pci_display_device(pdev);
  }

Link: https://lore.kernel.org/r/20230825062714.6325-2-sui.jingfeng@linux.dev
Signed-off-by: Sui Jingfeng <suijingfeng@loongson.cn>
[bhelgaas: reword commit log]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
drivers/pci/search.c
include/linux/pci.h