Changes in uspace/drv/usbhub/usbhub.c [4e900c1:ad4562c2] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/usbhub.c
r4e900c1 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) { … … 233 252 dprintf(USB_LOG_LEVEL_DEBUG, "starting control transaction"); 234 253 usb_endpoint_pipe_start_session(&result->endpoints.control); 235 opResult = usb_request_set_configuration(&result->endpoints.control, 1);236 assert(opResult == EOK);237 238 254 opResult = usb_request_get_descriptor(&result->endpoints.control, 239 255 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_DEVICE, … … 246 262 dprintf(USB_LOG_LEVEL_ERROR, "failed when receiving hub descriptor, badcode = %d",opResult); 247 263 free(serialized_descriptor); 248 free(result); 249 return NULL; 264 return result; 250 265 } 251 266 dprintf(USB_LOG_LEVEL_DEBUG2, "deserializing descriptor"); … … 253 268 if(descriptor==NULL){ 254 269 dprintf(USB_LOG_LEVEL_WARNING, "could not deserialize descriptor "); 255 free(result);256 return NULL;270 result->port_count = 1;///\TODO this code is only for debug!!! 271 return result; 257 272 } 258 273 … … 290 305 291 306 usb_hub_info_t * hub_info = usb_create_hub_info(dev); 292 if(!hub_info){293 return EINTR;294 }295 307 296 308 int opResult; … … 301 313 opResult = usb_hub_process_configuration_descriptors(hub_info); 302 314 if(opResult != EOK){ 303 dprintf(USB_LOG_LEVEL_ERROR,"could not get con figuration descriptors, %d",315 dprintf(USB_LOG_LEVEL_ERROR,"could not get condiguration descriptors, %d", 304 316 opResult); 305 317 return opResult;
Note:
See TracChangeset
for help on using the changeset viewer.