svn commit: r351843 - stable/11/usr.sbin/usbconfig

Hans Petter Selasky hselasky at FreeBSD.org
Thu Sep 5 09:33:49 UTC 2019


Author: hselasky
Date: Thu Sep  5 09:33:48 2019
New Revision: 351843
URL: https://svnweb.freebsd.org/changeset/base/351843

Log:
  MFC r351146:
  Implement detach_kernel_driver command in usbconfig(8).
  
  Submitted by:	Kevin Zheng <kevinz5000 at gmail.com>
  PR:		239916

Modified:
  stable/11/usr.sbin/usbconfig/usbconfig.8
  stable/11/usr.sbin/usbconfig/usbconfig.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.sbin/usbconfig/usbconfig.8
==============================================================================
--- stable/11/usr.sbin/usbconfig/usbconfig.8	Thu Sep  5 09:32:00 2019	(r351842)
+++ stable/11/usr.sbin/usbconfig/usbconfig.8	Thu Sep  5 09:33:48 2019	(r351843)
@@ -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 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]<unit>.<addr>
 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/11/usr.sbin/usbconfig/usbconfig.c
==============================================================================
--- stable/11/usr.sbin/usbconfig/usbconfig.c	Thu Sep  5 09:32:00 2019	(r351842)
+++ stable/11/usr.sbin/usbconfig/usbconfig.c	Thu Sep  5 09:33:48 2019	(r351843)
@@ -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 <vid> <pid> <lo_rev> <hi_rev> <quirk>" "\n"
 	    "  add_quirk <quirk>" "\n"
 	    "  remove_quirk <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;
 


More information about the svn-src-all mailing list