aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2016-08-29 22:48:36 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2016-08-29 22:48:36 +0000
commite05ec081fe81beb79567b82723bd045aa50f19c0 (patch)
tree49d4724d89f0eae45adf3d20810b4392775e83b1 /sys
parenta3d5eb2481e8d136300b107d93c282e63bf36969 (diff)
downloadsrc-e05ec081fe81beb79567b82723bd045aa50f19c0.tar.gz
src-e05ec081fe81beb79567b82723bd045aa50f19c0.zip
Implement 'devctl clear driver' to undo a previous 'devctl set driver'.
Add a new 'clear driver' command for devctl along with the accompanying ioctl and devctl_clear_driver() library routine to reset a device to use a wildcard devclass instead of a fixed devclass. This can be used to undo a previous 'set driver' command. After the device's name has been reset to permit wildcard names, it is reprobed so that it can attach to newly-available (to it) device drivers. MFC after: 1 month Sponsored by: Chelsio Communications
Notes
Notes: svn path=/head/; revision=305034
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/subr_bus.c20
-rw-r--r--sys/sys/bus.h4
2 files changed, 24 insertions, 0 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index 6a56f6baeb76..ddc5384a82dd 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -5349,6 +5349,7 @@ devctl2_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag,
case DEV_SUSPEND:
case DEV_RESUME:
case DEV_SET_DRIVER:
+ case DEV_CLEAR_DRIVER:
case DEV_RESCAN:
case DEV_DELETE:
error = priv_check(td, PRIV_DRIVER);
@@ -5514,6 +5515,25 @@ devctl2_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag,
error = device_probe_and_attach(dev);
break;
}
+ case DEV_CLEAR_DRIVER:
+ if (!(dev->flags & DF_FIXEDCLASS)) {
+ error = 0;
+ break;
+ }
+ if (device_is_attached(dev)) {
+ if (req->dr_flags & DEVF_CLEAR_DRIVER_DETACH)
+ error = device_detach(dev);
+ else
+ error = EBUSY;
+ if (error)
+ break;
+ }
+
+ dev->flags &= ~DF_FIXEDCLASS;
+ dev->flags |= DF_WILDCARD;
+ devclass_delete_device(dev->devclass, dev);
+ error = device_probe_and_attach(dev);
+ break;
case DEV_RESCAN:
if (!device_is_attached(dev)) {
error = ENXIO;
diff --git a/sys/sys/bus.h b/sys/sys/bus.h
index bb13a29f0913..9139edab4a96 100644
--- a/sys/sys/bus.h
+++ b/sys/sys/bus.h
@@ -117,6 +117,7 @@ struct devreq {
#define DEV_SUSPEND _IOW('D', 5, struct devreq)
#define DEV_RESUME _IOW('D', 6, struct devreq)
#define DEV_SET_DRIVER _IOW('D', 7, struct devreq)
+#define DEV_CLEAR_DRIVER _IOW('D', 8, struct devreq)
#define DEV_RESCAN _IOW('D', 9, struct devreq)
#define DEV_DELETE _IOW('D', 10, struct devreq)
@@ -126,6 +127,9 @@ struct devreq {
/* Flags for DEV_SET_DRIVER. */
#define DEVF_SET_DRIVER_DETACH 0x0000001 /* Detach existing driver. */
+/* Flags for DEV_CLEAR_DRIVER. */
+#define DEVF_CLEAR_DRIVER_DETACH 0x0000001 /* Detach existing driver. */
+
/* Flags for DEV_DELETE. */
#define DEVF_FORCE_DELETE 0x0000001