Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/subr_bus.c
Show First 20 Lines • Show All 5,198 Lines • ▼ Show 20 Lines | devctl2_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag, | ||||
case DEV_ATTACH: | case DEV_ATTACH: | ||||
case DEV_DETACH: | case DEV_DETACH: | ||||
case DEV_ENABLE: | case DEV_ENABLE: | ||||
case DEV_DISABLE: | case DEV_DISABLE: | ||||
case DEV_SUSPEND: | case DEV_SUSPEND: | ||||
case DEV_RESUME: | case DEV_RESUME: | ||||
case DEV_SET_DRIVER: | case DEV_SET_DRIVER: | ||||
case DEV_RESCAN: | case DEV_RESCAN: | ||||
case DEV_DELETE: | |||||
error = priv_check(td, PRIV_DRIVER); | error = priv_check(td, PRIV_DRIVER); | ||||
if (error == 0) | if (error == 0) | ||||
error = find_device(req, &dev); | error = find_device(req, &dev); | ||||
break; | break; | ||||
default: | default: | ||||
error = ENOTTY; | error = ENOTTY; | ||||
break; | break; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 154 Lines • ▼ Show 20 Lines | devctl2_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag, | ||||
} | } | ||||
case DEV_RESCAN: | case DEV_RESCAN: | ||||
if (!device_is_attached(dev)) { | if (!device_is_attached(dev)) { | ||||
error = ENXIO; | error = ENXIO; | ||||
break; | break; | ||||
} | } | ||||
error = BUS_RESCAN(dev); | error = BUS_RESCAN(dev); | ||||
break; | 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); | mtx_unlock(&Giant); | ||||
return (error); | return (error); | ||||
} | } | ||||
static struct cdevsw devctl2_cdevsw = { | static struct cdevsw devctl2_cdevsw = { | ||||
.d_version = D_VERSION, | .d_version = D_VERSION, | ||||
.d_ioctl = devctl2_ioctl, | .d_ioctl = devctl2_ioctl, | ||||
Show All 10 Lines |