Changeset 40a3bfa in mainline for uspace/drv/bus/usb/xhci/bus.c
- Timestamp:
- 2017-10-28T11:25:11Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d46ceb2b
- Parents:
- 58ac3ec
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/bus.c
r58ac3ec r40a3bfa 185 185 int xhci_bus_remove_device(xhci_bus_t *bus, xhci_hc_t *hc, device_t *dev) 186 186 { 187 int err; 187 188 xhci_device_t *xhci_dev = xhci_device_get(dev); 189 190 /* Block creation of new endpoints and transfers. */ 191 usb_log_debug2("Device '%s' going offline.", ddf_fun_get_name(dev->fun)); 192 fibril_mutex_lock(&dev->guard); 193 xhci_dev->online = false; 194 fibril_mutex_unlock(&dev->guard); 195 196 /* Abort running transfers. */ 197 usb_log_debug2("Aborting all active transfers to '%s'.", ddf_fun_get_name(dev->fun)); 198 for (size_t i = 0; i < ARRAY_SIZE(xhci_dev->endpoints); ++i) { 199 xhci_endpoint_t *ep = xhci_dev->endpoints[i]; 200 if (!ep || !ep->base.active) 201 continue; 202 203 /* FIXME: This is racy. */ 204 if ((err = xhci_transfer_abort(&ep->active_transfer))) { 205 usb_log_warning("Failed to abort active %s transfer to " 206 " endpoint %d of detached device '%s': %s", 207 usb_str_transfer_type(ep->base.transfer_type), 208 ep->base.endpoint, ddf_fun_get_name(dev->fun), 209 str_error(err)); 210 } 211 } 212 213 /* TODO: Figure out how to handle errors here. So far, they are reported and skipped. */ 214 215 /* Make DDF (and all drivers) forget about the device. */ 216 if ((err = ddf_fun_unbind(dev->fun))) { 217 usb_log_warning("Failed to unbind DDF function of detached device '%s': %s", 218 ddf_fun_get_name(dev->fun), str_error(err)); 219 } 220 221 /* Deconfigure device if it's still attached. */ 222 if (!xhci_dev->detached) { 223 if ((err = hc_deconfigure_device(hc, xhci_dev->slot_id))) { 224 usb_log_warning("Failed to deconfigure detached device '%s': %s", 225 ddf_fun_get_name(dev->fun), str_error(err)); 226 } 227 } 188 228 189 229 /* Unregister remaining endpoints. */ … … 192 232 continue; 193 233 194 const int err = unregister_endpoint(&bus->base, &xhci_dev->endpoints[i]->base); 195 if (err) 234 if ((err = unregister_endpoint(&bus->base, &xhci_dev->endpoints[i]->base))) { 196 235 usb_log_warning("Failed to unregister EP (%u:%u): %s", dev->address, i, str_error(err)); 236 } 197 237 } 198 238 199 239 // XXX: Ugly here. Move to device_destroy at endpoint.c? 240 if ((err = hc_disable_slot(hc, xhci_dev->slot_id))) { 241 usb_log_warning("Failed to disable slot %d for device '%s': %s", 242 xhci_dev->slot_id, ddf_fun_get_name(dev->fun), str_error(err)); 243 } 244 200 245 free32(xhci_dev->dev_ctx); 201 246 hc->dcbaa[xhci_dev->slot_id] = 0; 247 248 bus->devices_by_slot[xhci_dev->slot_id] = NULL; 249 202 250 return EOK; 203 251 } … … 305 353 /* Tear down TRB ring / PSA. */ 306 354 /* TODO: Make this method "noexcept" */ 307 if ((err = xhci_endpoint_free_transfer_ds(ep))) { 355 /* FIXME: There is some memory corruption going on, causing this to crash. */ 356 /*if ((err = xhci_endpoint_free_transfer_ds(ep))) { 308 357 usb_log_error("Failed to free resources of an endpoint."); 309 } 358 }*/ 310 359 311 360 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.