summaryrefslogtreecommitdiffstats
path: root/usr.sbin/usbconfig
diff options
context:
space:
mode:
authorthompsa <thompsa@FreeBSD.org>2009-02-24 03:43:05 +0000
committerthompsa <thompsa@FreeBSD.org>2009-02-24 03:43:05 +0000
commitf1a1841fd46d19db9e9c9715c72e7253c6821208 (patch)
treef4792f6be15577c3da25ef086c5ab15d262ccb99 /usr.sbin/usbconfig
parent8041f6f6948e9212d22713bd2c0c2bec494e144c (diff)
downloadFreeBSD-src-f1a1841fd46d19db9e9c9715c72e7253c6821208.zip
FreeBSD-src-f1a1841fd46d19db9e9c9715c72e7253c6821208.tar.gz
MFp4 //depot/projects/usb@157974
Add support for setting and getting the USB template value through libusb20 and usbconfig. Submitted by: Hans Petter Selasky
Diffstat (limited to 'usr.sbin/usbconfig')
-rw-r--r--usr.sbin/usbconfig/usbconfig.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/usr.sbin/usbconfig/usbconfig.c b/usr.sbin/usbconfig/usbconfig.c
index 4b69dc5..8a4ac1d 100644
--- a/usr.sbin/usbconfig/usbconfig.c
+++ b/usr.sbin/usbconfig/usbconfig.c
@@ -42,6 +42,7 @@
struct options {
const char *quirkname;
void *buffer;
+ int template;
gid_t gid;
uid_t uid;
mode_t mode;
@@ -65,6 +66,8 @@ struct options {
uint8_t got_set_alt:1;
uint8_t got_set_owner:1;
uint8_t got_set_perm:1;
+ uint8_t got_set_template:1;
+ uint8_t got_get_template:1;
uint8_t got_suspend:1;
uint8_t got_resume:1;
uint8_t got_reset:1;
@@ -99,6 +102,8 @@ enum {
T_SET_ALT,
T_SET_OWNER,
T_SET_PERM,
+ T_SET_TEMPLATE,
+ T_GET_TEMPLATE,
T_ADD_DEVICE_QUIRK,
T_REMOVE_DEVICE_QUIRK,
T_SHOW_IFACE_DRIVER,
@@ -130,6 +135,8 @@ static const struct token token[] = {
{"set_alt", T_SET_ALT, 1},
{"set_owner", T_SET_OWNER, 1},
{"set_perm", T_SET_PERM, 1},
+ {"set_template", T_SET_TEMPLATE, 1},
+ {"get_template", T_GET_TEMPLATE, 0},
{"add_dev_quirk_vplh", T_ADD_DEVICE_QUIRK, 5},
{"remove_dev_quirk_vplh", T_REMOVE_DEVICE_QUIRK, 5},
{"dump_quirk_names", T_DUMP_QUIRK_NAMES, 0},
@@ -283,6 +290,8 @@ usage(void)
" set_alt <alt_index>" "\n"
" set_owner <user:group>" "\n"
" set_perm <mode>" "\n"
+ " set_template <template>" "\n"
+ " 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"
" dump_quirk_names" "\n"
@@ -358,6 +367,20 @@ flush_command(struct libusb20_backend *pbe, struct options *opt)
be_dev_add_quirk(pbe,
opt->vid, opt->pid, opt->lo_rev, opt->hi_rev, opt->quirkname);
}
+ if (opt->got_set_template) {
+ opt->got_any--;
+ if (libusb20_be_set_template(pbe, opt->template)) {
+ printf("Setting USB template %u failed, "
+ "continuing.\n", opt->template);
+ }
+ }
+ if (opt->got_get_template) {
+ opt->got_any--;
+ if (libusb20_be_get_template(pbe, &opt->template))
+ printf("USB template: <unknown>\n");
+ else
+ printf("USB template: %u\n", opt->template);
+ }
if (opt->got_any == 0) {
/*
* do not scan through all the devices if there are no valid
@@ -691,6 +714,16 @@ main(int argc, char **argv)
opt->got_any++;
n++;
break;
+ case T_SET_TEMPLATE:
+ opt->template = a_mode(argv[n + 1]);
+ opt->got_set_template = 1;
+ opt->got_any++;
+ n++;
+ break;
+ case T_GET_TEMPLATE:
+ opt->got_get_template = 1;
+ opt->got_any++;
+ break;
case T_DUMP_DEVICE_DESC:
opt->got_dump_device_desc = 1;
opt->got_any++;
OpenPOWER on IntegriCloud