* [PATCH 3/3] usb: xhci: replace dma_pool_alloc and memset with dma_pool_zalloc
@ 2015-12-02 20:43 Geyslan G. Bem
2015-12-07 10:08 ` Peter Senna Tschudin
0 siblings, 1 reply; 2+ messages in thread
From: Geyslan G. Bem @ 2015-12-02 20:43 UTC (permalink / raw)
To: peter.senna
Cc: Geyslan G. Bem, Mathias Nyman, Greg Kroah-Hartman, linux-usb,
linux-kernel
Replace dma_pool_alloc and memset with a single call to dma_pool_zalloc.
Caught by coccinelle.
Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
---
drivers/usb/host/xhci-mem.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index c48cbe7..d034f92 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 3/3] usb: xhci: replace dma_pool_alloc and memset with dma_pool_zalloc
2015-12-02 20:43 [PATCH 3/3] usb: xhci: replace dma_pool_alloc and memset with dma_pool_zalloc Geyslan G. Bem
@ 2015-12-07 10:08 ` Peter Senna Tschudin
0 siblings, 0 replies; 2+ messages in thread
From: Peter Senna Tschudin @ 2015-12-07 10:08 UTC (permalink / raw)
To: Geyslan G. Bem; +Cc: Mathias Nyman, Greg Kroah-Hartman, linux-usb, linux-kernel
On Wed, Dec 2, 2015 at 9:43 PM, Geyslan G. Bem <geyslan@gmail.com> wrote:
> 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:
Acked-by: Peter Senna Tschudin <peter.senna@gmail.com>
>
> Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
> ---
> drivers/usb/host/xhci-mem.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
> index c48cbe7..d034f92 100644
> --- a/drivers/usb/host/xhci-mem.c
> +++ b/drivers/usb/host/xhci-mem.c
> @@ -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
>
--
Peter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-12-07 10:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-02 20:43 [PATCH 3/3] usb: xhci: replace dma_pool_alloc and memset with dma_pool_zalloc Geyslan G. Bem
2015-12-07 10:08 ` Peter Senna Tschudin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).