diff options
author | Sarah Sharp <sarah.a.sharp@linux.intel.com> | 2009-12-09 15:59:01 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-03-02 14:53:08 -0800 |
commit | 412566bd716397e28e81fc9b20804bc6a6daf14d (patch) | |
tree | 4013aaa1eda796f8dedea243167f3f4811d211b4 /drivers/usb/host/xhci-mem.c | |
parent | c01591bd6ece72e1c099cbc25ed812e1add579dc (diff) | |
download | blackbird-op-linux-412566bd716397e28e81fc9b20804bc6a6daf14d.tar.gz blackbird-op-linux-412566bd716397e28e81fc9b20804bc6a6daf14d.zip |
USB: xhci: Refactor code to free or cache endpoint rings.
Refactor out the code to cache or free endpoint rings from recently
dropped or disabled endpoints. This code will be used by a new function
to reset a device and disable all endpoints except control endpoint 0.
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host/xhci-mem.c')
-rw-r--r-- | drivers/usb/host/xhci-mem.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index bffcef7a5545..1f1f8a0f2e66 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -198,6 +198,31 @@ fail: return 0; } +void xhci_free_or_cache_endpoint_ring(struct xhci_hcd *xhci, + struct xhci_virt_device *virt_dev, + unsigned int ep_index) +{ + int rings_cached; + + rings_cached = virt_dev->num_rings_cached; + if (rings_cached < XHCI_MAX_RINGS_CACHED) { + virt_dev->num_rings_cached++; + rings_cached = virt_dev->num_rings_cached; + virt_dev->ring_cache[rings_cached] = + virt_dev->eps[ep_index].ring; + xhci_dbg(xhci, "Cached old ring, " + "%d ring%s cached\n", + rings_cached, + (rings_cached > 1) ? "s" : ""); + } else { + xhci_ring_free(xhci, virt_dev->eps[ep_index].ring); + xhci_dbg(xhci, "Ring cache full (%d rings), " + "freeing ring\n", + virt_dev->num_rings_cached); + } + virt_dev->eps[ep_index].ring = NULL; +} + /* Zero an endpoint ring (except for link TRBs) and move the enqueue and dequeue * pointers to the beginning of the ring. */ |