Skip to contentSkip to conversation

usb: xhci: replace dma_pool_alloc and memset with dma_pool_zalloc

PATCH In review Geyslan G. Bem 2 participants 2 messages Dec 2, 2015 – Dec 7, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 3/3 usb: xhci: replace dma_pool_alloc and memset with dma_pool_zalloc

Replace dma_pool_alloc and memset with a single call to dma_pool_zalloc.

Caught by coccinelle.

---
 drivers/usb/host/xhci-mem.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/usb/host/xhci-mem.c +3 -4
index c48cbe7..d034f92 100644
@@ -47,13 +47,12 @@ static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci,
 	if (!seg)
 		return NULL;
 
-	seg->trbs = dma_pool_alloc(xhci->segment_pool, flags, &dma);
+	seg->trbs = dma_pool_zalloc(xhci->segment_pool, flags, &dma);
 	if (!seg->trbs) {
 		kfree(seg);
 		return NULL;
 	}
 
-	memset(seg->trbs, 0, TRB_SEGMENT_SIZE);
 	/* If the cycle state is 0, set the cycle bit to 1 for all the TRBs */
 	if (cycle_state == 0) {
 		for (i = 0; i < TRBS_PER_SEGMENT; i++)
@@ -517,12 +516,12 @@ static struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci
 	if (type == XHCI_CTX_TYPE_INPUT)
 		ctx->size += CTX_SIZE(xhci->hcc_params);
 
-	ctx->bytes = dma_pool_alloc(xhci->device_pool, flags, &ctx->dma);
+	ctx->bytes = dma_pool_zalloc(xhci->device_pool, flags, &ctx->dma);
 	if (!ctx->bytes) {
 		kfree(ctx);
 		return NULL;
 	}
-	memset(ctx->bytes, 0, ctx->size);
+
 	return ctx;
 }
 
Signature · 1 line
2.6.2
Acked-by on v1 3/3
#1 lore raw
Quoted 3 lines · Geyslan G. Bem

Replace dma_pool_alloc and memset with a single call to dma_pool_zalloc.

Caught by coccinelle.

I would mention which script was used, but other than that:

Quoted 43 lines
---
 drivers/usb/host/xhci-mem.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/usb/host/xhci-mem.c +3 -5
index c48cbe7..d034f92 100644
@@ -47,13 +47,12 @@ static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci,
        if (!seg)
                return NULL;
 
-       seg->trbs = dma_pool_alloc(xhci->segment_pool, flags, &dma);
+       seg->trbs = dma_pool_zalloc(xhci->segment_pool, flags, &dma);
        if (!seg->trbs) {
                kfree(seg);
                return NULL;
        }
 
-       memset(seg->trbs, 0, TRB_SEGMENT_SIZE);
        /* If the cycle state is 0, set the cycle bit to 1 for all the TRBs */
        if (cycle_state == 0) {
                for (i = 0; i < TRBS_PER_SEGMENT; i++)
@@ -517,12 +516,12 @@ static struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci
        if (type == XHCI_CTX_TYPE_INPUT)
                ctx->size += CTX_SIZE(xhci->hcc_params);
 
-       ctx->bytes = dma_pool_alloc(xhci->device_pool, flags, &ctx->dma);
+       ctx->bytes = dma_pool_zalloc(xhci->device_pool, flags, &ctx->dma);
        if (!ctx->bytes) {
                kfree(ctx);
                return NULL;
        }
-       memset(ctx->bytes, 0, ctx->size);
+
        return ctx;
 }
 
--

2.6.2

Signature · 1 line
Peter