usb: Use dma_zalloc_coherent
Subsystems (4)
PATCH 1/1 usb: Use dma_zalloc_coherent
Use the zeroing version instead of dma_alloc_coherent and memset() as 0.
Signed-off-by Jisheng Zhang <[email protected]>
--- drivers/usb/dwc2/hcd_ddma.c | 5 +---- drivers/usb/host/uhci-hcd.c | 3 +-- drivers/usb/host/xhci-mem.c | 3 +-- 3 files changed, 3 insertions(+), 8 deletions(-)
drivers/usb/dwc2/hcd_ddma.c +1 -4
@@ -87,7 +87,7 @@ static u16 dwc2_frame_incr_val(struct dwc2_qh *qh)static int dwc2_desc_list_alloc (struct dwc2_hsotg *hsotg,struct dwc2_qh *qh,gfp_t flags) { - qh->desc_list =dma_alloc_coherent (hsotg->dev, + qh->desc_list =dma_zalloc_coherent (hsotg->dev,sizeof (struct dwc2_hcd_dma_desc ) *dwc2_max_desc_num (qh), &qh->desc_list_dma, flags);
@@ -95,9 +95,6 @@ static int dwc2_desc_list_alloc(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh,if (!qh->desc_list)return -ENOMEM ; -memset (qh->desc_list,0 , -sizeof (struct dwc2_hcd_dma_desc ) *dwc2_max_desc_num (qh)); - qh->n_bytes =kzalloc (sizeof (u32) *dwc2_max_desc_num (qh), flags);if (!qh->n_bytes) { dma_free_coherent(hsotg->dev, sizeof(struct dwc2_hcd_dma_desc)
drivers/usb/host/uhci-hcd.c +1 -2
@@ -589,7 +589,7 @@ static int uhci_start(struct usb_hcd *hcd) uhci->dentry = dentry;#endif - uhci->frame =dma_alloc_coherent (uhci_dev (uhci), + uhci->frame =dma_zalloc_coherent (uhci_dev (uhci),UHCI_NUMFRAMES *sizeof (*uhci->frame), &uhci->frame_dma_handle,GFP_KERNEL );if (!uhci->frame) {
@@ -597,7 +597,6 @@ static int uhci_start(struct usb_hcd *hcd) "unable to allocate consistent memory for frame list\n"); goto err_alloc_frame; } -memset (uhci->frame,0 ,UHCI_NUMFRAMES *sizeof (*uhci->frame)); uhci->frame_cpu =kcalloc (UHCI_NUMFRAMES ,sizeof (*uhci->frame_cpu),GFP_KERNEL );
drivers/usb/host/xhci-mem.c +1 -2
@@ -2455,7 +2455,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)if (xhci_check_trb_in_td_math (xhci, flags) <0 ) goto fail; - xhci->erst.entries =dma_alloc_coherent (dev, + xhci->erst.entries =dma_zalloc_coherent (dev,sizeof (struct xhci_erst_entry ) *ERST_NUM_SEGS , &dma,GFP_KERNEL );if (!xhci->erst.entries)
@@ -2464,7 +2464,6 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)"// Allocated event ring segment table at 0x%llx" , (unsigned long long)dma); -memset (xhci->erst.entries,0 ,sizeof (struct xhci_erst_entry )*ERST_NUM_SEGS ); xhci->erst.num_entries =ERST_NUM_SEGS ; xhci->erst.erst_dma_addr = dma; xhci_dbg_trace(xhci, trace_xhci_dbg_init,
Signature · 1 line
2.1.3