Changes in uspace/drv/usbhub/usbhub.c [625f1ba:09daa8b] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/usbhub.c
r625f1ba r09daa8b 157 157 static int usb_hub_set_configuration(usb_hub_info_t * hub_info){ 158 158 //device descriptor 159 usb_standard_device_descriptor_t *std_descriptor 160 = &hub_info->usb_device->descriptors.device; 159 usb_standard_device_descriptor_t std_descriptor; 160 int opResult = usb_request_get_device_descriptor( 161 &hub_info->usb_device->ctrl_pipe, 162 &std_descriptor); 163 if(opResult!=EOK){ 164 usb_log_error("could not get device descriptor, %d\n",opResult); 165 return opResult; 166 } 161 167 usb_log_info("hub has %d configurations\n", 162 std_descriptor->configuration_count);163 if(std_descriptor ->configuration_count<1){168 std_descriptor.configuration_count); 169 if(std_descriptor.configuration_count<1){ 164 170 usb_log_error("THERE ARE NO CONFIGURATIONS AVAILABLE\n"); 165 171 //shouldn`t I return? 166 //definitely 167 return EINVAL; 168 } 169 172 } 173 174 /* Retrieve full configuration descriptor. */ 175 uint8_t *descriptors = NULL; 176 size_t descriptors_size = 0; 177 opResult = usb_request_get_full_configuration_descriptor_alloc( 178 &hub_info->usb_device->ctrl_pipe, 0, 179 (void **) &descriptors, &descriptors_size); 180 if (opResult != EOK) { 181 usb_log_error("Could not get configuration descriptor: %s.\n", 182 str_error(opResult)); 183 return opResult; 184 } 170 185 usb_standard_configuration_descriptor_t *config_descriptor 171 = (usb_standard_configuration_descriptor_t *) 172 hub_info->usb_device->descriptors.configuration; 186 = (usb_standard_configuration_descriptor_t *) descriptors; 173 187 174 188 /* Set configuration. */ 175 int opResult = usb_request_set_configuration( 176 &hub_info->usb_device->ctrl_pipe, 189 opResult = usb_request_set_configuration(&hub_info->usb_device->ctrl_pipe, 177 190 config_descriptor->configuration_number); 178 191 … … 184 197 usb_log_debug("\tused configuration %d\n", 185 198 config_descriptor->configuration_number); 186 199 free(descriptors); 187 200 return EOK; 188 201 } … … 211 224 } 212 225 213 usb_ pipe_start_session(hub_info->control_pipe);226 usb_endpoint_pipe_start_session(hub_info->control_pipe); 214 227 //set hub configuration 215 228 opResult = usb_hub_set_configuration(hub_info); … … 226 239 return opResult; 227 240 } 228 usb_ pipe_end_session(hub_info->control_pipe);241 usb_endpoint_pipe_end_session(hub_info->control_pipe); 229 242 230 243 231 244 /// \TODO what is this? 232 usb_log_debug(" Creating `hub' function.\n");245 usb_log_debug("adding to ddf"); 233 246 ddf_fun_t *hub_fun = ddf_fun_create(hub_info->usb_device->ddf_dev, 234 247 fun_exposed, "hub"); … … 244 257 fid_t fid = fibril_create(usb_hub_control_loop, hub_info); 245 258 if (fid == 0) { 246 usb_log_error("failed to start monitoring fibril for new hub .\n");259 usb_log_error("failed to start monitoring fibril for new hub"); 247 260 return ENOMEM; 248 261 } 249 262 fibril_add_ready(fid); 250 usb_log_debug("Hub fibril created.\n"); 251 252 usb_log_info("Controlling hub `%s' (%d ports).\n", 253 hub_info->usb_device->ddf_dev->name, hub_info->port_count); 263 usb_log_debug("hub fibril created"); 264 usb_log_debug("has %d ports ",hub_info->port_count); 254 265 return EOK; 255 266 } … … 310 321 //reset port 311 322 usb_hub_set_reset_port_request(&request, port); 312 opResult = usb_ pipe_control_write(323 opResult = usb_endpoint_pipe_control_write( 313 324 hub->control_pipe, 314 325 &request,sizeof(usb_device_request_setup_packet_t), … … 343 354 } 344 355 //create connection to device 345 usb_ pipe_t new_device_pipe;356 usb_endpoint_pipe_t new_device_pipe; 346 357 usb_device_connection_t new_device_connection; 347 358 usb_device_connection_initialize_on_default_address( … … 349 360 &hub->connection 350 361 ); 351 usb_ pipe_initialize_default_control(362 usb_endpoint_pipe_initialize_default_control( 352 363 &new_device_pipe, 353 364 &new_device_connection); 354 usb_ pipe_probe_default_control(&new_device_pipe);365 usb_endpoint_pipe_probe_default_control(&new_device_pipe); 355 366 356 367 /* Request address from host controller. */ … … 368 379 //opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT, 369 380 // new_device_address); 370 usb_ pipe_start_session(&new_device_pipe);381 usb_endpoint_pipe_start_session(&new_device_pipe); 371 382 opResult = usb_request_set_address(&new_device_pipe,new_device_address); 372 usb_ pipe_end_session(&new_device_pipe);383 usb_endpoint_pipe_end_session(&new_device_pipe); 373 384 if (opResult != EOK) { 374 385 usb_log_error("could not set address for new device %d\n",opResult); … … 477 488 usb_log_debug("interrupt at port %d\n", port); 478 489 //determine type of change 479 usb_ pipe_t *pipe = hub->control_pipe;490 usb_endpoint_pipe_t *pipe = hub->control_pipe; 480 491 481 492 int opResult; … … 488 499 //endpoint 0 489 500 490 opResult = usb_ pipe_control_read(501 opResult = usb_endpoint_pipe_control_read( 491 502 pipe, 492 503 &request, sizeof(usb_device_request_setup_packet_t), … … 522 533 //port reset 523 534 if (usb_port_reset_completed(&status)) { 524 usb_log_info("port reset complete \n");535 usb_log_info("port reset complete"); 525 536 if (usb_port_enabled(&status)) { 526 537 usb_hub_finalize_add_device(hub, port, usb_port_speed(&status)); … … 549 560 int usb_hub_check_hub_changes(usb_hub_info_t * hub_info){ 550 561 int opResult; 551 opResult = usb_ pipe_start_session(562 opResult = usb_endpoint_pipe_start_session( 552 563 hub_info->status_change_pipe); 553 564 if(opResult != EOK){ … … 567 578 * Send the request. 568 579 */ 569 opResult = usb_ pipe_read(580 opResult = usb_endpoint_pipe_read( 570 581 hub_info->status_change_pipe, 571 582 change_bitmap, byte_length, &actual_size … … 575 586 free(change_bitmap); 576 587 usb_log_warning("something went wrong while getting status of hub\n"); 577 usb_ pipe_end_session(hub_info->status_change_pipe);588 usb_endpoint_pipe_end_session(hub_info->status_change_pipe); 578 589 return opResult; 579 590 } 580 591 unsigned int port; 581 opResult = usb_ pipe_start_session(hub_info->control_pipe);592 opResult = usb_endpoint_pipe_start_session(hub_info->control_pipe); 582 593 if(opResult!=EOK){ 583 594 usb_log_error("could not start control pipe session %d\n", opResult); 584 usb_ pipe_end_session(hub_info->status_change_pipe);595 usb_endpoint_pipe_end_session(hub_info->status_change_pipe); 585 596 return opResult; 586 597 } … … 589 600 usb_log_error("could not start host controller session %d\n", 590 601 opResult); 591 usb_ pipe_end_session(hub_info->control_pipe);592 usb_ pipe_end_session(hub_info->status_change_pipe);602 usb_endpoint_pipe_end_session(hub_info->control_pipe); 603 usb_endpoint_pipe_end_session(hub_info->status_change_pipe); 593 604 return opResult; 594 605 } … … 604 615 } 605 616 usb_hc_connection_close(&hub_info->connection); 606 usb_ pipe_end_session(hub_info->control_pipe);607 usb_ pipe_end_session(hub_info->status_change_pipe);617 usb_endpoint_pipe_end_session(hub_info->control_pipe); 618 usb_endpoint_pipe_end_session(hub_info->status_change_pipe); 608 619 free(change_bitmap); 609 620 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.