aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/devctl/devctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/devctl/devctl.c')
-rw-r--r--usr.sbin/devctl/devctl.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/usr.sbin/devctl/devctl.c b/usr.sbin/devctl/devctl.c
index 824b9075c04e..6b266f42fe40 100644
--- a/usr.sbin/devctl/devctl.c
+++ b/usr.sbin/devctl/devctl.c
@@ -65,12 +65,13 @@ static int devctl_table_handler(struct devctl_command **start,
SET_DECLARE(DEVCTL_DATASET(top), struct devctl_command);
+DEVCTL_TABLE(top, clear);
DEVCTL_TABLE(top, set);
static void
usage(void)
{
- fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
+ fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
"usage: devctl attach device",
" devctl detach [-f] device",
" devctl disable [-f] device",
@@ -78,6 +79,7 @@ usage(void)
" devctl suspend device",
" devctl resume device",
" devctl set driver [-f] device driver",
+ " devctl clear driver [-f] device",
" devctl rescan device",
" devctl delete [-f] device");
exit(1);
@@ -261,6 +263,40 @@ set_driver(int ac, char **av)
}
DEVCTL_COMMAND(set, driver, set_driver);
+static void
+clear_driver_usage(void)
+{
+
+ fprintf(stderr, "usage: devctl clear driver [-f] device\n");
+ exit(1);
+}
+
+static int
+clear_driver(int ac, char **av)
+{
+ bool force;
+ int ch;
+
+ force = false;
+ while ((ch = getopt(ac, av, "f")) != -1)
+ switch (ch) {
+ case 'f':
+ force = true;
+ break;
+ default:
+ clear_driver_usage();
+ }
+ ac -= optind;
+ av += optind;
+
+ if (ac != 1)
+ clear_driver_usage();
+ if (devctl_clear_driver(av[0], force) < 0)
+ err(1, "Failed to clear %s driver", av[0]);
+ return (0);
+}
+DEVCTL_COMMAND(clear, driver, clear_driver);
+
static int
rescan(int ac, char **av)
{