]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
usb : replace dma_pool_alloc and memset with dma_pool_zalloc
authorSaurabh Sengar <saurabh.truth@gmail.com>
Wed, 28 Oct 2015 07:14:35 +0000 (12:44 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 1 Dec 2015 22:26:33 +0000 (14:26 -0800)
replace dma_pool_alloc and memset with a single call to dma_pool_zalloc

Signed-off-by: Saurabh Sengar <saurabh.truth@gmail.com>
Acked-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/chipidea/udc.c
drivers/usb/gadget/udc/gr_udc.c
drivers/usb/host/uhci-q.c
drivers/usb/host/whci/qset.c
drivers/usb/host/xhci-mem.c

index 391a1225b0ba330cd818028f240cb151e8ade65c..b292b454c77ba8862b1e23c6472ea0ebf24f2b96 100644 (file)
@@ -349,14 +349,13 @@ static int add_td_to_list(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq,
        if (node == NULL)
                return -ENOMEM;
 
-       node->ptr = dma_pool_alloc(hwep->td_pool, GFP_ATOMIC,
+       node->ptr = dma_pool_zalloc(hwep->td_pool, GFP_ATOMIC,
                                   &node->dma);
        if (node->ptr == NULL) {
                kfree(node);
                return -ENOMEM;
        }
 
-       memset(node->ptr, 0, sizeof(struct ci_hw_td));
        node->ptr->token = cpu_to_le32(length << __ffs(TD_TOTAL_BYTES));
        node->ptr->token &= cpu_to_le32(TD_TOTAL_BYTES);
        node->ptr->token |= cpu_to_le32(TD_STATUS_ACTIVE);
index b9429bc4251161ac7407ab87168b97d31354e96f..39b7136d31d9c7b5be3263bb2ed2070dd3b2f537 100644 (file)
@@ -253,13 +253,12 @@ static struct gr_dma_desc *gr_alloc_dma_desc(struct gr_ep *ep, gfp_t gfp_flags)
        dma_addr_t paddr;
        struct gr_dma_desc *dma_desc;
 
-       dma_desc = dma_pool_alloc(ep->dev->desc_pool, gfp_flags, &paddr);
+       dma_desc = dma_pool_zalloc(ep->dev->desc_pool, gfp_flags, &paddr);
        if (!dma_desc) {
                dev_err(ep->dev->dev, "Could not allocate from DMA pool\n");
                return NULL;
        }
 
-       memset(dma_desc, 0, sizeof(*dma_desc));
        dma_desc->paddr = paddr;
 
        return dma_desc;
index da6f56d996ce56f61cd1be20a093c2c16ff54702..c17ea1589b8335b94abb1e176d13eb3cfee2b034 100644 (file)
@@ -248,11 +248,10 @@ static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci,
        dma_addr_t dma_handle;
        struct uhci_qh *qh;
 
-       qh = dma_pool_alloc(uhci->qh_pool, GFP_ATOMIC, &dma_handle);
+       qh = dma_pool_zalloc(uhci->qh_pool, GFP_ATOMIC, &dma_handle);
        if (!qh)
                return NULL;
 
-       memset(qh, 0, sizeof(*qh));
        qh->dma_handle = dma_handle;
 
        qh->element = UHCI_PTR_TERM(uhci);
index dc31c425ce0179551b27e2d7a900f1bb7b411ad8..329747398f9ac8aca888d1c7c726f8dadf48c050 100644 (file)
@@ -30,10 +30,9 @@ struct whc_qset *qset_alloc(struct whc *whc, gfp_t mem_flags)
        struct whc_qset *qset;
        dma_addr_t dma;
 
-       qset = dma_pool_alloc(whc->qset_pool, mem_flags, &dma);
+       qset = dma_pool_zalloc(whc->qset_pool, mem_flags, &dma);
        if (qset == NULL)
                return NULL;
-       memset(qset, 0, sizeof(struct whc_qset));
 
        qset->qset_dma = dma;
        qset->whc = whc;
index dc7f915d9a131c658fcd45786570e0884965b9d3..5cd080e0a685ebdbafbe3b6e64657f5be1607fda 100644 (file)
@@ -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,11 @@ 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;
 }