Changeset 04df063 in mainline for uspace/drv/bus/usb/xhci/rh.c
- Timestamp:
- 2017-10-02T19:16:29Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1f76b7d
- Parents:
- 370a1c8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/rh.c
r370a1c8 r04df063 63 63 int err; 64 64 65 xhci_cmd_t *cmd = xhci_alloc_command(); 66 if (!cmd) 67 return ENOMEM; 68 69 xhci_send_enable_slot_command(hc, cmd); 70 if ((err = xhci_wait_for_command(cmd, 100000)) != EOK) { 71 usb_log_error("Failed to enable a slot for the device."); 72 goto err_command; 73 } 74 75 uint32_t slot_id = cmd->slot_id; 65 xhci_cmd_t cmd; 66 xhci_cmd_init(&cmd); 67 68 xhci_send_enable_slot_command(hc, &cmd); 69 if ((err = xhci_cmd_wait(&cmd, 100000)) != EOK) 70 return err; 71 72 uint32_t slot_id = cmd.slot_id; 73 76 74 usb_log_debug2("Obtained slot ID: %u.\n", slot_id); 77 78 xhci_free_command(cmd); 79 cmd = NULL; 75 xhci_cmd_fini(&cmd); 80 76 81 77 xhci_input_ctx_t *ictx = malloc32(sizeof(xhci_input_ctx_t)); 82 78 if (!ictx) { 83 err = ENOMEM; 84 goto err_command; 79 return ENOMEM; 85 80 } 86 81 … … 90 85 XHCI_INPUT_CTRL_CTX_ADD_SET(ictx->ctrl_ctx, 1); 91 86 92 87 /* Initialize slot_ctx according to section 4.3.3 point 3. */ 93 88 /* Attaching to root hub port, root string equals to 0. */ 94 89 XHCI_SLOT_ROOT_HUB_PORT_SET(ictx->slot_ctx, port); … … 133 128 hc->dcbaa_virt[slot_id].dev_ctx = dctx; 134 129 135 cmd = xhci_alloc_command(); 136 cmd->ictx = ictx; 137 xhci_send_address_device_command(hc, cmd); 138 if ((err = xhci_wait_for_command(cmd, 100000)) != EOK) 130 xhci_cmd_init(&cmd); 131 xhci_send_address_device_command(hc, &cmd, ictx); 132 if ((err = xhci_cmd_wait(&cmd, 100000)) != EOK) 139 133 goto err_dctx; 140 134 141 xhci_free_command(cmd); 142 ictx = NULL; 135 xhci_cmd_fini(&cmd); 143 136 144 137 // TODO: Issue configure endpoint commands (sec 4.3.5). … … 158 151 } 159 152 err_ictx: 160 if (ictx) { 161 /* Avoid double free. */ 162 if (cmd && cmd->ictx && cmd->ictx == ictx) 163 cmd->ictx = NULL; 164 free32(ictx); 165 } 166 err_command: 167 if (cmd) 168 xhci_free_command(cmd); 153 free32(ictx); 169 154 return err; 170 155 }
Note:
See TracChangeset
for help on using the changeset viewer.