From owner-svn-src-all@freebsd.org Fri Aug 16 21:17:57 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 604F5AF412; Fri, 16 Aug 2019 21:17:57 +0000 (UTC) (envelope-from hselasky@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 469GPd1rf4z4n5J; Fri, 16 Aug 2019 21:17:57 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1D16D74D0; Fri, 16 Aug 2019 21:17:57 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7GLHukG042570; Fri, 16 Aug 2019 21:17:56 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7GLHukG042568; Fri, 16 Aug 2019 21:17:56 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201908162117.x7GLHukG042568@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Fri, 16 Aug 2019 21:17:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r351146 - head/usr.sbin/usbconfig X-SVN-Group: head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: head/usr.sbin/usbconfig X-SVN-Commit-Revision: 351146 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Aug 2019 21:17:57 -0000 Author: hselasky Date: Fri Aug 16 21:17:56 2019 New Revision: 351146 URL: https://svnweb.freebsd.org/changeset/base/351146 Log: Implement detach_kernel_driver command in usbconfig(8). Submitted by: Kevin Zheng PR: 239916 MFC after: 1 week Modified: head/usr.sbin/usbconfig/usbconfig.8 head/usr.sbin/usbconfig/usbconfig.c Modified: head/usr.sbin/usbconfig/usbconfig.8 ============================================================================== --- head/usr.sbin/usbconfig/usbconfig.8 Fri Aug 16 21:14:27 2019 (r351145) +++ head/usr.sbin/usbconfig/usbconfig.8 Fri Aug 16 21:17:56 2019 (r351146) @@ -23,7 +23,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd April 29, 2018 +.Dd August 16, 2019 .Dt USBCONFIG 8 .Os .Sh NAME @@ -52,6 +52,9 @@ Should only be used in conjunction with the unit argum .It Fl d Ar [ugen]. 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". +.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. .El @@ -71,7 +74,7 @@ the interface drivers and reducing the power consumpti but without going into power saving mode or detaching from the bus. In some cases, it prevents the device from charging. .It Cm set_alt Ar alt_index -Choose the alternate interface for the USB device. +Choose the alternate interface for the selected interface and USB device. Alternative settings for the current configuration are available as the .Ar bAlternateSetting in @@ -119,6 +122,8 @@ Display the list of interface drivers (such as or .Xr u3g 4 ) currently attached to the device. +.It Cm detach_kernel_driver +Detach kernel driver for the selected interface and USB device. .It Cm suspend Force the device to suspend. .It Cm resume Modified: head/usr.sbin/usbconfig/usbconfig.c ============================================================================== --- head/usr.sbin/usbconfig/usbconfig.c Fri Aug 16 21:14:27 2019 (r351145) +++ head/usr.sbin/usbconfig/usbconfig.c Fri Aug 16 21:17:56 2019 (r351146) @@ -89,6 +89,7 @@ struct options { uint8_t got_add_quirk:1; uint8_t got_dump_string:1; uint8_t got_do_request:1; + uint8_t got_detach_kernel_driver:1; }; struct token { @@ -111,6 +112,7 @@ enum { T_ADD_QUIRK, T_REMOVE_QUIRK, T_SHOW_IFACE_DRIVER, + T_DETACH_KERNEL_DRIVER, T_DUMP_QUIRK_NAMES, T_DUMP_DEVICE_QUIRKS, T_DUMP_ALL_DESC, @@ -144,6 +146,7 @@ static const struct token token[] = { {"remove_dev_quirk_vplh", T_REMOVE_DEVICE_QUIRK, 5}, {"add_quirk", T_ADD_QUIRK, 1}, {"remove_quirk", T_REMOVE_QUIRK, 1}, + {"detach_kernel_driver", T_DETACH_KERNEL_DRIVER, 0}, {"dump_quirk_names", T_DUMP_QUIRK_NAMES, 0}, {"dump_device_quirks", T_DUMP_DEVICE_QUIRKS, 0}, {"dump_all_desc", T_DUMP_ALL_DESC, 0}, @@ -284,6 +287,7 @@ usage(void) " remove_dev_quirk_vplh " "\n" " add_quirk " "\n" " remove_quirk " "\n" + " detach_kernel_driver" "\n" " dump_quirk_names" "\n" " dump_device_quirks" "\n" " dump_all_desc" "\n" @@ -492,6 +496,11 @@ flush_command(struct libusb20_backend *pbe, struct opt err(1, "could not set power ON"); } } + if (opt->got_detach_kernel_driver) { + if (libusb20_dev_detach_kernel_driver(pdev, opt->iface)) { + err(1, "could not detach kernel driver"); + } + } dump_any = (opt->got_dump_all_desc || opt->got_dump_device_desc || @@ -608,6 +617,13 @@ main(int argc, char **argv) opt->quirkname = argv[n + 5]; n += 5; opt->got_remove_device_quirk = 1; + opt->got_any++; + break; + + case T_DETACH_KERNEL_DRIVER: + if (opt->got_detach_kernel_driver) + duplicate_option(argv[n]); + opt->got_detach_kernel_driver = 1; opt->got_any++; break;