Changes in uspace/drv/usbhub/usbhub.c [49ce810:7d521e24] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/usbhub.c
r49ce810 r7d521e24 67 67 usb_hub_status_t status); 68 68 69 static int usb_process_hub_ local_power_change(usb_hub_info_t * hub_info,69 static int usb_process_hub_power_change(usb_hub_info_t * hub_info, 70 70 usb_hub_status_t status); 71 71 … … 336 336 */ 337 337 static int usb_hub_start_hub_fibril(usb_hub_info_t * hub_info){ 338 int rc; 338 /* 339 * The processing will require opened control pipe and connection 340 * to the host controller. 341 * It is waste of resources but let's hope there will be less 342 * hubs than the phone limit. 343 * FIXME: with some proper locking over pipes and session 344 * auto destruction, this could work better. 345 */ 346 int rc = usb_hc_connection_open(&hub_info->connection); 347 if (rc != EOK) { 348 //usb_pipe_end_session(hub_info->control_pipe); 349 usb_log_error("Failed to open connection to HC: %s.\n", 350 str_error(rc)); 351 return rc; 352 } 339 353 340 354 rc = usb_device_auto_poll(hub_info->usb_device, 0, … … 372 386 int opResult; 373 387 if (usb_hub_is_status(status,USB_HUB_FEATURE_HUB_OVER_CURRENT)){ 374 //poweroff all ports 375 unsigned int port; 376 for(port = 1;port <= hub_info->port_count;++port){ 377 opResult = usb_hub_clear_port_feature( 378 hub_info->control_pipe,port, 379 USB_HUB_FEATURE_PORT_POWER); 380 if (opResult != EOK) { 381 usb_log_warning( 382 "cannot power off port %d; %d\n", 383 port, opResult); 384 } 388 opResult = usb_hub_clear_feature(hub_info->control_pipe, 389 USB_HUB_FEATURE_HUB_LOCAL_POWER); 390 if (opResult != EOK) { 391 usb_log_error("cannot power off hub: %d\n", 392 opResult); 385 393 } 386 394 } else { 387 //power all ports 388 unsigned int port; 389 for(port = 1;port <= hub_info->port_count;++port){ 390 opResult = usb_hub_set_port_feature( 391 hub_info->control_pipe,port, 392 USB_HUB_FEATURE_PORT_POWER); 393 if (opResult != EOK) { 394 usb_log_warning( 395 "cannot power off port %d; %d\n", 396 port, opResult); 397 } 395 opResult = usb_hub_set_feature(hub_info->control_pipe, 396 USB_HUB_FEATURE_HUB_LOCAL_POWER); 397 if (opResult != EOK) { 398 usb_log_error("cannot power on hub: %d\n", 399 opResult); 398 400 } 399 401 } … … 402 404 403 405 /** 404 * process hub local power change 405 * 406 * This change is ignored. 406 * process hub power change 407 * 408 * If the power has been lost, reestablish it. 409 * If it was reestablished, re-power all ports. 407 410 * @param hub_info hub instance 408 411 * @param status hub status bitmask 409 412 * @return error code 410 413 */ 411 static int usb_process_hub_ local_power_change(usb_hub_info_t * hub_info,414 static int usb_process_hub_power_change(usb_hub_info_t * hub_info, 412 415 usb_hub_status_t status) { 413 416 int opResult = EOK; 417 if (!usb_hub_is_status(status,USB_HUB_FEATURE_HUB_LOCAL_POWER)) { 418 //restart power on hub 419 opResult = usb_hub_set_feature(hub_info->control_pipe, 420 USB_HUB_FEATURE_HUB_LOCAL_POWER); 421 if (opResult != EOK) { 422 usb_log_error("cannot power on hub: %d\n", 423 opResult); 424 } 425 } else {//power reestablished on hub- restart ports 426 size_t port; 427 for (port = 1; port <= hub_info->port_count; ++port) { 428 opResult = usb_hub_set_port_feature( 429 hub_info->control_pipe, 430 port, USB_HUB_FEATURE_PORT_POWER); 431 if (opResult != EOK) { 432 usb_log_error("Cannot power on port %zu: %s.\n", 433 port, str_error(opResult)); 434 } 435 } 436 } 437 if(opResult!=EOK){ 438 return opResult;//no feature clearing 439 } 414 440 opResult = usb_hub_clear_feature(hub_info->control_pipe, 415 441 USB_HUB_FEATURE_C_HUB_LOCAL_POWER); … … 426 452 * 427 453 * The change can be either in the over-current condition or 428 * local-power change.454 * local-power lost condition. 429 455 * @param hub_info hub instance 430 456 */ … … 461 487 if ( 462 488 usb_hub_is_status(status,16+USB_HUB_FEATURE_C_HUB_LOCAL_POWER)) { 463 usb_process_hub_ local_power_change(hub_info, status);489 usb_process_hub_power_change(hub_info, status); 464 490 } 465 491 }
Note:
See TracChangeset
for help on using the changeset viewer.