aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/subr_bus.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/subr_bus.c')
-rw-r--r--sys/kern/subr_bus.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index d9c2ac1b6e24..968cb99f8e50 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -5204,6 +5204,7 @@ devctl2_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag,
case DEV_RESUME:
case DEV_SET_DRIVER:
case DEV_RESCAN:
+ case DEV_DELETE:
error = priv_check(td, PRIV_DRIVER);
if (error == 0)
error = find_device(req, &dev);
@@ -5374,6 +5375,24 @@ devctl2_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag,
}
error = BUS_RESCAN(dev);
break;
+ case DEV_DELETE: {
+ device_t parent;
+
+ parent = device_get_parent(dev);
+ if (parent == NULL) {
+ error = EINVAL;
+ break;
+ }
+ if (!(req->dr_flags & DEVF_FORCE_DELETE)) {
+ if (bus_child_present(dev) != 0) {
+ error = EBUSY;
+ break;
+ }
+ }
+
+ error = device_delete_child(parent, dev);
+ break;
+ }
}
mtx_unlock(&Giant);
return (error);