aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSarah Sharp <sarah.a.sharp@linux.intel.com>2009-12-09 18:59:03 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2010-03-02 17:53:09 -0500
commita1d78c16bd31a715785e21967ac6110b386a3c1f (patch)
treeb0df8ca079b2afad844276fdf2ece21dbcdc38fa
parent412566bd716397e28e81fc9b20804bc6a6daf14d (diff)
USB: xhci: Allow allocation of commands without input contexts.
The xhci_command structure is the basic structure for issuing commands to the xHCI hardware. It contains a struct completion (so that the issuing function can wait on the command), command status, and a input context that is used to pass information to the hardware. Not all commands need the input context, so make it optional to allocate. Allow xhci_free_container_ctx() to be passed a NULL input context, to make freeing the xhci_command structure simple. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/usb/host/xhci-hcd.c2
-rw-r--r--drivers/usb/host/xhci-mem.c18
-rw-r--r--drivers/usb/host/xhci.h3
3 files changed, 15 insertions, 8 deletions
diff --git a/drivers/usb/host/xhci-hcd.c b/drivers/usb/host/xhci-hcd.c
index 451f53eec6d7..17f1caf2af64 100644
--- a/drivers/usb/host/xhci-hcd.c
+++ b/drivers/usb/host/xhci-hcd.c
@@ -1679,7 +1679,7 @@ int xhci_update_hub_device(struct usb_hcd *hcd, struct usb_device *hdev,
1679 xhci_warn(xhci, "Cannot update hub desc for unknown device.\n"); 1679 xhci_warn(xhci, "Cannot update hub desc for unknown device.\n");
1680 return -EINVAL; 1680 return -EINVAL;
1681 } 1681 }
1682 config_cmd = xhci_alloc_command(xhci, true, mem_flags); 1682 config_cmd = xhci_alloc_command(xhci, true, true, mem_flags);
1683 if (!config_cmd) { 1683 if (!config_cmd) {
1684 xhci_dbg(xhci, "Could not allocate xHCI command structure.\n"); 1684 xhci_dbg(xhci, "Could not allocate xHCI command structure.\n");
1685 return -ENOMEM; 1685 return -ENOMEM;
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 1f1f8a0f2e66..8045bc69083d 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -267,6 +267,8 @@ struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci,
267void xhci_free_container_ctx(struct xhci_hcd *xhci, 267void xhci_free_container_ctx(struct xhci_hcd *xhci,
268 struct xhci_container_ctx *ctx) 268 struct xhci_container_ctx *ctx)
269{ 269{
270 if (!ctx)
271 return;
270 dma_pool_free(xhci->device_pool, ctx->bytes, ctx->dma); 272 dma_pool_free(xhci->device_pool, ctx->bytes, ctx->dma);
271 kfree(ctx); 273 kfree(ctx);
272} 274}
@@ -844,7 +846,8 @@ static void scratchpad_free(struct xhci_hcd *xhci)
844} 846}
845 847
846struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, 848struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci,
847 bool allocate_completion, gfp_t mem_flags) 849 bool allocate_in_ctx, bool allocate_completion,
850 gfp_t mem_flags)
848{ 851{
849 struct xhci_command *command; 852 struct xhci_command *command;
850 853
@@ -852,11 +855,14 @@ struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci,
852 if (!command) 855 if (!command)
853 return NULL; 856 return NULL;
854 857
855 command->in_ctx = 858 if (allocate_in_ctx) {
856 xhci_alloc_container_ctx(xhci, XHCI_CTX_TYPE_INPUT, mem_flags); 859 command->in_ctx =
857 if (!command->in_ctx) { 860 xhci_alloc_container_ctx(xhci, XHCI_CTX_TYPE_INPUT,
858 kfree(command); 861 mem_flags);
859 return NULL; 862 if (!command->in_ctx) {
863 kfree(command);
864 return NULL;
865 }
860 } 866 }
861 867
862 if (allocate_completion) { 868 if (allocate_completion) {
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 61747f3c5c8f..902be9647c60 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1237,7 +1237,8 @@ void xhci_free_or_cache_endpoint_ring(struct xhci_hcd *xhci,
1237 struct xhci_virt_device *virt_dev, 1237 struct xhci_virt_device *virt_dev,
1238 unsigned int ep_index); 1238 unsigned int ep_index);
1239struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, 1239struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci,
1240 bool allocate_completion, gfp_t mem_flags); 1240 bool allocate_in_ctx, bool allocate_completion,
1241 gfp_t mem_flags);
1241void xhci_free_command(struct xhci_hcd *xhci, 1242void xhci_free_command(struct xhci_hcd *xhci,
1242 struct xhci_command *command); 1243 struct xhci_command *command);
1243 1244