Changeset 8b8c164 in mainline for uspace/drv/bus/usb/xhci/bus.c
- Timestamp:
- 2017-10-27T15:22:06Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 58ac3ec
- Parents:
- 7010861
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/bus.c
r7010861 r8b8c164 96 96 endpoint_add_ref(ep0_base); 97 97 98 ep0_base->device = &dev->base;99 98 xhci_endpoint_t *ep0 = xhci_endpoint_get(ep0_base); 100 99 … … 102 101 goto err_ep; 103 102 103 /* Register EP0 */ 104 if ((err = xhci_device_add_endpoint(dev, ep0))) 105 goto err_prepared; 106 104 107 /* Address device */ 105 108 if ((err = hc_address_device(hc, dev, ep0))) 106 goto err_prepared_ep; 107 108 /* Register EP0, passing Temporary reference */ 109 dev->endpoints[0] = ep0; 110 111 return EOK; 112 113 err_prepared_ep: 109 goto err_added; 110 111 /* Temporary reference */ 112 endpoint_del_ref(ep0_base); 113 return EOK; 114 115 err_added: 116 xhci_device_remove_endpoint(ep0); 117 err_prepared: 114 118 xhci_endpoint_free_transfer_ds(ep0); 115 119 err_ep: 120 /* Temporary reference */ 116 121 endpoint_del_ref(ep0_base); 117 122 err_slot: … … 251 256 } 252 257 253 static int register_endpoint(bus_t *bus_base, endpoint_t *ep, const usb_endpoint_desc_t *desc)258 static int register_endpoint(bus_t *bus_base, device_t *device, endpoint_t *ep_base, const usb_endpoint_desc_t *desc) 254 259 { 255 260 int err; 256 261 xhci_bus_t *bus = bus_to_xhci_bus(bus_base); 257 assert(bus); 258 259 assert(ep->device); 260 261 xhci_device_t *xhci_dev = xhci_device_get(ep->device); 262 xhci_endpoint_t *xhci_ep = xhci_endpoint_get(ep); 263 264 if ((err = prepare_endpoint(xhci_ep, desc))) 262 xhci_endpoint_t *ep = xhci_endpoint_get(ep_base); 263 264 xhci_device_t *dev = xhci_device_get(device); 265 266 if ((err = prepare_endpoint(ep, desc))) 265 267 return err; 266 268 267 usb_log_info("Endpoint(%d:%d) registered to XHCI bus.", ep->device->address, ep->endpoint); 268 return xhci_device_add_endpoint(bus->hc, xhci_dev, xhci_ep); 269 } 270 271 static int unregister_endpoint(bus_t *bus_base, endpoint_t *ep) 272 { 269 if ((err = xhci_device_add_endpoint(dev, ep))) 270 goto err_prepared; 271 272 usb_log_info("Endpoint(%d:%d) registered to XHCI bus.", dev->base.address, ep->base.endpoint); 273 274 xhci_ep_ctx_t ep_ctx; 275 xhci_setup_endpoint_context(ep, &ep_ctx); 276 277 if ((err = hc_add_endpoint(bus->hc, dev->slot_id, xhci_endpoint_index(ep), &ep_ctx))) 278 goto err_added; 279 280 return EOK; 281 282 err_added: 283 xhci_device_remove_endpoint(ep); 284 err_prepared: 285 xhci_endpoint_free_transfer_ds(ep); 286 return err; 287 } 288 289 static int unregister_endpoint(bus_t *bus_base, endpoint_t *ep_base) 290 { 291 int err; 273 292 xhci_bus_t *bus = bus_to_xhci_bus(bus_base); 274 assert(bus); 275 276 usb_log_info("Endpoint(%d:%d) unregistered from XHCI bus.", ep->device->address, ep->endpoint); 277 278 xhci_device_t *xhci_dev = xhci_device_get(ep->device); 279 xhci_endpoint_t *xhci_ep = xhci_endpoint_get(ep); 280 const int res = xhci_device_remove_endpoint(bus->hc, xhci_dev, xhci_ep); 281 if (res != EOK) 282 return res; 293 xhci_endpoint_t *ep = xhci_endpoint_get(ep_base); 294 xhci_device_t *dev = xhci_device_get(ep_base->device); 295 296 usb_log_info("Endpoint(%d:%d) unregistered from XHCI bus.", dev->base.address, ep->base.endpoint); 297 298 xhci_device_remove_endpoint(ep); 299 300 /* Drop the endpoint. */ 301 if ((err = hc_drop_endpoint(bus->hc, dev->slot_id, xhci_endpoint_index(ep)))) { 302 usb_log_error("Failed to drop endpoint: %s", str_error(err)); 303 } 304 305 /* Tear down TRB ring / PSA. */ 306 /* TODO: Make this method "noexcept" */ 307 if ((err = xhci_endpoint_free_transfer_ds(ep))) { 308 usb_log_error("Failed to free resources of an endpoint."); 309 } 283 310 284 311 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.