From owner-svn-src-all@freebsd.org Mon Jan 6 09:40:19 2020 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 54EA11FECA7; Mon, 6 Jan 2020 09:40:19 +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 47rr8g1bDTz4TMC; Mon, 6 Jan 2020 09:40:19 +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 31CF5C602; Mon, 6 Jan 2020 09:40:19 +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 0069eJfA014271; Mon, 6 Jan 2020 09:40:19 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0069eIpu014269; Mon, 6 Jan 2020 09:40:18 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <202001060940.0069eIpu014269@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 6 Jan 2020 09:40:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r356407 - stable/10/usr.sbin/usbconfig X-SVN-Group: stable-10 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/10/usr.sbin/usbconfig X-SVN-Commit-Revision: 356407 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: Mon, 06 Jan 2020 09:40:19 -0000 Author: hselasky Date: Mon Jan 6 09:40:18 2020 New Revision: 356407 URL: https://svnweb.freebsd.org/changeset/base/356407 Log: MFC r351146: Implement detach_kernel_driver command in usbconfig(8). Submitted by: Kevin Zheng PR: 239916 Modified: stable/10/usr.sbin/usbconfig/usbconfig.8 stable/10/usr.sbin/usbconfig/usbconfig.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/usbconfig/usbconfig.8 ============================================================================== --- stable/10/usr.sbin/usbconfig/usbconfig.8 Mon Jan 6 09:38:57 2020 (r356406) +++ stable/10/usr.sbin/usbconfig/usbconfig.8 Mon Jan 6 09:40:18 2020 (r356407) @@ -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: stable/10/usr.sbin/usbconfig/usbconfig.c ============================================================================== --- stable/10/usr.sbin/usbconfig/usbconfig.c Mon Jan 6 09:38:57 2020 (r356406) +++ stable/10/usr.sbin/usbconfig/usbconfig.c Mon Jan 6 09:40:18 2020 (r356407) @@ -87,6 +87,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 { @@ -109,6 +110,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, @@ -142,6 +144,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}, @@ -282,6 +285,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" @@ -490,6 +494,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 || @@ -606,6 +615,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;