summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorMario Limonciello <mario.limonciello@amd.com>2025-07-17 20:38:04 +0300
committerBjorn Helgaas <bhelgaas@google.com>2025-07-17 23:30:05 +0300
commit76720eed7d18baf51c0f31fe8a3784702f50e3fc (patch)
tree9c03aa6ae6656c1c0210f08208020a34ece4ec84 /include/linux
parent19272b37aa4f83ca52bdf9c16d5d81bdd1354494 (diff)
downloadlinux-76720eed7d18baf51c0f31fe8a3784702f50e3fc.tar.xz
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
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/pci.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 05e68f35f392..4fff6405a830 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -744,6 +744,21 @@ static inline bool pci_is_vga(struct pci_dev *pdev)
return false;
}
+/**
+ * pci_is_display - check if the PCI device is a display controller
+ * @pdev: PCI device
+ *
+ * Determine whether the given PCI device corresponds to a display
+ * controller. Display controllers are typically used for graphical output
+ * and are identified based on their class code.
+ *
+ * Return: true if the PCI device is a display controller, false otherwise.
+ */
+static inline bool pci_is_display(struct pci_dev *pdev)
+{
+ return (pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY;
+}
+
#define for_each_pci_bridge(dev, bus) \
list_for_each_entry(dev, &bus->devices, bus_list) \
if (!pci_is_bridge(dev)) {} else