Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: Add pci_is_display() to check if device is a display controller

Several places in the kernel do class shifting to match whether a PCI
device is display class. Add pci_is_display() for those places to use.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Daniel Dadap <ddadap@nvidia.com>
Reviewed-by: Simona Vetter <simona.vetter@ffwll.ch>
Link: https://patch.msgid.link/20250717173812.3633478-2-superm1@kernel.org

authored by

Mario Limonciello and committed by
Bjorn Helgaas
76720eed 19272b37

+15
+15
include/linux/pci.h
··· 744 744 return false; 745 745 } 746 746 747 + /** 748 + * pci_is_display - check if the PCI device is a display controller 749 + * @pdev: PCI device 750 + * 751 + * Determine whether the given PCI device corresponds to a display 752 + * controller. Display controllers are typically used for graphical output 753 + * and are identified based on their class code. 754 + * 755 + * Return: true if the PCI device is a display controller, false otherwise. 756 + */ 757 + static inline bool pci_is_display(struct pci_dev *pdev) 758 + { 759 + return (pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY; 760 + } 761 + 747 762 #define for_each_pci_bridge(dev, bus) \ 748 763 list_for_each_entry(dev, &bus->devices, bus_list) \ 749 764 if (!pci_is_bridge(dev)) {} else