Lines Matching refs:opt

307 reset_options(struct options *opt)
309 if (opt->buffer)
310 free(opt->buffer);
311 memset(opt, 0, sizeof(*opt));
315 flush_command(struct libusb20_backend *pbe, struct options *opt)
322 if ((opt->got_suspend +
323 opt->got_resume +
324 opt->got_reset +
325 opt->got_set_config +
326 opt->got_set_alt +
327 opt->got_power_save +
328 opt->got_power_on +
329 opt->got_power_off) > 1) {
335 if (opt->got_dump_quirk_names) {
336 opt->got_any--;
339 if (opt->got_dump_device_quirks) {
340 opt->got_any--;
343 if (opt->got_remove_device_quirk) {
344 opt->got_any--;
346 opt->vid, opt->pid, opt->lo_rev, opt->hi_rev, opt->quirkname);
348 if (opt->got_add_device_quirk) {
349 opt->got_any--;
351 opt->vid, opt->pid, opt->lo_rev, opt->hi_rev, opt->quirkname);
353 if (opt->got_set_template) {
354 opt->got_any--;
355 if (libusb20_be_set_template(pbe, opt->template)) {
357 "continuing.\n", opt->template);
360 if (opt->got_get_template) {
361 opt->got_any--;
362 if (libusb20_be_get_template(pbe, &opt->template))
365 printf("USB template: %u\n", opt->template);
367 if (opt->got_any == 0) {
376 if (opt->got_bus &&
377 (libusb20_dev_get_bus_number(pdev) != opt->bus)) {
380 if (opt->got_addr &&
381 (libusb20_dev_get_address(pdev) != opt->addr)) {
386 if (opt->got_remove_quirk) {
394 opt->quirkname);
397 if (opt->got_add_quirk) {
405 opt->quirkname);
411 if (opt->got_dump_string) {
412 dump_string_by_index(pdev, opt->string_index);
414 if (opt->got_do_request) {
418 if (libusb20_dev_request_sync(pdev, &opt->setup,
419 opt->buffer, &actlen, 5000 /* 5 seconds */ , 0)) {
421 } else if (!(opt->setup.bmRequestType &
429 ((uint8_t *)opt->buffer)[t],
436 c = ((uint8_t *)opt->buffer)[t];
445 if (opt->got_set_config) {
447 opt->config_index)) {
451 if (opt->got_set_alt) {
452 if (libusb20_dev_set_alt_index(pdev, opt->iface,
453 opt->alt_index)) {
457 if (opt->got_reset) {
462 if (opt->got_suspend) {
468 if (opt->got_resume) {
474 if (opt->got_power_off) {
480 if (opt->got_power_save) {
486 if (opt->got_power_on) {
492 if (opt->got_detach_kernel_driver) {
493 if (libusb20_dev_detach_kernel_driver(pdev, opt->iface)) {
498 (opt->got_dump_all_desc ||
499 opt->got_dump_device_desc ||
500 opt->got_dump_curr_config ||
501 opt->got_dump_all_config ||
502 opt->got_dump_info ||
503 opt->got_dump_stats);
505 if (opt->got_list || dump_any) {
507 opt->got_show_iface_driver);
509 if (opt->got_dump_device_desc) {
513 if (opt->got_dump_all_config) {
516 } else if (opt->got_dump_curr_config) {
519 } else if (opt->got_dump_all_desc) {
524 if (opt->got_dump_stats) {
540 reset_options(opt);
547 struct options *opt = &options;
565 opt->addr = num_id(optarg, "addr");
566 opt->got_addr = 1;
585 opt->bus = unit;
586 opt->addr = addr;
587 opt->got_bus = 1;
588 opt->got_addr = 1;
596 opt->iface = num_id(optarg, "iface");
600 opt->bus = num_id(optarg, "busnum");
601 opt->got_bus = 1;
605 opt->got_dump_device_desc = 1;
606 opt->got_dump_curr_config = 1;
607 opt->got_show_iface_driver = 1;
608 opt->got_any += 2; /* only the dump options count */
626 if (opt->got_add_quirk) {
627 flush_command(pbe, opt);
629 opt->quirkname = argv[n + 1];
632 opt->got_add_quirk = 1;
633 opt->got_any++;
637 if (opt->got_remove_quirk) {
638 flush_command(pbe, opt);
640 opt->quirkname = argv[n + 1];
643 opt->got_remove_quirk = 1;
644 opt->got_any++;
648 if (opt->got_add_device_quirk) {
649 flush_command(pbe, opt);
651 opt->vid = num_id(argv[n + 1], "Vendor ID");
652 opt->pid = num_id(argv[n + 2], "Product ID");
653 opt->lo_rev = num_id(argv[n + 3], "Low Revision");
654 opt->hi_rev = num_id(argv[n + 4], "High Revision");
655 opt->quirkname = argv[n + 5];
658 opt->got_add_device_quirk = 1;
659 opt->got_any++;
663 if (opt->got_remove_device_quirk) {
664 flush_command(pbe, opt);
666 opt->vid = num_id(argv[n + 1], "Vendor ID");
667 opt->pid = num_id(argv[n + 2], "Product ID");
668 opt->lo_rev = num_id(argv[n + 3], "Low Revision");
669 opt->hi_rev = num_id(argv[n + 4], "High Revision");
670 opt->quirkname = argv[n + 5];
672 opt->got_remove_device_quirk = 1;
673 opt->got_any++;
677 if (opt->got_detach_kernel_driver)
679 opt->got_detach_kernel_driver = 1;
680 opt->got_any++;
684 if (opt->got_dump_quirk_names)
686 opt->got_dump_quirk_names = 1;
687 opt->got_any++;
691 if (opt->got_dump_device_quirks)
693 opt->got_dump_device_quirks = 1;
694 opt->got_any++;
698 opt->got_show_iface_driver = 1;
702 if (opt->got_set_config)
704 opt->config_index = num_id(argv[n + 1], "cfg_index");
705 opt->got_set_config = 1;
706 opt->got_any++;
710 if (opt->got_set_alt)
712 opt->alt_index = num_id(argv[n + 1], "cfg_index");
713 opt->got_set_alt = 1;
714 opt->got_any++;
718 if (opt->got_set_template)
720 opt->template = get_int(argv[n + 1]);
721 opt->got_set_template = 1;
722 opt->got_any++;
726 if (opt->got_get_template)
728 opt->got_get_template = 1;
729 opt->got_any++;
732 if (opt->got_dump_all_desc)
734 opt->got_dump_all_desc = 1;
735 opt->got_any++;
738 if (opt->got_dump_device_desc)
740 opt->got_dump_device_desc = 1;
741 opt->got_any++;
744 if (opt->got_dump_curr_config)
746 opt->got_dump_curr_config = 1;
747 opt->got_any++;
750 if (opt->got_dump_all_config)
752 opt->got_dump_all_config = 1;
753 opt->got_any++;
756 if (opt->got_dump_info)
758 opt->got_dump_info = 1;
759 opt->got_any++;
762 if (opt->got_dump_stats)
764 opt->got_dump_stats = 1;
765 opt->got_any++;
768 if (opt->got_dump_string)
770 opt->string_index = num_id(argv[n + 1], "str_index");
771 opt->got_dump_string = 1;
772 opt->got_any++;
776 if (opt->got_suspend)
778 opt->got_suspend = 1;
779 opt->got_any++;
782 if (opt->got_resume)
784 opt->got_resume = 1;
785 opt->got_any++;
788 if (opt->got_power_off)
790 opt->got_power_off = 1;
791 opt->got_any++;
794 if (opt->got_power_save)
796 opt->got_power_save = 1;
797 opt->got_any++;
800 if (opt->got_power_on)
802 opt->got_power_on = 1;
803 opt->got_any++;
806 if (opt->got_reset)
808 opt->got_reset = 1;
809 opt->got_any++;
812 if (opt->got_list)
814 opt->got_list = 1;
815 opt->got_any++;
818 if (opt->got_do_request)
820 LIBUSB20_INIT(LIBUSB20_CONTROL_SETUP, &opt->setup);
821 opt->setup.bmRequestType = num_id(argv[n + 1], "bmReqTyp");
822 opt->setup.bRequest = num_id(argv[n + 2], "bReq");
823 opt->setup.wValue = num_id(argv[n + 3], "wVal");
824 opt->setup.wIndex = num_id(argv[n + 4], "wIndex");
825 opt->setup.wLength = num_id(argv[n + 5], "wLen");
826 if (opt->setup.wLength != 0) {
827 opt->buffer = malloc(opt->setup.wLength);
829 opt->buffer = NULL;
834 if (!(opt->setup.bmRequestType &
838 if (t < opt->setup.wLength) {
841 t = opt->setup.wLength;
843 ((uint8_t *)opt->buffer)[t] =
846 n += opt->setup.wLength;
848 opt->got_do_request = 1;
849 opt->got_any++;
869 opt->bus = unit;
870 opt->addr = addr;
871 opt->got_bus = 1;
872 opt->got_addr = 1;
879 if (opt->got_any) {
881 flush_command(pbe, opt);
884 opt->got_list = 1;
885 opt->got_any++;
886 flush_command(pbe, opt);