Changes in uspace/drv/usbhub/usbhub.c [4125b7d:361fcec] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/usbhub.c
r4125b7d r361fcec 73 73 74 74 75 /// \TODO malloc checking76 77 75 //********************************************* 78 76 // … … 105 103 } 106 104 107 //usb_pipe_start_session(hub_info->control_pipe);108 105 //set hub configuration 109 106 opResult = usb_hub_set_configuration(hub_info); … … 122 119 return opResult; 123 120 } 124 //usb_pipe_end_session(hub_info->control_pipe);125 126 121 127 122 usb_log_debug("Creating 'hub' function in DDF.\n"); … … 176 171 leave: 177 172 /* FIXME: proper interval. */ 178 async_usleep(1000 * 1000 * 10);173 async_usleep(1000 * 250); 179 174 180 175 return true; … … 218 213 // get hub descriptor 219 214 usb_log_debug("creating serialized descriptor\n"); 220 //void * serialized_descriptor = malloc(USB_HUB_MAX_DESCRIPTOR_SIZE);221 215 uint8_t serialized_descriptor[USB_HUB_MAX_DESCRIPTOR_SIZE]; 222 216 usb_hub_descriptor_t * descriptor; … … 252 246 hub_info->ports = malloc( 253 247 sizeof (usb_hub_port_t) * (hub_info->port_count + 1)); 248 if(!hub_info->ports){ 249 return ENOMEM; 250 } 254 251 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) { 256 253 usb_hub_port_init(&hub_info->ports[port]); 257 254 } 258 255 if(is_power_switched){ 259 256 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){ 271 259 usb_log_debug("!has_individual_port_powering\n"); 272 260 opResult = usb_hub_set_feature(hub_info->control_pipe, … … 277 265 } 278 266 } 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 279 278 }else{ 280 usb_log_debug("!is_power_switched \n");279 usb_log_debug("!is_power_switched, not going to be powered\n"); 281 280 } 282 281 usb_log_debug2("freeing data\n"); 283 //free(serialized_descriptor);284 //free(descriptor->devices_removable);285 282 free(descriptor); 286 283 return EOK; … … 415 412 usb_hub_status_t status) { 416 413 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)) { 418 415 //restart power on hub 419 416 opResult = usb_hub_set_feature(hub_info->control_pipe, … … 425 422 } else {//power reestablished on hub- restart ports 426 423 size_t port; 427 for (port = 0; port <hub_info->port_count; ++port) {424 for (port = 1; port <= hub_info->port_count; ++port) { 428 425 opResult = usb_hub_set_port_feature( 429 426 hub_info->control_pipe, … … 434 431 } 435 432 } 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 } 436 440 } 437 441 return opResult;
Note:
See TracChangeset
for help on using the changeset viewer.