diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libdevctl/devctl.3 | 44 | ||||
-rw-r--r-- | lib/libdevctl/devctl.c | 8 | ||||
-rw-r--r-- | lib/libdevctl/devctl.h | 1 |
3 files changed, 50 insertions, 3 deletions
diff --git a/lib/libdevctl/devctl.3 b/lib/libdevctl/devctl.3 index 7c4c74b..de4a9b6 100644 --- a/lib/libdevctl/devctl.3 +++ b/lib/libdevctl/devctl.3 @@ -25,12 +25,13 @@ .\" .\" $FreeBSD$ .\" -.Dd February 2, 2016 +.Dd August 29, 2016 .Dt DEVCTL 3 .Os .Sh NAME .Nm devctl , .Nm devctl_attach , +.Nm devctl_clear_driver , .Nm devctl_detach , .Nm devctl_disable , .Nm devctl_enable , @@ -43,6 +44,8 @@ .Ft int .Fn devctl_attach "const char *device" .Ft int +.Fn devctl_clear_driver "const char *device" "bool force" +.Ft int .Fn devctl_detach "const char *device" "bool force" .Ft int .Fn devctl_disable "const char *device" "bool force_detach" @@ -133,9 +136,26 @@ If the device is already attached and is true, the device will be detached from its current device driver before it is attached to the new device driver. +.Pp +The +.Fn devctl_clear_driver +function resets a device so that it can be attached to any valid device +driver rather than only drivers with a previously specified name. +This function is used to undo a previous call to +.Fn devctl_set_driver . +If the device is already attached and +.Fa force +is false, +the request will fail. +If the device is already attached and +.Fa force +is true, +the device will be detached from its current device driver. +After the device's name is reset, +it is reprobed and attached to a suitable device driver if one is found. .Sh RETURN VALUES -.Rv -std devctl_attach devctl_detach devctl_disable devctl_enable \ -devctl_set_driver +.Rv -std devctl_attach devctl_clear_driver devctl_detach \ +devctl_disable devctl_enable devctl_set_driver .Sh ERRORS In addition to specific errors noted below, all of the @@ -244,6 +264,24 @@ The device is disabled. .It Bq Er ENXIO The new device driver failed to attach. .El +.Pp +The +.Fn devctl_clear_driver +function may fail if: +.Bl -tag -width Er +.It Bq Er EBUSY +The device is currently attached to a device driver and +.Fa force +is false. +.It Bq Er EBUSY +The current device driver for +.Fa device +is busy and cannot detach at this time. +.It Bq Er EINVAL +The device is not configured for a specific device driver name. +.It Bq Er ENXIO +The device driver chosen after reprobing failed to attach. +.El .Sh SEE ALSO .Xr devinfo 3 , .Xr devstat 3 , diff --git a/lib/libdevctl/devctl.c b/lib/libdevctl/devctl.c index fa0e6a5..9e3b908 100644 --- a/lib/libdevctl/devctl.c +++ b/lib/libdevctl/devctl.c @@ -108,3 +108,11 @@ devctl_set_driver(const char *device, const char *driver, bool force) req.dr_flags |= DEVF_SET_DRIVER_DETACH; return (devctl_request(DEV_SET_DRIVER, &req)); } + +int +devctl_clear_driver(const char *device, bool force) +{ + + return (devctl_simple_request(DEV_CLEAR_DRIVER, device, force ? + DEVF_CLEAR_DRIVER_DETACH : 0)); +} diff --git a/lib/libdevctl/devctl.h b/lib/libdevctl/devctl.h index 3426cce..d65ea13 100644 --- a/lib/libdevctl/devctl.h +++ b/lib/libdevctl/devctl.h @@ -36,5 +36,6 @@ int devctl_detach(const char *device, bool force); int devctl_enable(const char *device); int devctl_disable(const char *device, bool force_detach); int devctl_set_driver(const char *device, const char *driver, bool force); +int devctl_clear_driver(const char *device, bool force); #endif /* !__DEVCTL_H__ */ |