Skip to content

Commit 76720ee

Browse files
superm1bjorn-helgaas
authored andcommitted
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
1 parent 19272b3 commit 76720ee

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

include/linux/pci.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,21 @@ static inline bool pci_is_vga(struct pci_dev *pdev)
744744
return false;
745745
}
746746

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+
747762
#define for_each_pci_bridge(dev, bus) \
748763
list_for_each_entry(dev, &bus->devices, bus_list) \
749764
if (!pci_is_bridge(dev)) {} else

0 commit comments

Comments
 (0)