aboutsummaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ata/ata-all.c3
-rw-r--r--sys/dev/bge/if_bge.c13
-rw-r--r--sys/dev/ichwd/ichwd.c5
-rw-r--r--sys/dev/iommu/busdma_iommu.c32
-rw-r--r--sys/dev/pci/pci.c10
-rw-r--r--sys/dev/pci/vga_pci.c6
-rw-r--r--sys/dev/vnic/thunder_bgx_fdt.c9
7 files changed, 20 insertions, 58 deletions
diff --git a/sys/dev/ata/ata-all.c b/sys/dev/ata/ata-all.c
index 2e77c0f6478e..85fe40aa4584 100644
--- a/sys/dev/ata/ata-all.c
+++ b/sys/dev/ata/ata-all.c
@@ -1176,8 +1176,7 @@ ataaction(struct cam_sim *sim, union ccb *ccb)
cpi->protocol = PROTO_ATA;
cpi->protocol_version = PROTO_VERSION_UNSPECIFIED;
cpi->maxio = ch->dma.max_iosize ? ch->dma.max_iosize : DFLTPHYS;
- if (device_get_devclass(device_get_parent(parent)) ==
- devclass_find("pci")) {
+ if (is_pci_device(parent)) {
cpi->hba_vendor = pci_get_vendor(parent);
cpi->hba_device = pci_get_device(parent);
cpi->hba_subvendor = pci_get_subvendor(parent);
diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c
index 2feb19bff677..3551f10b2ae3 100644
--- a/sys/dev/bge/if_bge.c
+++ b/sys/dev/bge/if_bge.c
@@ -3202,20 +3202,13 @@ bge_mbox_reorder(struct bge_softc *sc)
} mbox_reorder_lists[] = {
{ 0x1022, 0x7450, "AMD-8131 PCI-X Bridge" },
};
- devclass_t pci, pcib;
- device_t bus, dev;
+ device_t dev;
int i;
- pci = devclass_find("pci");
- pcib = devclass_find("pcib");
dev = sc->bge_dev;
- bus = device_get_parent(dev);
for (;;) {
- dev = device_get_parent(bus);
- bus = device_get_parent(dev);
- if (device_get_devclass(dev) != pcib)
- break;
- if (device_get_devclass(bus) != pci)
+ dev = device_get_parent(device_get_parent(dev));
+ if (!is_pci_device(dev))
break;
for (i = 0; i < nitems(mbox_reorder_lists); i++) {
if (pci_get_vendor(dev) ==
diff --git a/sys/dev/ichwd/ichwd.c b/sys/dev/ichwd/ichwd.c
index 5481553cc175..b0c953e58956 100644
--- a/sys/dev/ichwd/ichwd.c
+++ b/sys/dev/ichwd/ichwd.c
@@ -561,13 +561,12 @@ static device_t
ichwd_find_ich_lpc_bridge(device_t isa, struct ichwd_device **id_p)
{
struct ichwd_device *id;
- device_t isab, pci;
+ device_t isab;
uint16_t devid;
/* Check whether parent ISA bridge looks familiar. */
isab = device_get_parent(isa);
- pci = device_get_parent(isab);
- if (pci == NULL || device_get_devclass(pci) != devclass_find("pci"))
+ if (!is_pci_device(isab))
return (NULL);
if (pci_get_vendor(isab) != VENDORID_INTEL)
return (NULL);
diff --git a/sys/dev/iommu/busdma_iommu.c b/sys/dev/iommu/busdma_iommu.c
index 82f73d469585..3852429c4a8a 100644
--- a/sys/dev/iommu/busdma_iommu.c
+++ b/sys/dev/iommu/busdma_iommu.c
@@ -117,17 +117,14 @@ iommu_bus_dma_is_dev_disabled(int domain, int bus, int slot, int func)
int
iommu_get_requester(device_t dev, device_t *requesterp, uint16_t *rid)
{
- devclass_t pci_class;
device_t l, pci, pcib, pcip, pcibp, requester;
int cap_offset;
uint16_t pcie_flags;
bool bridge_is_pcie;
- pci_class = devclass_find("pci");
l = requester = dev;
- pci = device_get_parent(dev);
- if (pci == NULL || device_get_devclass(pci) != pci_class) {
+ if (!is_pci_device(dev)) {
*rid = 0; /* XXXKIB: Could be ACPI HID */
*requesterp = NULL;
return (ENOTTY);
@@ -141,29 +138,18 @@ iommu_get_requester(device_t dev, device_t *requesterp, uint16_t *rid)
* unit.
*/
for (;;) {
- pci = device_get_parent(l);
- if (pci == NULL) {
+ if (!is_pci_device(l)) {
if (bootverbose) {
printf(
- "iommu_get_requester(%s): NULL parent for %s\n",
+ "iommu_get_requester(%s): non-pci ancestor %s\n",
device_get_name(dev), device_get_name(l));
}
*rid = 0;
*requesterp = NULL;
return (ENXIO);
}
- if (device_get_devclass(pci) != pci_class) {
- if (bootverbose) {
- printf(
- "iommu_get_requester(%s): non-pci parent %s for %s\n",
- device_get_name(dev), device_get_name(pci),
- device_get_name(l));
- }
- *rid = 0;
- *requesterp = NULL;
- return (ENXIO);
- }
+ pci = device_get_parent(l);
pcib = device_get_parent(pci);
if (pcib == NULL) {
if (bootverbose) {
@@ -182,10 +168,8 @@ iommu_get_requester(device_t dev, device_t *requesterp, uint16_t *rid)
* port, and the requester ID won't be translated
* further.
*/
- pcip = device_get_parent(pcib);
- if (device_get_devclass(pcip) != pci_class)
+ if (!is_pci_device(pcib))
break;
- pcibp = device_get_parent(pcip);
if (pci_find_cap(l, PCIY_EXPRESS, &cap_offset) == 0) {
/*
@@ -212,6 +196,8 @@ iommu_get_requester(device_t dev, device_t *requesterp, uint16_t *rid)
* PCI bridge, then we know pcib is actually a
* PCIe/PCI bridge.
*/
+ pcip = device_get_parent(pcib);
+ pcibp = device_get_parent(pcip);
if (!bridge_is_pcie && pci_find_cap(pcibp,
PCIY_EXPRESS, &cap_offset) == 0) {
pcie_flags = pci_read_config(pcibp,
@@ -337,11 +323,9 @@ bool
bus_dma_iommu_set_buswide(device_t dev)
{
struct iommu_unit *unit;
- device_t parent;
u_int busno, slot, func;
- parent = device_get_parent(dev);
- if (device_get_devclass(parent) != devclass_find("pci"))
+ if (!is_pci_device(dev))
return (false);
unit = iommu_find(dev, bootverbose);
if (unit == NULL)
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c
index adf3daea66fd..034f34e2dde2 100644
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -6535,11 +6535,9 @@ device_t
pci_find_pcie_root_port(device_t dev)
{
struct pci_devinfo *dinfo;
- devclass_t pci_class;
device_t pcib, bus;
- pci_class = devclass_find("pci");
- KASSERT(device_get_devclass(device_get_parent(dev)) == pci_class,
+ KASSERT(is_pci_device(dev),
("%s: non-pci device %s", __func__, device_get_nameunit(dev)));
/*
@@ -6555,11 +6553,7 @@ pci_find_pcie_root_port(device_t dev)
KASSERT(pcib != NULL, ("%s: null bridge of %s", __func__,
device_get_nameunit(bus)));
- /*
- * pcib's parent must be a PCI bus for this to be a
- * PCI-PCI bridge.
- */
- if (device_get_devclass(device_get_parent(pcib)) != pci_class)
+ if (!is_pci_device(pcib))
return (NULL);
dinfo = device_get_ivars(pcib);
diff --git a/sys/dev/pci/vga_pci.c b/sys/dev/pci/vga_pci.c
index 39b2fcab67b4..72c93e201d96 100644
--- a/sys/dev/pci/vga_pci.c
+++ b/sys/dev/pci/vga_pci.c
@@ -111,8 +111,7 @@ vga_pci_is_boot_display(device_t dev)
*/
pcib = device_get_parent(device_get_parent(dev));
- if (device_get_devclass(device_get_parent(pcib)) ==
- devclass_find("pci")) {
+ if (is_pci_device(pcib)) {
/*
* The parent bridge is a PCI-to-PCI bridge: check the
* value of the "VGA Enable" bit.
@@ -186,8 +185,7 @@ vga_pci_map_bios(device_t dev, size_t *size)
#endif
pcib = device_get_parent(device_get_parent(dev));
- if (device_get_devclass(device_get_parent(pcib)) ==
- devclass_find("pci")) {
+ if (is_pci_device(pcib)) {
/*
* The parent bridge is a PCI-to-PCI bridge: check the
* value of the "VGA Enable" bit.
diff --git a/sys/dev/vnic/thunder_bgx_fdt.c b/sys/dev/vnic/thunder_bgx_fdt.c
index 20a5b54f7448..d8c5459f2914 100644
--- a/sys/dev/vnic/thunder_bgx_fdt.c
+++ b/sys/dev/vnic/thunder_bgx_fdt.c
@@ -285,11 +285,9 @@ bgx_fdt_traverse_nodes(uint8_t unit, phandle_t start, char *name,
static device_t
bgx_find_root_pcib(device_t dev)
{
- devclass_t pci_class;
device_t pcib, bus;
- pci_class = devclass_find("pci");
- KASSERT(device_get_devclass(device_get_parent(dev)) == pci_class,
+ KASSERT(is_pci_device(dev),
("%s: non-pci device %s", __func__, device_get_nameunit(dev)));
/* Walk the bridge hierarchy until we find a non-PCI device */
@@ -298,9 +296,6 @@ bgx_find_root_pcib(device_t dev)
KASSERT(bus != NULL, ("%s: null parent of %s", __func__,
device_get_nameunit(dev)));
- if (device_get_devclass(bus) != pci_class)
- return (NULL);
-
pcib = device_get_parent(bus);
KASSERT(pcib != NULL, ("%s: null bridge of %s", __func__,
device_get_nameunit(bus)));
@@ -309,7 +304,7 @@ bgx_find_root_pcib(device_t dev)
* If the parent of this PCIB is not PCI
* then we found our root PCIB.
*/
- if (device_get_devclass(device_get_parent(pcib)) != pci_class)
+ if (!is_pci_device(pcib))
return (pcib);
dev = pcib;