From nobody Mon Dec 20 21:09:26 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A8FC01903142; Mon, 20 Dec 2021 21:09:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JHsfG2bsqz3FNl; Mon, 20 Dec 2021 21:09:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 359291D501; Mon, 20 Dec 2021 21:09:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BKL9Qnq005656; Mon, 20 Dec 2021 21:09:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BKL9QmJ005655; Mon, 20 Dec 2021 21:09:26 GMT (envelope-from git) Date: Mon, 20 Dec 2021 21:09:26 GMT Message-Id: <202112202109.1BKL9QmJ005655@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Joerg Wunsch Subject: git: d69b9cc26d1c - main - usbconfig: implement a -v option List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: joerg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d69b9cc26d1c24a4cbc37478a571b1f531aa7bcc Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640034566; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Xq2Y/gD1uq1hj65pyeMUi92x2bHbqGDpuovTYvstfDc=; b=V2o1xNfW11jWR78GI6S957nIh8babz+ceyYia+vnz0aJA/CZbPNJP9GxAvj+dIUfwJAvVQ fj4/QQAU01iE9U1at9+ShaiWMPOfSd0MdhOYeZoop8nDX4Fn/z3ZM92kWZel603y3Uozfl dhJn6RSJPFDumXsEI/YzH6D9Byac3AAvRMdScDjP+UdnQYWV3aUKWdEj0kCG6eClNgnEC+ RLDSUAyplRsbWZ3rtZ5MoQ1EUo/7ZLpWf1cU75vmsfLSzTAJt4xFM0ebogAJeeNsbTLLpu DRnRQ4Ja9L+7mQn46u3vRHs+xlADWHjdEzTb9Ab7GzDn7OMVNZpwWnwovDzbWQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640034566; a=rsa-sha256; cv=none; b=aRla12ayAAubtfvchGRKvwJxLma4qhlnKGmIhXAnZjCIEw2ut95pmZ19RC0tBRfYF+A3jr FgkZbOt39xXbEiqEqS7P+3An4fUVYVV5BqsAGIh/XGWmtcAojCpA5Gy1w/2dpZcLBRPfuO zzNkJfMshCn8Dy69naHvWk2lLVSInuJ4etxHG0MI7BoprDD2yzNmzI7Pfc6aleQ4qRYzMS Cs9ynIuGKvuL3n4jHh8ETcqCh4vZwVrTIP4PaRuy0LYPIh5NN86N2ZPItIY2Un6CuVPKK7 +atnzkr628fsnhiD4d5MH21JUoRo0/orS2nR5u3vUR8Qny/iLpJpTavoG8w5HA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by joerg: URL: https://cgit.FreeBSD.org/src/commit/?id=d69b9cc26d1c24a4cbc37478a571b1f531aa7bcc commit d69b9cc26d1c24a4cbc37478a571b1f531aa7bcc Author: Joerg Wunsch AuthorDate: 2021-12-20 19:33:05 +0000 Commit: Joerg Wunsch CommitDate: 2021-12-20 21:08:57 +0000 usbconfig: implement a -v option Implement a -v option to usbconfig(8), as a shortcut for the most frequently needed commands dump_device_desc, dump_curr_config_desc, and show_ifdrv. While here, implement a real -h option that has been promised by the man page. Use to declare the utility return codes. Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D33586 MFC after: 2 weeks --- usr.sbin/usbconfig/usbconfig.8 | 16 +++++++++++++--- usr.sbin/usbconfig/usbconfig.c | 28 ++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/usr.sbin/usbconfig/usbconfig.8 b/usr.sbin/usbconfig/usbconfig.8 index dd6264451cf7..e34cf7cfd5d0 100644 --- a/usr.sbin/usbconfig/usbconfig.8 +++ b/usr.sbin/usbconfig/usbconfig.8 @@ -23,7 +23,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd December 20, 2021 +.Dd December 21, 2021 .Dt USBCONFIG 8 .Os .Sh NAME @@ -34,10 +34,12 @@ .Op Fl u Ar unit .Op Fl a Ar addr .Op Fl i Ar interface_index +.Op Fl v .Op cmds... .Nm .Fl d Ar [[/dev/]ugen]. .Op Fl i Ar interface_index +.Op Fl v .Op cmds... .Sh DESCRIPTION The @@ -56,11 +58,19 @@ Limit device range to USB devices connected to the given unit and address. The unit and address coordinates may be prefixed by the lowercased word "ugen", or the full path name .Pa /dev/ugen . +.It Fl h +Show help and available commands. .It Fl i Ar interface_index Specify interface index as indicated by the command description. If this argument is not specified a value of zero will be used for the interface index. -.It Fl h -Show help and available commands. +.It Fl v +Shortcut to activate the +.Cm dump_device_desc , +.Cm dump_curr_config_desc , +and +.Cm show_ifdrv +commands +.Pq Dq verbose mode . .El .Pp The following commands may be used with diff --git a/usr.sbin/usbconfig/usbconfig.c b/usr.sbin/usbconfig/usbconfig.c index 986aa6cd8f7b..49acbf68b33c 100644 --- a/usr.sbin/usbconfig/usbconfig.c +++ b/usr.sbin/usbconfig/usbconfig.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -267,12 +268,12 @@ duplicate_option(const char *ptr) } static void -usage(void) +usage(int exitcode) { fprintf(stderr, "" "usbconfig - configure the USB subsystem" "\n" - "usage: usbconfig [-u ] [-a ] [-i ] [cmds...]" "\n" - "usage: usbconfig -d [ugen]. [-i ] [cmds...]" "\n" + "usage: usbconfig [-u ] [-a ] [-i ] [-v] [cmds...]" "\n" + "usage: usbconfig -d [ugen]. [-i ] [-v] [cmds...]" "\n" "commands:" "\n" " set_config " "\n" " set_alt " "\n" @@ -558,13 +559,13 @@ main(int argc, char **argv) int ch; if (argc < 1) { - usage(); + usage(EX_USAGE); } pbe = libusb20_be_alloc_default(); if (pbe == NULL) err(1, "could not access USB backend\n"); - while ((ch = getopt(argc, argv, "a:d:i:u:")) != -1) { + while ((ch = getopt(argc, argv, "a:d:hi:u:v")) != -1) { switch (ch) { case 'a': opt->addr = num_id(optarg, "addr"); @@ -593,6 +594,10 @@ main(int argc, char **argv) opt->got_addr = 1; break; + case 'h': + usage(EX_OK); + break; + case 'i': opt->iface = num_id(optarg, "iface"); break; @@ -602,8 +607,15 @@ main(int argc, char **argv) opt->got_bus = 1; break; + case 'v': + opt->got_dump_device_desc = 1; + opt->got_dump_curr_config = 1; + opt->got_show_iface_driver = 1; + opt->got_any += 2; /* only the dump options count */ + break; + default: - usage(); + usage(EX_USAGE); } } argc -= optind; @@ -856,7 +868,7 @@ main(int argc, char **argv) &unit, &addr) != 2) || (unit < 0) || (unit > 65535) || (addr < 0) || (addr > 65535)) { - usage(); + usage(EX_USAGE); break; } @@ -866,7 +878,7 @@ main(int argc, char **argv) opt->got_addr = 1; break; } - usage(); + usage(EX_USAGE); break; } }