Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F157798394
D56997.id178028.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
10 KB
Referenced Files
None
Subscribers
None
D56997.id178028.diff
View Options
diff --git a/sys/arm64/cavium/thunder_pcie_pem.c b/sys/arm64/cavium/thunder_pcie_pem.c
--- a/sys/arm64/cavium/thunder_pcie_pem.c
+++ b/sys/arm64/cavium/thunder_pcie_pem.c
@@ -760,8 +760,6 @@
{
struct resource_map_request req;
struct resource_map map;
- devclass_t pci_class;
- device_t parent;
struct thunder_pem_softc *sc;
int error;
int rid;
@@ -773,9 +771,7 @@
sc->dev = dev;
/* Allocate memory for resource */
- pci_class = devclass_find("pci");
- parent = device_get_parent(dev);
- if (device_get_devclass(parent) == pci_class)
+ if (is_pci_device(dev))
rid = PCIR_BAR(0);
else
rid = RID_PEM_SPACE;
diff --git a/sys/arm64/iommu/smmu.c b/sys/arm64/iommu/smmu.c
--- a/sys/arm64/iommu/smmu.c
+++ b/sys/arm64/iommu/smmu.c
@@ -1825,7 +1825,6 @@
struct iommu_domain *iodom;
struct smmu_softc *sc;
struct smmu_ctx *ctx;
- devclass_t pci_class;
u_int sid;
int err;
@@ -1836,8 +1835,7 @@
domain = ctx->domain;
iodom = (struct iommu_domain *)domain;
- pci_class = devclass_find("pci");
- if (device_get_devclass(device_get_parent(ctx->dev)) == pci_class) {
+ if (is_pci_device(ctx->dev)) {
err = smmu_pci_get_sid(ctx->dev, NULL, &sid);
if (err)
return (err);
@@ -1863,7 +1861,7 @@
smmu_init_ste(sc, domain->cd, ctx->sid, ctx->bypass);
- if (device_get_devclass(device_get_parent(ctx->dev)) == pci_class)
+ if (is_pci_device((ctx->dev))
if (iommu_is_buswide_ctx(iodom->iommu, pci_get_bus(ctx->dev)))
smmu_set_buswide(dev, domain, ctx);
diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h
--- a/sys/compat/linuxkpi/common/include/linux/pci.h
+++ b/sys/compat/linuxkpi/common/include/linux/pci.h
@@ -399,8 +399,7 @@
static inline bool
dev_is_pci(struct device *dev)
{
- return (device_get_devclass(device_get_parent(dev->bsddev)) ==
- devclass_find("pci"));
+ return (is_pci_device(dev->bsddev));
}
static inline uint16_t
@@ -556,8 +555,7 @@
bridge = device_get_parent(bridge);
if (bridge == NULL)
goto done;
- if (device_get_devclass(device_get_parent(bridge)) !=
- devclass_find("pci"))
+ if (!is_pci_device(bridge))
goto done;
/*
diff --git a/sys/dev/ata/ata-all.c b/sys/dev/ata/ata-all.c
--- a/sys/dev/ata/ata-all.c
+++ b/sys/dev/ata/ata-all.c
@@ -1176,8 +1176,7 @@
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
--- a/sys/dev/bge/if_bge.c
+++ b/sys/dev/bge/if_bge.c
@@ -3202,20 +3202,13 @@
} 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
--- a/sys/dev/ichwd/ichwd.c
+++ b/sys/dev/ichwd/ichwd.c
@@ -561,13 +561,12 @@
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
--- a/sys/dev/iommu/busdma_iommu.c
+++ b/sys/dev/iommu/busdma_iommu.c
@@ -117,17 +117,14 @@
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 @@
* 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 @@
* 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 @@
* 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 @@
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
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -6535,11 +6535,9 @@
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 @@
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
--- a/sys/dev/pci/vga_pci.c
+++ b/sys/dev/pci/vga_pci.c
@@ -111,8 +111,7 @@
*/
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 @@
#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
--- a/sys/dev/vnic/thunder_bgx_fdt.c
+++ b/sys/dev/vnic/thunder_bgx_fdt.c
@@ -285,11 +285,9 @@
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 @@
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 @@
* 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;
diff --git a/sys/x86/iommu/amd_drv.c b/sys/x86/iommu/amd_drv.c
--- a/sys/x86/iommu/amd_drv.c
+++ b/sys/x86/iommu/amd_drv.c
@@ -894,8 +894,7 @@
if (!amdiommu_enable)
return (ENXIO);
- if (device_get_devclass(device_get_parent(dev)) !=
- devclass_find("pci"))
+ if (!is_pci_device(dev))
return (ENXIO);
bzero(&ifu, sizeof(ifu));
diff --git a/sys/x86/iommu/intel_drv.c b/sys/x86/iommu/intel_drv.c
--- a/sys/x86/iommu/intel_drv.c
+++ b/sys/x86/iommu/intel_drv.c
@@ -605,16 +605,13 @@
int
dmar_dev_depth(device_t child)
{
- devclass_t pci_class;
device_t bus, pcib;
int depth;
- pci_class = devclass_find("pci");
for (depth = 1; ; depth++) {
bus = device_get_parent(child);
pcib = device_get_parent(bus);
- if (device_get_devclass(device_get_parent(pcib)) !=
- pci_class)
+ if (!is_pci_device(pcib))
return (depth);
child = pcib;
}
@@ -623,19 +620,16 @@
void
dmar_dev_path(device_t child, int *busno, void *path1, int depth)
{
- devclass_t pci_class;
device_t bus, pcib;
ACPI_DMAR_PCI_PATH *path;
- pci_class = devclass_find("pci");
path = path1;
for (depth--; depth != -1; depth--) {
path[depth].Device = pci_get_slot(child);
path[depth].Function = pci_get_function(child);
bus = device_get_parent(child);
pcib = device_get_parent(bus);
- if (device_get_devclass(device_get_parent(pcib)) !=
- pci_class) {
+ if (!is_pci_device(pcib)) {
/* reached a host bridge */
*busno = pcib_get_bus(bus);
return;
@@ -765,8 +759,7 @@
/*
* This function can only handle PCI(e) devices.
*/
- if (device_get_devclass(device_get_parent(dev)) !=
- devclass_find("pci"))
+ if (!is_pci_device(dev))
return (NULL);
dev_domain = pci_get_domain(dev);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, May 26, 7:46 AM (1 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33505144
Default Alt Text
D56997.id178028.diff (10 KB)
Attached To
Mode
D56997: sys: Use is_pci_device instead of direct comparisons to devclasses
Attached
Detach File
Event Timeline
Log In to Comment