From nobody Tue Jan 18 21:15:41 2022 X-Original-To: dev-commits-src-branches@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 5EAAD1965740; Tue, 18 Jan 2022 21:15:42 +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 4JdhQ572z6z3qwY; Tue, 18 Jan 2022 21:15:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642540542; 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=WnztPiWPXNQOEL4UzTW01wupBnigzhNy2uHi7Dixnsw=; b=yN702ODeS/BnB6yHENdIfpE9qab7FX3N/KX+R0Fw3unD9TUnJ1UOUklbaQH4qCy6dfmhPX 2Vgf1axqVGhurkW+RO4pdfLdiKmynSWUxA+IRIqHU8VNzYwDXoRaU86Xlv3Zp0wJLQEM4E 1afVz+Y01EmsRZgBGP4hTnd3dRwOZGXfPOO+nyefeza2CrzcHsFks4V5ID8DxoyojdgW6p SjBGVADZVMC+K9VJFTdiswj41rXPI9xaQXjEFPwwAdy7ifxZrqLMp+8ca83vVS6wPOcdKB aQ3536IJ7hWPbNRH5MMz4dB5XMbLS9/qrfsxdWZ0Ra9OmdtWpRkz3Sv/35hWJQ== 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 ACCB1754; Tue, 18 Jan 2022 21:15:41 +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 20ILFfSo035643; Tue, 18 Jan 2022 21:15:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20ILFfPp035642; Tue, 18 Jan 2022 21:15:41 GMT (envelope-from git) Date: Tue, 18 Jan 2022 21:15:41 GMT Message-Id: <202201182115.20ILFfPp035642@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Joerg Wunsch Subject: git: bb0b7f405138 - stable/12 - usbconfig: implement a -v option List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/12 X-Git-Reftype: branch X-Git-Commit: bb0b7f405138c1bf208a619847aba4132ae37a19 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642540542; 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=WnztPiWPXNQOEL4UzTW01wupBnigzhNy2uHi7Dixnsw=; b=rl+UNciBrC2YjCMXl98EpONwyLFJw84g7y22SDhdeUs9pBNaOk+Gk6HS/ruqC852VZGLdn fsW0njBm7LCy4gC9TClisBEE7XxbRjAolzq4IsYubTcMIPxbfUHxGpny8+a0FBAhkhG1Z5 zDpB+D6jBP29TcKuaXK78OOswtUOHouVPSWQYuw7e989jYWFYvLSOclIxvx6cL+06QiQp5 2GT841gJN3hhydkLDgpF7A4LE3SAKMqtPHVhGlGf2YhROOk9txsGjXkavtIa2drmsUGKAE aXqQITReLOgYotQQxS4KErAgQrtIzjD9zcGmZget3LTSwwG7ksgBISPUQEokcQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642540542; a=rsa-sha256; cv=none; b=eVwYZr6/O1zb3zJ7SPKFboux7yWYuivtkkLj8R15TeS00AGBS92JAvBG4NUFrXO8ztS8+t m0QrN2Yazu0QM87lkm0TU2sHvSlKwFa7tLFOLWC0gyDtflHOCRL/RdY/o8h75e5UwdHXP2 8QrhaFQZhKKpRVmIRVxQx10Eph2dP0FGG955Z+6zvcmJWORnx/7ufVE5vD+SGOK2VCLroo oVjdrtV/xbhO207EpdXea/pp4lNiTP3w77Iiq0IpVrRLt3teky0ZedTSkWVfvPS+40hYfx tg5I+qMrplTnMbvQRcrfNcXFJoNSbK9Jd4z4LacwfRXRfw75o72MNv+lQ24zQA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by joerg: URL: https://cgit.FreeBSD.org/src/commit/?id=bb0b7f405138c1bf208a619847aba4132ae37a19 commit bb0b7f405138c1bf208a619847aba4132ae37a19 Author: Joerg Wunsch AuthorDate: 2021-12-20 19:33:05 +0000 Commit: Joerg Wunsch CommitDate: 2022-01-18 21:15:15 +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 (cherry picked from commit d69b9cc26d1c24a4cbc37478a571b1f531aa7bcc) --- 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; } }