提交 a1d78c16 编写于 作者: S Sarah Sharp 提交者: Greg Kroah-Hartman

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: NSarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 412566bd
...@@ -1679,7 +1679,7 @@ int xhci_update_hub_device(struct usb_hcd *hcd, struct usb_device *hdev, ...@@ -1679,7 +1679,7 @@ int xhci_update_hub_device(struct usb_hcd *hcd, struct usb_device *hdev,
xhci_warn(xhci, "Cannot update hub desc for unknown device.\n"); xhci_warn(xhci, "Cannot update hub desc for unknown device.\n");
return -EINVAL; return -EINVAL;
} }
config_cmd = xhci_alloc_command(xhci, true, mem_flags); config_cmd = xhci_alloc_command(xhci, true, true, mem_flags);
if (!config_cmd) { if (!config_cmd) {
xhci_dbg(xhci, "Could not allocate xHCI command structure.\n"); xhci_dbg(xhci, "Could not allocate xHCI command structure.\n");
return -ENOMEM; return -ENOMEM;
......
...@@ -267,6 +267,8 @@ struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci, ...@@ -267,6 +267,8 @@ struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci,
void xhci_free_container_ctx(struct xhci_hcd *xhci, void xhci_free_container_ctx(struct xhci_hcd *xhci,
struct xhci_container_ctx *ctx) struct xhci_container_ctx *ctx)
{ {
if (!ctx)
return;
dma_pool_free(xhci->device_pool, ctx->bytes, ctx->dma); dma_pool_free(xhci->device_pool, ctx->bytes, ctx->dma);
kfree(ctx); kfree(ctx);
} }
...@@ -844,7 +846,8 @@ static void scratchpad_free(struct xhci_hcd *xhci) ...@@ -844,7 +846,8 @@ static void scratchpad_free(struct xhci_hcd *xhci)
} }
struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci,
bool allocate_completion, gfp_t mem_flags) bool allocate_in_ctx, bool allocate_completion,
gfp_t mem_flags)
{ {
struct xhci_command *command; struct xhci_command *command;
...@@ -852,11 +855,14 @@ struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, ...@@ -852,11 +855,14 @@ struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci,
if (!command) if (!command)
return NULL; return NULL;
command->in_ctx = if (allocate_in_ctx) {
xhci_alloc_container_ctx(xhci, XHCI_CTX_TYPE_INPUT, mem_flags); command->in_ctx =
if (!command->in_ctx) { xhci_alloc_container_ctx(xhci, XHCI_CTX_TYPE_INPUT,
kfree(command); mem_flags);
return NULL; if (!command->in_ctx) {
kfree(command);
return NULL;
}
} }
if (allocate_completion) { if (allocate_completion) {
......
...@@ -1237,7 +1237,8 @@ void xhci_free_or_cache_endpoint_ring(struct xhci_hcd *xhci, ...@@ -1237,7 +1237,8 @@ void xhci_free_or_cache_endpoint_ring(struct xhci_hcd *xhci,
struct xhci_virt_device *virt_dev, struct xhci_virt_device *virt_dev,
unsigned int ep_index); unsigned int ep_index);
struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci,
bool allocate_completion, gfp_t mem_flags); bool allocate_in_ctx, bool allocate_completion,
gfp_t mem_flags);
void xhci_free_command(struct xhci_hcd *xhci, void xhci_free_command(struct xhci_hcd *xhci,
struct xhci_command *command); struct xhci_command *command);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册