Changes in uspace/drv/usbhub/usbhub.c [dd143621:49ce810] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/usbhub.c
rdd143621 r49ce810 72 72 static void usb_hub_process_global_interrupt(usb_hub_info_t * hub_info); 73 73 74 static void usb_hub_polling_termin ated_callback(usb_device_t * device,74 static void usb_hub_polling_terminted_callback(usb_device_t * device, 75 75 bool was_error, void * data); 76 76 … … 200 200 result->control_pipe = &usb_dev->ctrl_pipe; 201 201 result->is_default_address_used = false; 202 203 result->ports = NULL;204 result->port_count = (size_t) -1;205 fibril_mutex_initialize(&result->port_mutex);206 207 fibril_mutex_initialize(&result->pending_ops_mutex);208 fibril_condvar_initialize(&result->pending_ops_cv);209 result->pending_ops_count = 0;210 202 return result; 211 203 } … … 348 340 rc = usb_device_auto_poll(hub_info->usb_device, 0, 349 341 hub_port_changes_callback, ((hub_info->port_count + 1) / 8) + 1, 350 usb_hub_polling_termin ated_callback, hub_info);342 usb_hub_polling_terminted_callback, hub_info); 351 343 if (rc != EOK) { 352 344 usb_log_error("Failed to create polling fibril: %s.\n", … … 481 473 * @param data pointer to usb_hub_info_t structure 482 474 */ 483 static void usb_hub_polling_termin ated_callback(usb_device_t * device,475 static void usb_hub_polling_terminted_callback(usb_device_t * device, 484 476 bool was_error, void * data){ 485 usb_hub_info_t * hub = data; 486 assert(hub); 487 488 fibril_mutex_lock(&hub->pending_ops_mutex); 489 490 /* The device is dead. However there might be some pending operations 491 * that we need to wait for. 492 * One of them is device adding in progress. 493 * The respective fibril is probably waiting for status change 494 * in port reset (port enable) callback. 495 * Such change would never come (otherwise we would not be here). 496 * Thus, we would flush all pending port resets. 497 */ 498 if (hub->pending_ops_count > 0) { 499 fibril_mutex_lock(&hub->port_mutex); 500 size_t port; 501 for (port = 0; port < hub->port_count; port++) { 502 usb_hub_port_t *the_port = hub->ports + port; 503 fibril_mutex_lock(&the_port->reset_mutex); 504 the_port->reset_completed = true; 505 the_port->reset_okay = false; 506 fibril_condvar_broadcast(&the_port->reset_cv); 507 fibril_mutex_unlock(&the_port->reset_mutex); 508 } 509 fibril_mutex_unlock(&hub->port_mutex); 510 } 511 /* And now wait for them. */ 512 while (hub->pending_ops_count > 0) { 513 fibril_condvar_wait(&hub->pending_ops_cv, 514 &hub->pending_ops_mutex); 515 } 516 fibril_mutex_unlock(&hub->pending_ops_mutex); 517 518 free(hub->ports); 519 free(hub); 477 usb_hub_info_t * hub_info = data; 478 if(!hub_info) return; 479 free(hub_info->ports); 480 free(hub_info); 520 481 } 521 482
Note:
See TracChangeset
for help on using the changeset viewer.