]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
PCI: Add pci_is_display() to check if device is a display controller
authorMario Limonciello <mario.limonciello@amd.com>
Thu, 17 Jul 2025 17:38:04 +0000 (12:38 -0500)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 17 Jul 2025 20:30:05 +0000 (15:30 -0500)
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
include/linux/pci.h

index 05e68f35f39238f8b9ce08df97b384d1c1e89bbe..4fff6405a8304c008c4707ba8d2af53ee1740b04 100644 (file)
@@ -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