Ignore:
File:
1 edited

Legend:

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

    r361fcec r4125b7d  
    7373
    7474
     75/// \TODO malloc checking
     76
    7577//*********************************************
    7678//
     
    103105        }
    104106
     107        //usb_pipe_start_session(hub_info->control_pipe);
    105108        //set hub configuration
    106109        opResult = usb_hub_set_configuration(hub_info);
     
    119122                return opResult;
    120123        }
     124        //usb_pipe_end_session(hub_info->control_pipe);
     125
    121126
    122127        usb_log_debug("Creating 'hub' function in DDF.\n");
     
    171176leave:
    172177        /* FIXME: proper interval. */
    173         async_usleep(1000 * 250);
     178        async_usleep(1000 * 1000 * 10);
    174179
    175180        return true;
     
    213218        // get hub descriptor
    214219        usb_log_debug("creating serialized descriptor\n");
     220        //void * serialized_descriptor = malloc(USB_HUB_MAX_DESCRIPTOR_SIZE);
    215221        uint8_t serialized_descriptor[USB_HUB_MAX_DESCRIPTOR_SIZE];
    216222        usb_hub_descriptor_t * descriptor;
     
    246252        hub_info->ports = malloc(
    247253            sizeof (usb_hub_port_t) * (hub_info->port_count + 1));
    248         if(!hub_info->ports){
    249                 return ENOMEM;
    250         }
    251254        size_t port;
    252         for (port = 0; port < hub_info->port_count + 1; ++port) {
     255        for (port = 0; port < hub_info->port_count + 1; port++) {
    253256                usb_hub_port_init(&hub_info->ports[port]);
    254257        }
    255258        if(is_power_switched){
    256259                usb_log_debug("is_power_switched\n");
    257                
    258                 if(!has_individual_port_powering){
     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{
    259271                        usb_log_debug("!has_individual_port_powering\n");
    260272                        opResult = usb_hub_set_feature(hub_info->control_pipe,
     
    265277                        }
    266278                }
    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                
    278279        }else{
    279                 usb_log_debug("!is_power_switched, not going to be powered\n");
     280                usb_log_debug("!is_power_switched\n");
    280281        }
    281282        usb_log_debug2("freeing data\n");
     283        //free(serialized_descriptor);
     284        //free(descriptor->devices_removable);
    282285        free(descriptor);
    283286        return EOK;
     
    412415    usb_hub_status_t status) {
    413416        int opResult;
    414         if (!usb_hub_is_status(status,USB_HUB_FEATURE_HUB_LOCAL_POWER)) {
     417        if (usb_hub_is_status(status,USB_HUB_FEATURE_HUB_LOCAL_POWER)) {
    415418                //restart power on hub
    416419                opResult = usb_hub_set_feature(hub_info->control_pipe,
     
    422425        } else {//power reestablished on hub- restart ports
    423426                size_t port;
    424                 for (port = 1; port <= hub_info->port_count; ++port) {
     427                for (port = 0; port < hub_info->port_count; ++port) {
    425428                        opResult = usb_hub_set_port_feature(
    426429                            hub_info->control_pipe,
     
    431434                        }
    432435                }
    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                 }
    440436        }
    441437        return opResult;
Note: See TracChangeset for help on using the changeset viewer.