Changes in uspace/drv/usbhub/usbhub.c [46e078a:9063484] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/usbhub.c
r46e078a r9063484 45 45 #include <usb/request.h> 46 46 #include <usb/classes/hub.h> 47 #include <usb/devpoll.h> 47 48 #include <stdio.h> 48 49 … … 104 105 } 105 106 106 usb_pipe_start_session(hub_info->control_pipe);107 //usb_pipe_start_session(hub_info->control_pipe); 107 108 //set hub configuration 108 109 opResult = usb_hub_set_configuration(hub_info); … … 121 122 return opResult; 122 123 } 123 usb_pipe_end_session(hub_info->control_pipe);124 125 /// \TODO what is this? 126 usb_log_debug("Creating `hub' function.\n");124 //usb_pipe_end_session(hub_info->control_pipe); 125 126 127 usb_log_debug("Creating 'hub' function in DDF.\n"); 127 128 ddf_fun_t *hub_fun = ddf_fun_create(hub_info->usb_device->ddf_dev, 128 129 fun_exposed, "hub"); … … 152 153 bool hub_port_changes_callback(usb_device_t *dev, 153 154 uint8_t *change_bitmap, size_t change_bitmap_size, void *arg) { 155 usb_log_debug("hub_port_changes_callback\n"); 154 156 usb_hub_info_t *hub = (usb_hub_info_t *) arg; 155 157 … … 216 218 // get hub descriptor 217 219 usb_log_debug("creating serialized descriptor\n"); 218 void * serialized_descriptor = malloc(USB_HUB_MAX_DESCRIPTOR_SIZE); 220 //void * serialized_descriptor = malloc(USB_HUB_MAX_DESCRIPTOR_SIZE); 221 uint8_t serialized_descriptor[USB_HUB_MAX_DESCRIPTOR_SIZE]; 219 222 usb_hub_descriptor_t * descriptor; 220 223 int opResult; … … 234 237 } 235 238 usb_log_debug2("deserializing descriptor\n"); 236 descriptor = usb_deserialize_hub_desriptor(serialized_descriptor); 239 descriptor = usb_create_deserialized_hub_desriptor( 240 serialized_descriptor); 237 241 if (descriptor == NULL) { 238 242 usb_log_warning("could not deserialize descriptor \n"); 239 return opResult;243 return ENOMEM; 240 244 } 241 245 usb_log_debug("setting port count to %d\n", descriptor->ports_count); 242 246 hub_info->port_count = descriptor->ports_count; 243 247 /// \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); 244 252 hub_info->ports = malloc( 245 253 sizeof (usb_hub_port_t) * (hub_info->port_count + 1)); … … 248 256 usb_hub_port_init(&hub_info->ports[port]); 249 257 } 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 %d; %d\n", 267 port+1, 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; %d\n", 276 opResult); 277 } 278 } 279 }else{ 280 usb_log_debug("!is_power_switched\n"); 281 } 250 282 usb_log_debug2("freeing data\n"); 251 free(serialized_descriptor);252 free(descriptor->devices_removable);283 //free(serialized_descriptor); 284 //free(descriptor->devices_removable); 253 285 free(descriptor); 254 286 return EOK; … … 312 344 * auto destruction, this could work better. 313 345 */ 314 int rc = usb_ pipe_start_session(hub_info->control_pipe);346 int rc = usb_hc_connection_open(&hub_info->connection); 315 347 if (rc != EOK) { 316 usb_log_error("Failed to start session on control pipe: %s.\n", 317 str_error(rc)); 318 return rc; 319 } 320 rc = usb_hc_connection_open(&hub_info->connection); 321 if (rc != EOK) { 322 usb_pipe_end_session(hub_info->control_pipe); 348 //usb_pipe_end_session(hub_info->control_pipe); 323 349 usb_log_error("Failed to open connection to HC: %s.\n", 324 350 str_error(rc));
Note:
See TracChangeset
for help on using the changeset viewer.