Ignore:
File:
1 edited

Legend:

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

    r4125b7d r361fcec  
    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;
     
    415412    usb_hub_status_t status) {
    416413        int opResult;
    417         if (usb_hub_is_status(status,USB_HUB_FEATURE_HUB_LOCAL_POWER)) {
     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,
     
    434431                        }
    435432                }
     433                opResult = usb_hub_clear_feature(hub_info->control_pipe,
     434                    USB_HUB_FEATURE_C_HUB_LOCAL_POWER);
     435                if (opResult != EOK) {
     436                        usb_log_error("cannnot clear hub power change flag: "
     437                            "%d\n",
     438                            opResult);
     439                }
    436440        }
    437441        return opResult;
Note: See TracChangeset for help on using the changeset viewer.