Changeset 400735e in mainline for uspace/drv/usbhub/usbhub.c
- Timestamp:
- 2011-05-28T14:30:58Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3fb5a3e
- Parents:
- e8f826b (diff), 48141f0 (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
re8f826b r400735e 67 67 usb_hub_status_t status); 68 68 69 static int usb_process_hub_ power_change(usb_hub_info_t * hub_info,69 static int usb_process_hub_local_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 /* 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 } 338 int rc; 353 339 354 340 rc = usb_device_auto_poll(hub_info->usb_device, 0, … … 386 372 int opResult; 387 373 if (usb_hub_is_status(status,USB_HUB_FEATURE_HUB_OVER_CURRENT)){ 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); 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 } 393 385 } 394 386 } else { 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); 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 } 400 398 } 401 399 } … … 404 402 405 403 /** 406 * process hub power change 407 * 408 * If the power has been lost, reestablish it. 409 * If it was reestablished, re-power all ports. 404 * process hub local power change 405 * 406 * This change is ignored. 410 407 * @param hub_info hub instance 411 408 * @param status hub status bitmask 412 409 * @return error code 413 410 */ 414 static int usb_process_hub_ power_change(usb_hub_info_t * hub_info,411 static int usb_process_hub_local_power_change(usb_hub_info_t * hub_info, 415 412 usb_hub_status_t status) { 416 413 int opResult = EOK; 417 if (!usb_hub_is_status(status,USB_HUB_FEATURE_HUB_LOCAL_POWER)) {418 //restart power on hub419 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 ports426 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 clearing439 }440 414 opResult = usb_hub_clear_feature(hub_info->control_pipe, 441 415 USB_HUB_FEATURE_C_HUB_LOCAL_POWER); … … 452 426 * 453 427 * The change can be either in the over-current condition or 454 * local-power lost condition.428 * local-power change. 455 429 * @param hub_info hub instance 456 430 */ … … 487 461 if ( 488 462 usb_hub_is_status(status,16+USB_HUB_FEATURE_C_HUB_LOCAL_POWER)) { 489 usb_process_hub_ power_change(hub_info, status);463 usb_process_hub_local_power_change(hub_info, status); 490 464 } 491 465 }
Note:
See TracChangeset
for help on using the changeset viewer.