Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752933AbeABKLM (ORCPT + 1 other); Tue, 2 Jan 2018 05:11:12 -0500 Received: from mga05.intel.com ([192.55.52.43]:52159 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752736AbeABKLJ (ORCPT ); Tue, 2 Jan 2018 05:11:09 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,496,1508828400"; d="scan'208";a="6695952" Subject: Re: [PATCH v2] USB: host: Use zeroing memory allocator rather than allocator/memset To: Himanshu Jha , gregkh@linuxfoundation.org Cc: stern@rowland.harvard.edu, mathias.nyman@intel.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, mcgrof@kernel.org References: <1514664232-9654-1-git-send-email-himanshujha199640@gmail.com> From: Mathias Nyman Message-ID: <82141791-ec06-e513-d35a-8de789bb804e@linux.intel.com> Date: Tue, 2 Jan 2018 12:13:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <1514664232-9654-1-git-send-email-himanshujha199640@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On 30.12.2017 22:03, Himanshu Jha wrote: > Use dma_zalloc_coherent for allocating zeroed > memory and remove unnecessary memset function. > > Done using Coccinelle. > Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci > 0-day tested with no failures. > > Suggested-by: Luis R. Rodriguez > Signed-off-by: Himanshu Jha > --- > v2: > -align argumenst as they were before applying the SmPL rule. > > drivers/usb/host/uhci-hcd.c | 7 +++---- > drivers/usb/host/xhci-mem.c | 7 ++----- > 2 files changed, 5 insertions(+), 9 deletions(-) > > diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c > index f5c9021..ac53398 100644 > --- a/drivers/usb/host/uhci-hcd.c > +++ b/drivers/usb/host/uhci-hcd.c > @@ -600,15 +600,14 @@ static int uhci_start(struct usb_hcd *hcd) > uhci->dentry = dentry; > #endif > > - uhci->frame = dma_alloc_coherent(uhci_dev(uhci), > - UHCI_NUMFRAMES * sizeof(*uhci->frame), > - &uhci->frame_dma_handle, GFP_KERNEL); > + uhci->frame = dma_zalloc_coherent(uhci_dev(uhci), > + UHCI_NUMFRAMES * sizeof(*uhci->frame), > + &uhci->frame_dma_handle, GFP_KERNEL); > if (!uhci->frame) { > dev_err(uhci_dev(uhci), > "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); > diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c > index 554a8a5..332420d 100644 > --- a/drivers/usb/host/xhci-mem.c > +++ b/drivers/usb/host/xhci-mem.c > @@ -1782,14 +1782,11 @@ int xhci_alloc_erst(struct xhci_hcd *xhci, > struct xhci_erst_entry *entry; > > size = sizeof(struct xhci_erst_entry) * evt_ring->num_segs; > - erst->entries = dma_alloc_coherent(xhci_to_hcd(xhci)->self.sysdev, > - size, > - &erst->erst_dma_addr, > - flags); > + erst->entries = dma_zalloc_coherent(xhci_to_hcd(xhci)->self.sysdev, > + size, &erst->erst_dma_addr, flags); > if (!erst->entries) > return -ENOMEM; > > - memset(erst->entries, 0, size); > erst->num_entries = evt_ring->num_segs; > > seg = evt_ring->first_seg; For the xhci part: Acked-by: Mathias Nyman