Changeset 1537ba6 in mainline for uspace/app/usbinfo/info.c
- Timestamp:
- 2011-02-02T10:19:13Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 93f8da1
- Parents:
- 0b31409 (diff), b00849e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/usbinfo/info.c
r0b31409 r1537ba6 38 38 #include <errno.h> 39 39 #include <usb/usbdrv.h> 40 #include <usb/pipes.h> 41 #include <usb/request.h> 40 42 #include "usbinfo.h" 41 43 42 int dump_device( int hc_phone, usb_address_t address)44 int dump_device(devman_handle_t hc_handle, usb_address_t address) 43 45 { 46 int rc; 47 usb_device_connection_t wire; 48 usb_endpoint_pipe_t ctrl_pipe; 49 ctrl_pipe.hc_phone = -1; 50 51 int hc_phone = devman_device_connect(hc_handle, 0); 52 if (hc_phone < 0) { 53 fprintf(stderr, 54 NAME ": failed to connect to host controller (%zu): %s.\n", 55 (size_t) hc_handle, str_error(hc_phone)); 56 return hc_phone; 57 } 58 44 59 /* 45 60 * Dump information about possible match ids. … … 47 62 match_id_list_t match_id_list; 48 63 init_match_ids(&match_id_list); 49 intrc = usb_drv_create_device_match_ids(hc_phone, &match_id_list, address);64 rc = usb_drv_create_device_match_ids(hc_phone, &match_id_list, address); 50 65 if (rc != EOK) { 51 66 fprintf(stderr, 52 67 NAME ": failed to fetch match ids of the device: %s.\n", 53 68 str_error(rc)); 54 return rc;69 goto leave; 55 70 } 56 71 dump_match_ids(&match_id_list); 72 73 /* 74 * Initialize pipes. 75 */ 76 rc = usb_device_connection_initialize(&wire, hc_handle, address); 77 if (rc != EOK) { 78 fprintf(stderr, 79 NAME ": failed to create connection to the device: %s.\n", 80 str_error(rc)); 81 goto leave; 82 } 83 rc = usb_endpoint_pipe_initialize_default_control(&ctrl_pipe, &wire); 84 if (rc != EOK) { 85 fprintf(stderr, 86 NAME ": failed to create default control pipe: %s.\n", 87 str_error(rc)); 88 goto leave; 89 } 90 rc = usb_endpoint_pipe_start_session(&ctrl_pipe); 91 if (rc != EOK) { 92 fprintf(stderr, 93 NAME ": failed to start session on control pipe: %s.\n", 94 str_error(rc)); 95 goto leave; 96 } 57 97 58 98 /* … … 60 100 */ 61 101 usb_standard_device_descriptor_t device_descriptor; 62 usb_dprintf(NAME, 1, 63 "usb_drv_req_get_device_descriptor(%d, %d, %p)\n", 64 hc_phone, (int) address, &device_descriptor); 65 66 rc = usb_drv_req_get_device_descriptor(hc_phone, address, 67 &device_descriptor); 102 rc = usb_request_get_device_descriptor(&ctrl_pipe, &device_descriptor); 68 103 if (rc != EOK) { 69 104 fprintf(stderr, 70 105 NAME ": failed to fetch standard device descriptor: %s.\n", 71 106 str_error(rc)); 72 return rc;107 goto leave; 73 108 } 74 109 dump_usb_descriptor((uint8_t *)&device_descriptor, sizeof(device_descriptor)); … … 79 114 usb_standard_configuration_descriptor_t config_descriptor; 80 115 int config_index = 0; 81 usb_dprintf(NAME, 1, 82 "usb_drv_req_get_bare_configuration_descriptor(%d, %d, %d, %p)\n", 83 hc_phone, (int) address, config_index, &config_descriptor); 84 85 rc = usb_drv_req_get_bare_configuration_descriptor(hc_phone, address, 86 config_index, &config_descriptor ); 116 rc = usb_request_get_bare_configuration_descriptor(&ctrl_pipe, 117 config_index, &config_descriptor); 87 118 if (rc != EOK) { 88 119 fprintf(stderr, 89 120 NAME ": failed to fetch standard configuration descriptor: %s.\n", 90 121 str_error(rc)); 91 return rc;122 goto leave; 92 123 } 93 124 //dump_standard_configuration_descriptor(config_index, &config_descriptor); 94 125 95 126 void *full_config_descriptor = malloc(config_descriptor.total_length); 96 usb_dprintf(NAME, 1, 97 "usb_drv_req_get_full_configuration_descriptor(%d, %d, %d, %p, %zu)\n", 98 hc_phone, (int) address, config_index, 99 full_config_descriptor, config_descriptor.total_length); 100 101 rc = usb_drv_req_get_full_configuration_descriptor(hc_phone, address, 127 rc = usb_request_get_full_configuration_descriptor(&ctrl_pipe, 102 128 config_index, 103 129 full_config_descriptor, config_descriptor.total_length, NULL); … … 106 132 NAME ": failed to fetch full configuration descriptor: %s.\n", 107 133 str_error(rc)); 108 return rc;134 goto leave; 109 135 } 110 136 … … 112 138 config_descriptor.total_length); 113 139 114 return EOK; 140 rc = EOK; 141 leave: 142 /* Ignoring errors here. */ 143 ipc_hangup(hc_phone); 144 usb_endpoint_pipe_end_session(&ctrl_pipe); 145 146 return rc; 115 147 } 116 148
Note:
See TracChangeset
for help on using the changeset viewer.