Changeset 9d9ffdd in mainline for uspace/drv/usbhub/usbhub.c
- Timestamp:
- 2011-03-11T15:42:43Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0bd4810c
- Parents:
- 60a228f (diff), a8def7d (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/drv/usbhub/usbhub.c
r60a228f r9d9ffdd 149 149 } 150 150 151 / /configuration descriptor152 /// \TODO check other configurations?153 usb_standard_configuration_descriptor_t config_descriptor;154 opResult = usb_request_get_ bare_configuration_descriptor(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( 155 155 &hub->endpoints.control, 0, 156 &config_descriptor); 157 if(opResult!=EOK){ 158 dprintf(USB_LOG_LEVEL_ERROR, "could not get configuration descriptor, %d",opResult); 156 (void **) &descriptors, &descriptors_size); 157 if (opResult != EOK) { 158 usb_log_error("Could not get configuration descriptor: %s.\n", 159 str_error(opResult)); 159 160 return opResult; 160 161 } 161 //set configuration 162 usb_standard_configuration_descriptor_t *config_descriptor 163 = (usb_standard_configuration_descriptor_t *) descriptors; 164 165 /* Set configuration. */ 162 166 opResult = usb_request_set_configuration(&hub->endpoints.control, 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); 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)); 169 172 return opResult; 170 173 } 171 174 dprintf(USB_LOG_LEVEL_DEBUG, "\tused configuration %d", 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 } 175 config_descriptor->configuration_number); 195 176 196 177 usb_endpoint_mapping_t endpoint_mapping[1] = { … … 204 185 opResult = usb_endpoint_pipe_initialize_from_configuration( 205 186 endpoint_mapping, 1, 206 descriptors, config_descriptor.total_length,187 descriptors, descriptors_size, 207 188 &hub->device_connection); 208 189 if (opResult != EOK) { … … 252 233 dprintf(USB_LOG_LEVEL_DEBUG, "starting control transaction"); 253 234 usb_endpoint_pipe_start_session(&result->endpoints.control); 235 opResult = usb_request_set_configuration(&result->endpoints.control, 1); 236 assert(opResult == EOK); 237 254 238 opResult = usb_request_get_descriptor(&result->endpoints.control, 255 239 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_DEVICE, … … 262 246 dprintf(USB_LOG_LEVEL_ERROR, "failed when receiving hub descriptor, badcode = %d",opResult); 263 247 free(serialized_descriptor); 264 return result; 248 free(result); 249 return NULL; 265 250 } 266 251 dprintf(USB_LOG_LEVEL_DEBUG2, "deserializing descriptor"); … … 268 253 if(descriptor==NULL){ 269 254 dprintf(USB_LOG_LEVEL_WARNING, "could not deserialize descriptor "); 270 result->port_count = 1;///\TODO this code is only for debug!!!271 return result;255 free(result); 256 return NULL; 272 257 } 273 258 … … 305 290 306 291 usb_hub_info_t * hub_info = usb_create_hub_info(dev); 292 if(!hub_info){ 293 return EINTR; 294 } 307 295 308 296 int opResult; … … 313 301 opResult = usb_hub_process_configuration_descriptors(hub_info); 314 302 if(opResult != EOK){ 315 dprintf(USB_LOG_LEVEL_ERROR,"could not get con diguration descriptors, %d",303 dprintf(USB_LOG_LEVEL_ERROR,"could not get configuration descriptors, %d", 316 304 opResult); 317 305 return opResult;
Note:
See TracChangeset
for help on using the changeset viewer.