Skip to content

Commit 7e845ec

Browse files
Sui Jingfengbjorn-helgaas
authored andcommitted
PCI: Add pci_is_vga() helper
The PCI Code and ID Assignment spec, r1.15, secs 1.4 and 1.1, define VGA Base Class and Sub-Classes: 03 00 PCI_CLASS_DISPLAY_VGA VGA-compatible or 8514-compatible 00 01 PCI_CLASS_NOT_DEFINED_VGA VGA-compatible (before Class Code) Add a pci_is_vga() helper to return true if a device is in either category. These VGA devices use the hardwired legacy VGA resources ([mem 0xa0000-0xbffff], [io 0x3b0-0x3bb], [io 0x3c0-0x3df] and aliases), so they require special handling if more than one is present in the system. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sui Jingfeng <[email protected]> [bhelgaas: commit log, drop !pdev test] Signed-off-by: Bjorn Helgaas <[email protected]> Cc: "Maciej W. Rozycki" <[email protected]>
1 parent 0bb80ec commit 7e845ec

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

include/linux/pci.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,30 @@ static inline bool pci_is_bridge(struct pci_dev *dev)
713713
dev->hdr_type == PCI_HEADER_TYPE_CARDBUS;
714714
}
715715

716+
/**
717+
* pci_is_vga - check if the PCI device is a VGA device
718+
*
719+
* The PCI Code and ID Assignment spec, r1.15, secs 1.4 and 1.1, define
720+
* VGA Base Class and Sub-Classes:
721+
*
722+
* 03 00 PCI_CLASS_DISPLAY_VGA VGA-compatible or 8514-compatible
723+
* 00 01 PCI_CLASS_NOT_DEFINED_VGA VGA-compatible (before Class Code)
724+
*
725+
* Return true if the PCI device is a VGA device and uses the legacy VGA
726+
* resources ([mem 0xa0000-0xbffff], [io 0x3b0-0x3bb], [io 0x3c0-0x3df] and
727+
* aliases).
728+
*/
729+
static inline bool pci_is_vga(struct pci_dev *pdev)
730+
{
731+
if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
732+
return true;
733+
734+
if ((pdev->class >> 8) == PCI_CLASS_NOT_DEFINED_VGA)
735+
return true;
736+
737+
return false;
738+
}
739+
716740
#define for_each_pci_bridge(dev, bus) \
717741
list_for_each_entry(dev, &bus->devices, bus_list) \
718742
if (!pci_is_bridge(dev)) {} else

0 commit comments

Comments
 (0)