Changeset 4688350b in mainline for uspace/drv/bus/usb/xhci/commands.c
- Timestamp:
- 2017-10-01T22:54:09Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 370a1c8
- Parents:
- 4d28d86
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/commands.c
r4d28d86 r4688350b 81 81 } 82 82 83 int xhci_wait_for_command(xhci_cmd_t *cmd, uint32_t timeout) 84 { 85 uint32_t time = 0; 83 int xhci_wait_for_command(xhci_cmd_t *cmd, suseconds_t timeout) 84 { 85 int rv = EOK; 86 87 fibril_mutex_lock(&cmd->completed_mtx); 86 88 while (!cmd->completed) { 87 async_usleep(1000); 88 time += 1000; 89 90 if (time > timeout) 91 return ETIMEOUT; 92 } 93 94 return EOK; 89 usb_log_debug2("Waiting for event completion: going to sleep."); 90 rv = fibril_condvar_wait_timeout(&cmd->completed_cv, &cmd->completed_mtx, timeout); 91 92 usb_log_debug2("Waiting for event completion: woken: %s", str_error(rv)); 93 if (rv == ETIMEOUT) 94 break; 95 } 96 fibril_mutex_lock(&cmd->completed_mtx); 97 98 return rv; 95 99 } 96 100 … … 98 102 { 99 103 xhci_cmd_t *cmd = malloc32(sizeof(xhci_cmd_t)); 100 memset(cmd, 0, sizeof(xhci_cmd_t)); 104 xhci_cmd_init(cmd); 105 return cmd; 106 } 107 108 void xhci_cmd_init(xhci_cmd_t *cmd) 109 { 110 memset(cmd, 0, sizeof(*cmd)); 101 111 102 112 link_initialize(&cmd->link); 113 114 fibril_mutex_initialize(&cmd->completed_mtx); 115 fibril_condvar_initialize(&cmd->completed_cv); 103 116 104 117 /** … … 108 121 */ 109 122 cmd->has_owner = true; 110 111 return cmd;112 123 } 113 124 … … 493 504 } 494 505 506 fibril_mutex_lock(&command->completed_mtx); 495 507 command->completed = true; 508 fibril_condvar_broadcast(&command->completed_cv); 509 fibril_mutex_unlock(&command->completed_mtx); 510 496 511 497 512 if (!command->has_owner) {
Note:
See TracChangeset
for help on using the changeset viewer.