Implement detach_kernel_driver command in usbconfig(8).
Submitted by: Kevin Zheng <kevinz5000@gmail.com> PR: 239916 MFC after: 1 week
This commit is contained in:
parent
ffea06a831
commit
fb50acc6c6
@ -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 argument.
|
||||
.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 consumption to minimum,
|
||||
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
|
||||
|
@ -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 options *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 ||
|
||||
@ -611,6 +620,13 @@ main(int argc, char **argv)
|
||||
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;
|
||||
|
||||
case T_DUMP_QUIRK_NAMES:
|
||||
if (opt->got_dump_quirk_names)
|
||||
duplicate_option(argv[n]);
|
||||
|
Loading…
Reference in New Issue
Block a user