Lines Matching refs:opt

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