/** * frees the virtual devices for "xhci_ctrl" pointer passed * * @param ptr pointer to "xhci_ctrl" whose virtual devices are to be freed * @return none */ static void xhci_free_virt_devices(struct xhci_ctrl *ctrl) { int i; int slot_id; struct xhci_virt_device *virt_dev; /* * refactored here to loop through all virt_dev * Slot ID 0 is reserved */ for (slot_id = 0; slot_id < MAX_HC_SLOTS; slot_id++) { virt_dev = ctrl->devs[slot_id]; if (!virt_dev) continue; ctrl->dcbaa->dev_context_ptrs[slot_id] = 0; for (i = 0; i < 31; ++i) if (virt_dev->eps[i].ring) xhci_ring_free(virt_dev->eps[i].ring); if (virt_dev->in_ctx) xhci_free_container_ctx(virt_dev->in_ctx); if (virt_dev->out_ctx) xhci_free_container_ctx(virt_dev->out_ctx); free(virt_dev); /* make sure we are pointing to NULL */ ctrl->devs[slot_id] = NULL; } }
/* All the xhci_tds in the ring's TD list should be freed at this point */ void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id) { struct xhci_virt_device *dev; int i; /* Slot ID 0 is reserved */ if (slot_id == 0 || !xhci->devs[slot_id]) return; dev = xhci->devs[slot_id]; xhci->dcbaa->dev_context_ptrs[slot_id] = 0; if (!dev) return; for (i = 0; i < 31; ++i) if (dev->eps[i].ring) xhci_ring_free(xhci, dev->eps[i].ring); if (dev->ring_cache) { for (i = 0; i < dev->num_rings_cached; i++) xhci_ring_free(xhci, dev->ring_cache[i]); kfree(dev->ring_cache); } if (dev->in_ctx) xhci_free_container_ctx(xhci, dev->in_ctx); if (dev->out_ctx) xhci_free_container_ctx(xhci, dev->out_ctx); kfree(xhci->devs[slot_id]); xhci->devs[slot_id] = 0; }
/* All the xhci_tds in the ring's TD list should be freed at this point */ void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id) { struct xhci_virt_device *dev; int i; /* Slot ID 0 is reserved */ if (slot_id == 0 || !xhci->devs[slot_id]) return; dev = xhci->devs[slot_id]; xhci->dcbaa->dev_context_ptrs[slot_id] = 0; UBI_DMA_FLUSH(&xhci->dcbaa->dev_context_ptrs[slot_id], sizeof(u64)); if (!dev) return; for (i = 0; i < 31; ++i) if (dev->ep_rings[i]) xhci_ring_free(xhci, dev->ep_rings[i]); if (dev->in_ctx) xhci_free_container_ctx(xhci, dev->in_ctx); if (dev->out_ctx) xhci_free_container_ctx(xhci, dev->out_ctx); kfree(xhci->devs[slot_id]); xhci->devs[slot_id] = 0; }