Changes in uspace/drv/usbhub/usbhub.c [4125b7d:5e07e2b5] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/usbhub.c
r4125b7d r5e07e2b5 105 105 } 106 106 107 //usb_pipe_start_session(hub_info->control_pipe);107 usb_pipe_start_session(hub_info->control_pipe); 108 108 //set hub configuration 109 109 opResult = usb_hub_set_configuration(hub_info); … … 122 122 return opResult; 123 123 } 124 //usb_pipe_end_session(hub_info->control_pipe);125 126 127 usb_log_debug("Creating 'hub' function in DDF.\n");124 usb_pipe_end_session(hub_info->control_pipe); 125 126 /// \TODO what is this? 127 usb_log_debug("Creating `hub' function.\n"); 128 128 ddf_fun_t *hub_fun = ddf_fun_create(hub_info->usb_device->ddf_dev, 129 129 fun_exposed, "hub"); … … 153 153 bool hub_port_changes_callback(usb_device_t *dev, 154 154 uint8_t *change_bitmap, size_t change_bitmap_size, void *arg) { 155 usb_log_debug("hub_port_changes_callback\n");156 155 usb_hub_info_t *hub = (usb_hub_info_t *) arg; 157 156 … … 218 217 // get hub descriptor 219 218 usb_log_debug("creating serialized descriptor\n"); 220 //void * serialized_descriptor = malloc(USB_HUB_MAX_DESCRIPTOR_SIZE); 221 uint8_t serialized_descriptor[USB_HUB_MAX_DESCRIPTOR_SIZE]; 219 void * serialized_descriptor = malloc(USB_HUB_MAX_DESCRIPTOR_SIZE); 222 220 usb_hub_descriptor_t * descriptor; 223 221 int opResult; … … 237 235 } 238 236 usb_log_debug2("deserializing descriptor\n"); 239 descriptor = usb_create_deserialized_hub_desriptor( 240 serialized_descriptor); 237 descriptor = usb_deserialize_hub_desriptor(serialized_descriptor); 241 238 if (descriptor == NULL) { 242 239 usb_log_warning("could not deserialize descriptor \n"); 243 return ENOMEM;240 return opResult; 244 241 } 245 242 usb_log_debug("setting port count to %d\n", descriptor->ports_count); 246 243 hub_info->port_count = descriptor->ports_count; 247 244 /// \TODO this is not semantically correct 248 bool is_power_switched =249 ((descriptor->hub_characteristics & 1) ==0);250 bool has_individual_port_powering =251 ((descriptor->hub_characteristics & 1) !=0);252 245 hub_info->ports = malloc( 253 246 sizeof (usb_hub_port_t) * (hub_info->port_count + 1)); … … 256 249 usb_hub_port_init(&hub_info->ports[port]); 257 250 } 258 if(is_power_switched){ 259 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{ 271 usb_log_debug("!has_individual_port_powering\n"); 272 opResult = usb_hub_set_feature(hub_info->control_pipe, 273 USB_HUB_FEATURE_C_HUB_LOCAL_POWER); 274 if (opResult != EOK) { 275 usb_log_error("cannot power hub: %s\n", 276 str_error(opResult)); 277 } 278 } 279 }else{ 280 usb_log_debug("!is_power_switched\n"); 251 for (port = 0; port < hub_info->port_count; port++) { 252 opResult = usb_hub_set_port_feature(hub_info->control_pipe, 253 port+1, USB_HUB_FEATURE_PORT_POWER); 254 if (opResult != EOK) { 255 usb_log_error("cannot power on port %d; %d\n", 256 port+1, opResult); 257 } 281 258 } 282 259 usb_log_debug2("freeing data\n"); 283 //free(serialized_descriptor);284 //free(descriptor->devices_removable);260 free(serialized_descriptor); 261 free(descriptor->devices_removable); 285 262 free(descriptor); 286 263 return EOK; … … 344 321 * auto destruction, this could work better. 345 322 */ 346 int rc = usb_ hc_connection_open(&hub_info->connection);323 int rc = usb_pipe_start_session(hub_info->control_pipe); 347 324 if (rc != EOK) { 348 //usb_pipe_end_session(hub_info->control_pipe); 325 usb_log_error("Failed to start session on control pipe: %s.\n", 326 str_error(rc)); 327 return rc; 328 } 329 rc = usb_hc_connection_open(&hub_info->connection); 330 if (rc != EOK) { 331 usb_pipe_end_session(hub_info->control_pipe); 349 332 usb_log_error("Failed to open connection to HC: %s.\n", 350 333 str_error(rc)); … … 362 345 } 363 346 364 usb_log_info("Controlling hub `%s' (% zuports).\n",347 usb_log_info("Controlling hub `%s' (%d ports).\n", 365 348 hub_info->usb_device->ddf_dev->name, hub_info->port_count); 366 349 return EOK; … … 430 413 port, USB_HUB_FEATURE_PORT_POWER); 431 414 if (opResult != EOK) { 432 usb_log_error(" Cannot power on port %zu: %s.\n",433 port, str_error(opResult));415 usb_log_error("cannot power on port %d; %d\n", 416 port, opResult); 434 417 } 435 418 }
Note:
See TracChangeset
for help on using the changeset viewer.