Commit 76720eed authored by Mario Limonciello's avatar Mario Limonciello Committed by Bjorn Helgaas
Browse files

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: default avatarMario Limonciello <mario.limonciello@amd.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Reviewed-by: default avatarDaniel Dadap <ddadap@nvidia.com>
Reviewed-by: default avatarSimona Vetter <simona.vetter@ffwll.ch>
Link: https://patch.msgid.link/20250717173812.3633478-2-superm1@kernel.org
parent 19272b37
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -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