aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/pci/pci_iov.c2
-rw-r--r--sys/kern/subr_bus.c19
-rw-r--r--sys/sys/bus.h1
3 files changed, 21 insertions, 1 deletions
diff --git a/sys/dev/pci/pci_iov.c b/sys/dev/pci/pci_iov.c
index ff5a833c3702..e256a5d126f1 100644
--- a/sys/dev/pci/pci_iov.c
+++ b/sys/dev/pci/pci_iov.c
@@ -586,7 +586,7 @@ pci_iov_enumerate_vfs(struct pci_devinfo *dinfo, const nvlist_t *config,
* VFs.
*/
if (nvlist_get_bool(iov_config, "passthrough"))
- device_set_devclass(vf, "ppt");
+ device_set_devclass_fixed(vf, "ppt");
vfinfo = device_get_ivars(vf);
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index 1c7b21ca7d9e..20a14abef428 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -2683,6 +2683,25 @@ device_set_devclass(device_t dev, const char *classname)
}
/**
+ * @brief Set the devclass of a device and mark the devclass fixed.
+ * @see device_set_devclass()
+ */
+int
+device_set_devclass_fixed(device_t dev, const char *classname)
+{
+ int error;
+
+ if (classname == NULL)
+ return (EINVAL);
+
+ error = device_set_devclass(dev, classname);
+ if (error)
+ return (error);
+ dev->flags |= DF_FIXEDCLASS;
+ return (0);
+}
+
+/**
* @brief Set the driver of a device
*
* @retval 0 success
diff --git a/sys/sys/bus.h b/sys/sys/bus.h
index d6dc53585eba..8b1f1736a17f 100644
--- a/sys/sys/bus.h
+++ b/sys/sys/bus.h
@@ -522,6 +522,7 @@ void device_quiet(device_t dev);
void device_set_desc(device_t dev, const char* desc);
void device_set_desc_copy(device_t dev, const char* desc);
int device_set_devclass(device_t dev, const char *classname);
+int device_set_devclass_fixed(device_t dev, const char *classname);
int device_set_driver(device_t dev, driver_t *driver);
void device_set_flags(device_t dev, u_int32_t flags);
void device_set_softc(device_t dev, void *softc);