Changeset 400735e in mainline for uspace/drv/usbhub/usbhub.c


Ignore:
Timestamp:
2011-05-28T14:30:58Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
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.
Message:

Merge development/ changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhub/usbhub.c

    re8f826b r400735e  
    6767    usb_hub_status_t status);
    6868
    69 static int usb_process_hub_power_change(usb_hub_info_t * hub_info,
     69static int usb_process_hub_local_power_change(usb_hub_info_t * hub_info,
    7070    usb_hub_status_t status);
    7171
     
    336336 */
    337337static 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;
    353339
    354340        rc = usb_device_auto_poll(hub_info->usb_device, 0,
     
    386372        int opResult;
    387373        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                        }
    393385                }
    394386        } 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                        }
    400398                }
    401399        }
     
    404402
    405403/**
    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.
    410407 * @param hub_info hub instance
    411408 * @param status hub status bitmask
    412409 * @return error code
    413410 */
    414 static int usb_process_hub_power_change(usb_hub_info_t * hub_info,
     411static int usb_process_hub_local_power_change(usb_hub_info_t * hub_info,
    415412    usb_hub_status_t status) {
    416413        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         }
    440414        opResult = usb_hub_clear_feature(hub_info->control_pipe,
    441415            USB_HUB_FEATURE_C_HUB_LOCAL_POWER);
     
    452426 *
    453427 * The change can be either in the over-current condition or
    454  * local-power lost condition.
     428 * local-power change.
    455429 * @param hub_info hub instance
    456430 */
     
    487461        if (
    488462            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);
    490464        }
    491465}
Note: See TracChangeset for help on using the changeset viewer.