Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F145596449
D31073.1778267008.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D31073.1778267008.diff
View Options
Index: sys/dev/pci/pci.c
===================================================================
--- sys/dev/pci/pci.c
+++ sys/dev/pci/pci.c
@@ -6261,11 +6261,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(devclass_is_derived_from("pci", dev),
("%s: non-pci device %s", __func__, device_get_nameunit(dev)));
/*
@@ -6285,7 +6283,7 @@
* 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 (!devclass_is_derived_from("pci", device_get_parent(pcib)))
return (NULL);
dinfo = device_get_ivars(pcib);
Index: sys/kern/subr_bus.c
===================================================================
--- sys/kern/subr_bus.c
+++ sys/kern/subr_bus.c
@@ -1755,6 +1755,23 @@
return (0);
}
+bool
+devclass_is_derived_from(const char *name, device_t dev)
+{
+ devclass_t dc, ddc;
+
+ dc = devclass_find(name);
+ if (dc == NULL)
+ return (false);
+ ddc = device_get_devclass(dev);
+ while (dc != NULL) {
+ if (dc == ddc)
+ return (true);
+ dc = dc->parent;
+ }
+ return (false);
+}
+
/**
* @internal
* @brief Make a new device and add it as a child of @p parent
Index: sys/sys/bus.h
===================================================================
--- sys/sys/bus.h
+++ sys/sys/bus.h
@@ -652,6 +652,7 @@
devclass_t devclass_get_parent(devclass_t dc);
struct sysctl_ctx_list *devclass_get_sysctl_ctx(devclass_t dc);
struct sysctl_oid *devclass_get_sysctl_tree(devclass_t dc);
+bool devclass_is_derived_from(const char *, device_t);
/*
* Access functions for device resources.
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, May 8, 7:03 PM (23 m, 22 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28612203
Default Alt Text
D31073.1778267008.diff (1 KB)
Attached To
Mode
D31073: Hack at the moment: see if devclass_is_derived_from helps...
Attached
Detach File
Event Timeline
Log In to Comment