PERFORCE change 172130 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Wed Dec 23 09:59:04 UTC 2009
http://p4web.freebsd.org/chv.cgi?CH=172130
Change 172130 by hselasky at hselasky_laptop001 on 2009/12/23 09:59:02
usbconfig:
- improve command line parsing
- add new convenience commands that can add and remove quirks based on -u and -a options.
- patch by: HPS
Affected files ...
.. //depot/projects/usb/src/usr.sbin/usbconfig/usbconfig.c#17 edit
Differences ...
==== //depot/projects/usb/src/usr.sbin/usbconfig/usbconfig.c#17 (text+ko) ====
@@ -1,6 +1,6 @@
/* $FreeBSD: src/usr.sbin/usbconfig/usbconfig.c,v 1.8 2009/03/17 21:21:33 delphij Exp $ */
/*-
- * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
+ * Copyright (c) 2008-2009 Hans Petter Selasky. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -81,6 +81,8 @@
uint8_t got_show_iface_driver:1;
uint8_t got_remove_device_quirk:1;
uint8_t got_add_device_quirk:1;
+ uint8_t got_remove_quirk:1;
+ uint8_t got_add_quirk:1;
uint8_t got_dump_string:1;
uint8_t got_do_request:1;
};
@@ -101,6 +103,8 @@
T_GET_TEMPLATE,
T_ADD_DEVICE_QUIRK,
T_REMOVE_DEVICE_QUIRK,
+ T_ADD_QUIRK,
+ T_REMOVE_QUIRK,
T_SHOW_IFACE_DRIVER,
T_DUMP_QUIRK_NAMES,
T_DUMP_DEVICE_QUIRKS,
@@ -131,6 +135,8 @@
{"get_template", T_GET_TEMPLATE, 0},
{"add_dev_quirk_vplh", T_ADD_DEVICE_QUIRK, 5},
{"remove_dev_quirk_vplh", T_REMOVE_DEVICE_QUIRK, 5},
+ {"add_quirk", T_ADD_QUIRK, 1},
+ {"remove_quirk", T_REMOVE_QUIRK, 1},
{"dump_quirk_names", T_DUMP_QUIRK_NAMES, 0},
{"dump_device_quirks", T_DUMP_DEVICE_QUIRKS, 0},
{"dump_device_desc", T_DUMP_DEVICE_DESC, 0},
@@ -259,6 +265,8 @@
" get_template" "\n"
" add_dev_quirk_vplh <vid> <pid> <lo_rev> <hi_rev> <quirk>" "\n"
" remove_dev_quirk_vplh <vid> <pid> <lo_rev> <hi_rev> <quirk>" "\n"
+ " add_quirk <quirk>" "\n"
+ " remove_quirk <quirk>" "\n"
" dump_quirk_names" "\n"
" dump_device_quirks" "\n"
" dump_device_desc" "\n"
@@ -360,6 +368,28 @@
}
matches++;
+ if (opt->got_remove_quirk) {
+ struct LIBUSB20_DEVICE_DESC_DECODED *ddesc;
+
+ ddesc = libusb20_dev_get_device_desc(pdev);
+
+ be_dev_remove_quirk(pbe,
+ ddesc->idVendor, ddesc->idProduct,
+ ddesc->bcdDevice, ddesc->bcdDevice,
+ opt->quirkname);
+ }
+
+ if (opt->got_add_quirk) {
+ struct LIBUSB20_DEVICE_DESC_DECODED *ddesc;
+
+ ddesc = libusb20_dev_get_device_desc(pdev);
+
+ be_dev_add_quirk(pbe,
+ ddesc->idVendor, ddesc->idProduct,
+ ddesc->bcdDevice, ddesc->bcdDevice,
+ opt->quirkname);
+ }
+
if (libusb20_dev_open(pdev, 0)) {
err(1, "could not open device");
}
@@ -518,6 +548,28 @@
if (t > 255)
t = 255;
switch (get_token(argv[n], t)) {
+ case T_ADD_QUIRK:
+ if (opt->got_add_quirk) {
+ flush_command(pbe, opt);
+ }
+ opt->quirkname = argv[n + 1];
+ n++;
+
+ opt->got_add_quirk = 1;
+ opt->got_any++;
+ break;
+
+ case T_REMOVE_QUIRK:
+ if (opt->got_remove_quirk) {
+ flush_command(pbe, opt);
+ }
+ opt->quirkname = argv[n + 1];
+ n++;
+
+ opt->got_remove_quirk = 1;
+ opt->got_any++;
+ break;
+
case T_ADD_DEVICE_QUIRK:
if (opt->got_add_device_quirk) {
flush_command(pbe, opt);
@@ -548,11 +600,15 @@
break;
case T_DUMP_QUIRK_NAMES:
+ if (opt->got_dump_quirk_names)
+ break;
opt->got_dump_quirk_names = 1;
opt->got_any++;
break;
case T_DUMP_DEVICE_QUIRKS:
+ if (opt->got_dump_device_quirks)
+ break;
opt->got_dump_device_quirks = 1;
opt->got_any++;
break;
@@ -581,40 +637,56 @@
n++;
break;
case T_SET_CONFIG:
+ if (opt->got_set_config)
+ break;
opt->config_index = num_id(argv[n + 1], "cfg_index");
opt->got_set_config = 1;
opt->got_any++;
n++;
break;
case T_SET_ALT:
+ if (opt->got_set_alt)
+ break;
opt->alt_index = num_id(argv[n + 1], "cfg_index");
opt->got_set_alt = 1;
opt->got_any++;
n++;
break;
case T_SET_TEMPLATE:
+ if (opt->got_set_template)
+ break;
opt->template = get_int(argv[n + 1]);
opt->got_set_template = 1;
opt->got_any++;
n++;
break;
case T_GET_TEMPLATE:
+ if (opt->got_get_template)
+ break;
opt->got_get_template = 1;
opt->got_any++;
break;
case T_DUMP_DEVICE_DESC:
+ if (opt->got_dump_device_desc)
+ break;
opt->got_dump_device_desc = 1;
opt->got_any++;
break;
case T_DUMP_CURR_CONFIG_DESC:
+ if (opt->got_dump_curr_config)
+ break;
opt->got_dump_curr_config = 1;
opt->got_any++;
break;
case T_DUMP_ALL_CONFIG_DESC:
+ if (opt->got_dump_all_config)
+ break;
opt->got_dump_all_config = 1;
opt->got_any++;
break;
case T_DUMP_INFO:
+ if (opt->got_dump_info)
+ break;
opt->got_dump_info = 1;
opt->got_any++;
break;
@@ -628,30 +700,44 @@
n++;
break;
case T_SUSPEND:
+ if (opt->got_suspend)
+ break;
opt->got_suspend = 1;
opt->got_any++;
break;
case T_RESUME:
+ if (opt->got_resume)
+ break;
opt->got_resume = 1;
opt->got_any++;
break;
case T_POWER_OFF:
+ if (opt->got_power_off)
+ break;
opt->got_power_off = 1;
opt->got_any++;
break;
case T_POWER_SAVE:
+ if (opt->got_power_save)
+ break;
opt->got_power_save = 1;
opt->got_any++;
break;
case T_POWER_ON:
+ if (opt->got_power_on)
+ break;
opt->got_power_on = 1;
opt->got_any++;
break;
case T_RESET:
+ if (opt->got_reset)
+ break;
opt->got_reset = 1;
opt->got_any++;
break;
case T_LIST:
+ if (opt->got_list)
+ break;
opt->got_list = 1;
opt->got_any++;
break;
More information about the p4-projects
mailing list