Changeset 30f9f8f in mainline for uspace/drv/usbhub/usbhub.c


Ignore:
Timestamp:
2011-05-06T09:29:03Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9a884ed
Parents:
c709eb0 (diff), 310c4df (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

    rc709eb0 r30f9f8f  
    7373
    7474
    75 /// \TODO malloc checking
    76 
    7775//*********************************************
    7876//
     
    105103        }
    106104
    107         //usb_pipe_start_session(hub_info->control_pipe);
    108105        //set hub configuration
    109106        opResult = usb_hub_set_configuration(hub_info);
     
    122119                return opResult;
    123120        }
    124         //usb_pipe_end_session(hub_info->control_pipe);
    125 
    126121
    127122        usb_log_debug("Creating 'hub' function in DDF.\n");
     
    176171leave:
    177172        /* FIXME: proper interval. */
    178         async_usleep(1000 * 1000 * 10);
     173        async_usleep(1000 * 250);
    179174
    180175        return true;
     
    218213        // get hub descriptor
    219214        usb_log_debug("creating serialized descriptor\n");
    220         //void * serialized_descriptor = malloc(USB_HUB_MAX_DESCRIPTOR_SIZE);
    221215        uint8_t serialized_descriptor[USB_HUB_MAX_DESCRIPTOR_SIZE];
    222216        usb_hub_descriptor_t * descriptor;
     
    252246        hub_info->ports = malloc(
    253247            sizeof (usb_hub_port_t) * (hub_info->port_count + 1));
     248        if(!hub_info->ports){
     249                return ENOMEM;
     250        }
    254251        size_t port;
    255         for (port = 0; port < hub_info->port_count + 1; port++) {
     252        for (port = 0; port < hub_info->port_count + 1; ++port) {
    256253                usb_hub_port_init(&hub_info->ports[port]);
    257254        }
    258255        if(is_power_switched){
    259256                usb_log_debug("is_power_switched\n");
    260                 if(has_individual_port_powering){
    261                         usb_log_debug("has_individual_port_powering\n");
    262                         for (port = 0; port < hub_info->port_count; port++) {
    263                                 opResult = usb_hub_set_port_feature(hub_info->control_pipe,
    264                                     port+1, USB_HUB_FEATURE_PORT_POWER);
    265                                 if (opResult != EOK) {
    266                                         usb_log_error("cannot power on port %zu: %s.\n",
    267                                             port+1, str_error(opResult));
    268                                 }
    269                         }
    270                 }else{
     257               
     258                if(!has_individual_port_powering){
    271259                        usb_log_debug("!has_individual_port_powering\n");
    272260                        opResult = usb_hub_set_feature(hub_info->control_pipe,
     
    277265                        }
    278266                }
     267
     268                for (port = 1; port <= hub_info->port_count; ++port) {
     269                        usb_log_debug("Powering port %zu.\n",port);
     270                        opResult = usb_hub_set_port_feature(hub_info->control_pipe,
     271                            port, USB_HUB_FEATURE_PORT_POWER);
     272                        if (opResult != EOK) {
     273                                usb_log_error("cannot power on port %zu: %s.\n",
     274                                    port, str_error(opResult));
     275                        }
     276                }
     277               
    279278        }else{
    280                 usb_log_debug("!is_power_switched\n");
     279                usb_log_debug("!is_power_switched, not going to be powered\n");
    281280        }
    282281        usb_log_debug2("freeing data\n");
    283         //free(serialized_descriptor);
    284         //free(descriptor->devices_removable);
    285282        free(descriptor);
    286283        return EOK;
     
    414411static int usb_process_hub_power_change(usb_hub_info_t * hub_info,
    415412    usb_hub_status_t status) {
    416         int opResult;
    417         if (usb_hub_is_status(status,USB_HUB_FEATURE_HUB_LOCAL_POWER)) {
     413        int opResult = EOK;
     414        if (!usb_hub_is_status(status,USB_HUB_FEATURE_HUB_LOCAL_POWER)) {
    418415                //restart power on hub
    419416                opResult = usb_hub_set_feature(hub_info->control_pipe,
     
    425422        } else {//power reestablished on hub- restart ports
    426423                size_t port;
    427                 for (port = 0; port < hub_info->port_count; ++port) {
     424                for (port = 1; port <= hub_info->port_count; ++port) {
    428425                        opResult = usb_hub_set_port_feature(
    429426                            hub_info->control_pipe,
     
    435432                }
    436433        }
     434        if(opResult!=EOK){
     435                return opResult;//no feature clearing
     436        }
     437        opResult = usb_hub_clear_feature(hub_info->control_pipe,
     438            USB_HUB_FEATURE_C_HUB_LOCAL_POWER);
     439                if (opResult != EOK) {
     440                usb_log_error("cannnot clear hub power change flag: "
     441                    "%d\n",
     442                    opResult);
     443        }
    437444        return opResult;
    438445}
Note: See TracChangeset for help on using the changeset viewer.