Changeset 8b8c164 in mainline for uspace/drv/bus/usb/xhci/endpoint.c
- Timestamp:
- 2017-10-27T15:22:06Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade
- Children:
- 58ac3ec
- Parents:
- 7010861
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/endpoint.c
r7010861 r8b8c164 189 189 { 190 190 191 usb_log_debug2("Allocating main transfer ring for endpoint " XHCI_EP_FMT, XHCI_EP_ARGS(*xhci_ep));191 usb_log_debug2("Allocating main transfer ring for endpoint %u", xhci_ep->base.endpoint); 192 192 193 193 xhci_ep->primary_stream_ctx_array = NULL; … … 323 323 } 324 324 325 int xhci_device_add_endpoint(xhci_ hc_t *hc, xhci_device_t *dev, xhci_endpoint_t *ep)325 int xhci_device_add_endpoint(xhci_device_t *dev, xhci_endpoint_t *ep) 326 326 { 327 327 assert(dev); … … 329 329 330 330 /* Offline devices don't create new endpoints other than EP0. */ 331 if (!dev->online ) {331 if (!dev->online && ep->base.endpoint > 0) { 332 332 return EAGAIN; 333 333 } … … 335 335 const usb_endpoint_t ep_num = ep->base.endpoint; 336 336 337 assert(&dev->base == ep->base.device); 338 339 // TODO Do not fail hard on runtime conditions 340 assert(!dev->endpoints[ep_num]); 337 if (dev->endpoints[ep_num]) 338 return EEXIST; 339 340 /* Device reference */ 341 endpoint_add_ref(&ep->base); 342 ep->base.device = &dev->base; 341 343 342 344 dev->endpoints[ep_num] = ep; 343 345 ++dev->active_endpoint_count; 344 346 345 if (ep_num == 0) { 346 /* EP 0 is initialized while setting up the device, 347 * so we must not issue the command now. */ 348 return EOK; 349 } 350 351 /* Add endpoint. */ 352 xhci_ep_ctx_t ep_ctx; 353 xhci_setup_endpoint_context(ep, &ep_ctx); 354 355 return hc_add_endpoint(hc, dev->slot_id, xhci_endpoint_index(ep), &ep_ctx); 356 } 357 358 int xhci_device_remove_endpoint(xhci_hc_t *hc, xhci_device_t *dev, xhci_endpoint_t *ep) 359 { 360 assert(&dev->base == ep->base.device); 347 return EOK; 348 } 349 350 void xhci_device_remove_endpoint(xhci_endpoint_t *ep) 351 { 352 assert(ep); 353 xhci_device_t *dev = xhci_device_get(ep->base.device); 354 361 355 assert(dev->endpoints[ep->base.endpoint]); 362 363 int err = ENOMEM;364 const usb_endpoint_t ep_num = ep->base.endpoint;365 356 366 357 dev->endpoints[ep->base.endpoint] = NULL; 367 358 --dev->active_endpoint_count; 368 369 if (ep_num == 0) { 370 /* EP 0 is finalized while releasing the device, 371 * so we must not issue the command now. */ 372 return EOK; 373 } 374 375 /* Drop the endpoint. */ 376 if ((err = hc_drop_endpoint(hc, dev->slot_id, xhci_endpoint_index(ep)))) { 377 goto err; 378 } 379 380 /* Tear down TRB ring / PSA. */ 381 /* FIXME: For some reason, this causes crash at xhci_trb_ring_fini. 382 if ((err = xhci_endpoint_free_transfer_ds(ep))) { 383 goto err_cmd; 384 } 385 */ 386 387 return EOK; 388 389 err: 390 dev->endpoints[ep_num] = ep; 391 ++dev->active_endpoint_count; 392 return err; 359 ep->base.device = NULL; 360 361 endpoint_del_ref(&ep->base); 393 362 } 394 363
Note:
See TracChangeset
for help on using the changeset viewer.