From 912280b4b4bb73550319bb860aa3d3b641e1ddfe Mon Sep 17 00:00:00 2001 From: Edward Tomasz Napierala Date: Tue, 17 Apr 2018 19:39:47 +0000 Subject: [PATCH] Make it possible to pass the ugenX.Y to usbconfig(8) without using "-d", eg "usbconfig ugen1.2 dump_all_desc". Reviewed by: hselasky@ MFC after: 2 weeks Sponsored by: The FreeBSD Foundation --- usr.sbin/usbconfig/usbconfig.8 | 4 ++-- usr.sbin/usbconfig/usbconfig.c | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/usr.sbin/usbconfig/usbconfig.8 b/usr.sbin/usbconfig/usbconfig.8 index 6c14028d4bf5..57f118ad8d65 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 30, 2017 +.Dd April 17, 2018 .Dt USBCONFIG 8 .Os .Sh NAME @@ -35,7 +35,7 @@ .Op Fl a Ar addr .Op cmds... .Nm -.Op Fl d Ar [ugen]. +.Op Oo Fl d Oc Ar [ugen]. .Op cmds... .Sh DESCRIPTION The diff --git a/usr.sbin/usbconfig/usbconfig.c b/usr.sbin/usbconfig/usbconfig.c index 4c5bfb61c3ef..2fd45c500868 100644 --- a/usr.sbin/usbconfig/usbconfig.c +++ b/usr.sbin/usbconfig/usbconfig.c @@ -820,6 +820,29 @@ main(int argc, char **argv) opt->got_any++; break; default: + if (n == 1) { + ptr = argv[n]; + + if ((ptr[0] == 'u') && + (ptr[1] == 'g') && + (ptr[2] == 'e') && + (ptr[3] == 'n')) + ptr += 4; + + if ((sscanf(ptr, "%d.%d", + &unit, &addr) != 2) || + (unit < 0) || (unit > 65535) || + (addr < 0) || (addr > 65535)) { + usage(); + break; + } + + opt->bus = unit; + opt->addr = addr; + opt->got_bus = 1; + opt->got_addr = 1; + break; + } usage(); break; }