Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2073703ybi; Thu, 4 Jul 2019 04:48:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqzI8bCN5RDaPzOIiFA9wunBwktkZK+CKpSmNKDGzYzniW1rZWeidW1h5+6glU9PPZsub8ka X-Received: by 2002:a63:5d45:: with SMTP id o5mr43631775pgm.40.1562240917005; Thu, 04 Jul 2019 04:48:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562240916; cv=none; d=google.com; s=arc-20160816; b=VfXS3TxFd7cRoac1IarEj6WCkZJAapuZja8T6PDISTNdwwD0jrE1LhNNT1hkc03qhy rvEIErUI6kxqOYBhmYfWhZpJtL5Ws4PYV6HbSiQOF0H9gzwQWh2tsVqa0as+eaXN8zET RA6cBTAJ9mX7GBmMf1lVaEsIxaLbmKL0172S8t7BHWbUQP8yzbfh3QoRPjurbUoL0rlP Fdce4nDycbBPLhLFFx06+l3wCXdO3DUpyxAaHh81nZq5MlNJKBRKSHs0kDVzT/YAQDiU q57BzSouCGUqC8mRzY/QFhB0eeb0lCpp3bDahfeFOOYeRul/MmLY4x2MX/uTWEhcraFy 9qwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=UBe5gEYsgoVbt9kCQpdyaOqDwTf0IJKa5gW28ba3xE8=; b=ShweRLpNFmZukp9SDNDJo2FCYD9xnausFWpUSQwFl9JYQ0YG3gYqdLJEhd6Z0P2zAZ HL+XKCG6DTXwPhYZQBoGgb0r80MQYDMd49S0bEYkTsr3OnqCSAtishDHhojSSLClLKRR ZwHeZyd8RlYZGc55x0U0X8qdE/Cth/H09nAAQs5G4/xCcEC0Q04Bz3EZ94Zzk0zIeC/1 OlkjkLBqVLZUHsivnJD1K4kwg72AhWhCQC7nl9Cx6LVanY3WnMX+xnGM61wfQTHEcKWg wvlF9Ip2RrKV36B44ndvvAPLDNLk+igziPcg3uR9liGYyCNwHK6kihgt1kxWM+xZheCk BI3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=eXkaECc6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=opensource.cirrus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a10si5452103pfc.55.2019.07.04.04.48.22; Thu, 04 Jul 2019 04:48:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=eXkaECc6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=opensource.cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727611AbfGDLry (ORCPT + 99 others); Thu, 4 Jul 2019 07:47:54 -0400 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:39060 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727436AbfGDLrx (ORCPT ); Thu, 4 Jul 2019 07:47:53 -0400 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x64Bihlp001158; Thu, 4 Jul 2019 06:47:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=PODMain02222019; bh=UBe5gEYsgoVbt9kCQpdyaOqDwTf0IJKa5gW28ba3xE8=; b=eXkaECc6iWCAHvLklGh40apXQVkI0QlN6Zc7c6JhlXWZHRzkZ34NOWwnsuuBXImXW/B5 TXaJZXxYXnGJdf11vB/Rev7Wk1rZlv7Nvgw1sOZg37uD2KmkBr7csdL5kaUAlNFzdqrm +iZFisMqrTvxroHQ2AwPwYA32q4TUZQRC4T5qR7BieHGWILAwcO0U/j9LzGSYqFhA6Ej XFjIk45QovU1y7K/3qZSpJUl2r5KiMBqpm+OoeQqatZZ0aI2Ui6vEWKnwdqI/xYQ8jg1 YKPPGU80xEyJxNvJrqqXuzD6n3bS/dl/5gNOuN92UXVpahv/Mp4RWIQxQEMxCyxeNRPc 6w== Authentication-Results: ppops.net; spf=fail smtp.mailfrom=rf@opensource.cirrus.com Received: from mail1.cirrus.com (mail1.cirrus.com [141.131.3.20]) by mx0a-001ae601.pphosted.com with ESMTP id 2te5d4gqcp-1; Thu, 04 Jul 2019 06:47:31 -0500 Received: from EDIEX01.ad.cirrus.com (unknown [198.61.84.80]) by mail1.cirrus.com (Postfix) with ESMTP id 67043611C8C1; Thu, 4 Jul 2019 06:47:30 -0500 (CDT) Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Thu, 4 Jul 2019 12:47:29 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.1591.10 via Frontend Transport; Thu, 4 Jul 2019 12:47:29 +0100 Received: from [198.90.251.101] (edi-sw-dsktp006.ad.cirrus.com [198.90.251.101]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id B261A45; Thu, 4 Jul 2019 12:47:29 +0100 (BST) Subject: Re: [PATCH v2 34/35] sound/soc/codecs: Use kmemdup rather than duplicating its implementation To: Fuqian Huang CC: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , , , References: <20190703163224.1029-1-huangfq.daxian@gmail.com> From: Richard Fitzgerald Message-ID: <52ee7351-19fc-4fd3-33f8-9392a4ad9526@opensource.cirrus.com> Date: Thu, 4 Jul 2019 12:47:29 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20190703163224.1029-1-huangfq.daxian@gmail.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-SPF-Result: fail X-Proofpoint-SPF-Record: v=spf1 include:spf-001ae601.pphosted.com include:spf.protection.outlook.com -all X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907040152 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit message title prefix should be "ASoC: wm0010:" not "sound/soc /codecs:". Take a look at other patches to the same files. > kmemdup is introduced to duplicate a region of memory in a neat way. > Rather than kmalloc/kzalloc + memcpy, which the programmer needs to > write the size twice (sometimes lead to mistakes), kmemdup improves > readability, leads to smaller code and also reduce the chances of mistakes. > Suggestion to use kmemdup rather than using kmalloc/kzalloc + memcpy. > > Acked-by: Richard Fitzgerald > Signed-off-by: Fuqian Huang > --- > Changes in v2: > - Fix a typo in commit message (memset -> memcpy) > - Split into two patches > > sound/soc/codecs/wm0010.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/sound/soc/codecs/wm0010.c b/sound/soc/codecs/wm0010.c > index 727d6703c905..807826f30f58 100644 > --- a/sound/soc/codecs/wm0010.c > +++ b/sound/soc/codecs/wm0010.c > @@ -515,7 +515,7 @@ static int wm0010_stage2_load(struct snd_soc_component *component) > dev_dbg(component->dev, "Downloading %zu byte stage 2 loader\n", fw->size); > > /* Copy to local buffer first as vmalloc causes problems for dma */ > - img = kzalloc(fw->size, GFP_KERNEL | GFP_DMA); > + img = kmemdup(&fw->data[0], fw->size, GFP_KERNEL | GFP_DMA); > if (!img) { > ret = -ENOMEM; > goto abort2; > @@ -527,8 +527,6 @@ static int wm0010_stage2_load(struct snd_soc_component *component) > goto abort1; > } > > - memcpy(img, &fw->data[0], fw->size); > - > spi_message_init(&m); > memset(&t, 0, sizeof(t)); > t.rx_buf = out; >