Changes in uspace/drv/usbhub/usbhub.c [d70e0a3c:ad4562c2] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/usbhub.c
rd70e0a3c rad4562c2 149 149 } 150 150 151 / * Retrieve full configuration descriptor. */152 uint8_t *descriptors = NULL;153 size_t descriptors_size = 0;154 opResult = usb_request_get_ full_configuration_descriptor_alloc(151 //configuration descriptor 152 /// \TODO check other configurations? 153 usb_standard_configuration_descriptor_t config_descriptor; 154 opResult = usb_request_get_bare_configuration_descriptor( 155 155 &hub->endpoints.control, 0, 156 (void **) &descriptors, &descriptors_size); 157 if (opResult != EOK) { 158 usb_log_error("Could not get configuration descriptor: %s.\n", 159 str_error(opResult)); 156 &config_descriptor); 157 if(opResult!=EOK){ 158 dprintf(USB_LOG_LEVEL_ERROR, "could not get configuration descriptor, %d",opResult); 160 159 return opResult; 161 160 } 162 usb_standard_configuration_descriptor_t *config_descriptor 163 = (usb_standard_configuration_descriptor_t *) descriptors; 164 165 /* Set configuration. */ 161 //set configuration 166 162 opResult = usb_request_set_configuration(&hub->endpoints.control, 167 config_descriptor->configuration_number); 168 169 if (opResult != EOK) { 170 usb_log_error("Failed to set hub configuration: %s.\n", 171 str_error(opResult)); 163 config_descriptor.configuration_number); 164 165 if (opResult != EOK) { 166 dprintf(USB_LOG_LEVEL_ERROR, 167 "something went wrong when setting hub`s configuration, %d", 168 opResult); 172 169 return opResult; 173 170 } 174 171 dprintf(USB_LOG_LEVEL_DEBUG, "\tused configuration %d", 175 config_descriptor->configuration_number); 172 config_descriptor.configuration_number); 173 174 //full configuration descriptor 175 size_t transferred = 0; 176 uint8_t * descriptors = (uint8_t *)malloc(config_descriptor.total_length); 177 if (descriptors == NULL) { 178 dprintf(USB_LOG_LEVEL_ERROR, "insufficient memory"); 179 return ENOMEM; 180 } 181 opResult = usb_request_get_full_configuration_descriptor(&hub->endpoints.control, 182 0, descriptors, 183 config_descriptor.total_length, &transferred); 184 if(opResult!=EOK){ 185 free(descriptors); 186 dprintf(USB_LOG_LEVEL_ERROR, 187 "could not get full configuration descriptor, %d",opResult); 188 return opResult; 189 } 190 if (transferred != config_descriptor.total_length) { 191 dprintf(USB_LOG_LEVEL_ERROR, 192 "received incorrect full configuration descriptor"); 193 return ELIMIT; 194 } 176 195 177 196 usb_endpoint_mapping_t endpoint_mapping[1] = { … … 185 204 opResult = usb_endpoint_pipe_initialize_from_configuration( 186 205 endpoint_mapping, 1, 187 descriptors, descriptors_size,206 descriptors, config_descriptor.total_length, 188 207 &hub->device_connection); 189 208 if (opResult != EOK) {
Note:
See TracChangeset
for help on using the changeset viewer.