Lines Matching full:opt
309 reset_options(struct options *opt) in reset_options() argument
311 if (opt->buffer) in reset_options()
312 free(opt->buffer); in reset_options()
313 memset(opt, 0, sizeof(*opt)); in reset_options()
317 flush_command(struct libusb20_backend *pbe, struct options *opt) in flush_command() argument
324 if ((opt->got_suspend + in flush_command()
325 opt->got_resume + in flush_command()
326 opt->got_reset + in flush_command()
327 opt->got_set_config + in flush_command()
328 opt->got_set_alt + in flush_command()
329 opt->got_power_save + in flush_command()
330 opt->got_power_on + in flush_command()
331 opt->got_power_off) > 1) { in flush_command()
337 if (opt->got_dump_quirk_names) { in flush_command()
338 opt->got_any--; in flush_command()
341 if (opt->got_dump_device_quirks) { in flush_command()
342 opt->got_any--; in flush_command()
345 if (opt->got_remove_device_quirk) { in flush_command()
346 opt->got_any--; in flush_command()
348 opt->vid, opt->pid, opt->lo_rev, opt->hi_rev, opt->quirkname); in flush_command()
350 if (opt->got_add_device_quirk) { in flush_command()
351 opt->got_any--; in flush_command()
353 opt->vid, opt->pid, opt->lo_rev, opt->hi_rev, opt->quirkname); in flush_command()
355 if (opt->got_set_template) { in flush_command()
356 opt->got_any--; in flush_command()
357 if (libusb20_be_set_template(pbe, opt->template)) { in flush_command()
359 "continuing.\n", opt->template); in flush_command()
362 if (opt->got_get_template) { in flush_command()
363 opt->got_any--; in flush_command()
364 if (libusb20_be_get_template(pbe, &opt->template)) in flush_command()
367 printf("USB template: %u\n", opt->template); in flush_command()
369 if (opt->got_any == 0) { in flush_command()
378 if (opt->got_bus && in flush_command()
379 (libusb20_dev_get_bus_number(pdev) != opt->bus)) { in flush_command()
382 if (opt->got_addr && in flush_command()
383 (libusb20_dev_get_address(pdev) != opt->addr)) { in flush_command()
388 if (opt->got_remove_quirk) { in flush_command()
396 opt->quirkname); in flush_command()
399 if (opt->got_add_quirk) { in flush_command()
407 opt->quirkname); in flush_command()
413 if (opt->got_dump_string) { in flush_command()
414 dump_string_by_index(pdev, opt->string_index); in flush_command()
416 if (opt->got_do_request) { in flush_command()
420 if (libusb20_dev_request_sync(pdev, &opt->setup, in flush_command()
421 opt->buffer, &actlen, 5000 /* 5 seconds */ , 0)) { in flush_command()
423 } else if (!(opt->setup.bmRequestType & in flush_command()
431 ((uint8_t *)opt->buffer)[t], in flush_command()
438 c = ((uint8_t *)opt->buffer)[t]; in flush_command()
447 if (opt->got_set_config) { in flush_command()
449 opt->config_index)) { in flush_command()
453 if (opt->got_set_alt) { in flush_command()
454 if (libusb20_dev_set_alt_index(pdev, opt->iface, in flush_command()
455 opt->alt_index)) { in flush_command()
459 if (opt->got_reset) { in flush_command()
464 if (opt->got_suspend) { in flush_command()
470 if (opt->got_resume) { in flush_command()
476 if (opt->got_power_off) { in flush_command()
482 if (opt->got_power_save) { in flush_command()
488 if (opt->got_power_on) { in flush_command()
494 if (opt->got_detach_kernel_driver) { in flush_command()
495 if (libusb20_dev_detach_kernel_driver(pdev, opt->iface)) { in flush_command()
500 (opt->got_dump_all_desc || in flush_command()
501 opt->got_dump_device_desc || in flush_command()
502 opt->got_dump_curr_config || in flush_command()
503 opt->got_dump_all_config || in flush_command()
504 opt->got_dump_info || in flush_command()
505 opt->got_dump_stats); in flush_command()
507 if (opt->got_list || dump_any) { in flush_command()
509 opt->got_show_iface_driver, in flush_command()
510 opt->opt_dump_in_list_mode && opt->got_dump_device_desc); in flush_command()
512 if (opt->got_dump_device_desc) { in flush_command()
513 if (!opt->opt_dump_in_list_mode) in flush_command()
515 dump_device_desc(pdev, opt->opt_dump_in_list_mode); in flush_command()
517 if (opt->got_dump_all_config) { in flush_command()
520 } else if (opt->got_dump_curr_config) { in flush_command()
523 } else if (opt->got_dump_all_desc) { in flush_command()
528 if (opt->got_dump_stats) { in flush_command()
532 if (dump_any && !opt->opt_dump_in_list_mode) { in flush_command()
544 reset_options(opt); in flush_command()
551 struct options *opt = &options; in main() local
569 opt->addr = num_id(optarg, "addr"); in main()
570 opt->got_addr = 1; in main()
589 opt->bus = unit; in main()
590 opt->addr = addr; in main()
591 opt->got_bus = 1; in main()
592 opt->got_addr = 1; in main()
600 opt->iface = num_id(optarg, "iface"); in main()
604 opt->opt_dump_in_list_mode = 1; in main()
608 opt->bus = num_id(optarg, "busnum"); in main()
609 opt->got_bus = 1; in main()
613 opt->got_dump_device_desc = 1; in main()
614 opt->got_dump_curr_config = 1; in main()
615 opt->got_show_iface_driver = 1; in main()
616 opt->got_any += 2; /* only the dump options count */ in main()
634 if (opt->got_add_quirk) { in main()
635 flush_command(pbe, opt); in main()
637 opt->quirkname = argv[n + 1]; in main()
640 opt->got_add_quirk = 1; in main()
641 opt->got_any++; in main()
645 if (opt->got_remove_quirk) { in main()
646 flush_command(pbe, opt); in main()
648 opt->quirkname = argv[n + 1]; in main()
651 opt->got_remove_quirk = 1; in main()
652 opt->got_any++; in main()
656 if (opt->got_add_device_quirk) { in main()
657 flush_command(pbe, opt); in main()
659 opt->vid = num_id(argv[n + 1], "Vendor ID"); in main()
660 opt->pid = num_id(argv[n + 2], "Product ID"); in main()
661 opt->lo_rev = num_id(argv[n + 3], "Low Revision"); in main()
662 opt->hi_rev = num_id(argv[n + 4], "High Revision"); in main()
663 opt->quirkname = argv[n + 5]; in main()
666 opt->got_add_device_quirk = 1; in main()
667 opt->got_any++; in main()
671 if (opt->got_remove_device_quirk) { in main()
672 flush_command(pbe, opt); in main()
674 opt->vid = num_id(argv[n + 1], "Vendor ID"); in main()
675 opt->pid = num_id(argv[n + 2], "Product ID"); in main()
676 opt->lo_rev = num_id(argv[n + 3], "Low Revision"); in main()
677 opt->hi_rev = num_id(argv[n + 4], "High Revision"); in main()
678 opt->quirkname = argv[n + 5]; in main()
680 opt->got_remove_device_quirk = 1; in main()
681 opt->got_any++; in main()
685 if (opt->got_detach_kernel_driver) in main()
687 opt->got_detach_kernel_driver = 1; in main()
688 opt->got_any++; in main()
692 if (opt->got_dump_quirk_names) in main()
694 opt->got_dump_quirk_names = 1; in main()
695 opt->got_any++; in main()
699 if (opt->got_dump_device_quirks) in main()
701 opt->got_dump_device_quirks = 1; in main()
702 opt->got_any++; in main()
706 opt->got_show_iface_driver = 1; in main()
710 if (opt->got_set_config) in main()
712 opt->config_index = num_id(argv[n + 1], "cfg_index"); in main()
713 opt->got_set_config = 1; in main()
714 opt->got_any++; in main()
718 if (opt->got_set_alt) in main()
720 opt->alt_index = num_id(argv[n + 1], "cfg_index"); in main()
721 opt->got_set_alt = 1; in main()
722 opt->got_any++; in main()
726 if (opt->got_set_template) in main()
728 opt->template = get_int(argv[n + 1]); in main()
729 opt->got_set_template = 1; in main()
730 opt->got_any++; in main()
734 if (opt->got_get_template) in main()
736 opt->got_get_template = 1; in main()
737 opt->got_any++; in main()
740 if (opt->got_dump_all_desc) in main()
742 opt->got_dump_all_desc = 1; in main()
743 opt->got_any++; in main()
746 if (opt->got_dump_device_desc) in main()
748 opt->got_dump_device_desc = 1; in main()
749 opt->got_any++; in main()
752 if (opt->got_dump_curr_config) in main()
754 opt->got_dump_curr_config = 1; in main()
755 opt->got_any++; in main()
758 if (opt->got_dump_all_config) in main()
760 opt->got_dump_all_config = 1; in main()
761 opt->got_any++; in main()
764 if (opt->got_dump_info) in main()
766 opt->got_dump_info = 1; in main()
767 opt->got_any++; in main()
770 if (opt->got_dump_stats) in main()
772 opt->got_dump_stats = 1; in main()
773 opt->got_any++; in main()
776 if (opt->got_dump_string) in main()
778 opt->string_index = num_id(argv[n + 1], "str_index"); in main()
779 opt->got_dump_string = 1; in main()
780 opt->got_any++; in main()
784 if (opt->got_suspend) in main()
786 opt->got_suspend = 1; in main()
787 opt->got_any++; in main()
790 if (opt->got_resume) in main()
792 opt->got_resume = 1; in main()
793 opt->got_any++; in main()
796 if (opt->got_power_off) in main()
798 opt->got_power_off = 1; in main()
799 opt->got_any++; in main()
802 if (opt->got_power_save) in main()
804 opt->got_power_save = 1; in main()
805 opt->got_any++; in main()
808 if (opt->got_power_on) in main()
810 opt->got_power_on = 1; in main()
811 opt->got_any++; in main()
814 if (opt->got_reset) in main()
816 opt->got_reset = 1; in main()
817 opt->got_any++; in main()
820 if (opt->got_list) in main()
822 opt->got_list = 1; in main()
823 opt->got_any++; in main()
826 if (opt->got_do_request) in main()
828 LIBUSB20_INIT(LIBUSB20_CONTROL_SETUP, &opt->setup); in main()
829 opt->setup.bmRequestType = num_id(argv[n + 1], "bmReqTyp"); in main()
830 opt->setup.bRequest = num_id(argv[n + 2], "bReq"); in main()
831 opt->setup.wValue = num_id(argv[n + 3], "wVal"); in main()
832 opt->setup.wIndex = num_id(argv[n + 4], "wIndex"); in main()
833 opt->setup.wLength = num_id(argv[n + 5], "wLen"); in main()
834 if (opt->setup.wLength != 0) { in main()
835 opt->buffer = malloc(opt->setup.wLength); in main()
837 opt->buffer = NULL; in main()
842 if (!(opt->setup.bmRequestType & in main()
846 if (t < opt->setup.wLength) { in main()
849 t = opt->setup.wLength; in main()
851 ((uint8_t *)opt->buffer)[t] = in main()
854 n += opt->setup.wLength; in main()
856 opt->got_do_request = 1; in main()
857 opt->got_any++; in main()
877 opt->bus = unit; in main()
878 opt->addr = addr; in main()
879 opt->got_bus = 1; in main()
880 opt->got_addr = 1; in main()
887 if (opt->got_any) { in main()
889 flush_command(pbe, opt); in main()
892 opt->got_list = 1; in main()
893 opt->got_any++; in main()
894 flush_command(pbe, opt); in main()