From patchwork Sat Aug 6 11:26:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Meyer X-Patchwork-Id: 1041502 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p76BRBNa006068 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 6 Aug 2011 11:27:33 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qpf1r-00017D-Je; Sat, 06 Aug 2011 11:26:56 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Qpf1r-0007km-3p; Sat, 06 Aug 2011 11:26:55 +0000 Received: from www17.your-server.de ([213.133.104.17]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qpf1n-0007kV-VQ for linux-arm-kernel@lists.infradead.org; Sat, 06 Aug 2011 11:26:52 +0000 Received: from [84.59.143.167] (helo=[192.168.2.108]) by www17.your-server.de with esmtpsa (SSLv3:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1Qpf1g-0004nI-9i; Sat, 06 Aug 2011 13:26:44 +0200 Subject: [PATCH] arm: mach-davinci: use kzalloc() From: Thomas Meyer To: Russell King , linux-arm-kernel@lists.infradead.org, Linux Kernel Mailing List Date: Sat, 06 Aug 2011 13:26:13 +0200 X-Mailer: Evolution 3.0.2 (3.0.2-3.fc15) Message-ID: <1312629976.5589.128.camel@localhost.localdomain> Mime-Version: 1.0 X-Authenticated-Sender: thomas@m3y3r.de X-Virus-Scanned: Clear (ClamAV 0.97.2/13408/Sat Aug 6 10:47:58 2011) X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110806_072652_184597_94A2E3E6 X-CRM114-Status: UNSURE ( 8.12 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Sat, 06 Aug 2011 11:27:33 +0000 (UTC) From: Thomas Meyer Use kzalloc rather than kmalloc followed by memset with 0 This considers some simple cases that are common and easy to validate Note in particular that there are no ...s in the rule, so all of the matched code has to be contiguous The semantic patch that makes this output is available in scripts/coccinelle/api/alloc/kzalloc-simple.cocci. More information about semantic patching is available at http://coccinelle.lip6.fr/ Signed-off-by: Thomas Meyer diff -u -p a/arch/arm/mach-davinci/dma.c b/arch/arm/mach-davinci/dma.c --- a/arch/arm/mach-davinci/dma.c 2010-10-26 18:50:12.713889353 +0200 +++ b/arch/arm/mach-davinci/dma.c 2011-08-01 20:40:38.326583216 +0200 @@ -1435,12 +1435,11 @@ static int __init edma_probe(struct plat goto fail1; } - edma_cc[j] = kmalloc(sizeof(struct edma), GFP_KERNEL); + edma_cc[j] = kzalloc(sizeof(struct edma), GFP_KERNEL); if (!edma_cc[j]) { status = -ENOMEM; goto fail1; } - memset(edma_cc[j], 0, sizeof(struct edma)); edma_cc[j]->num_channels = min_t(unsigned, info[j]->n_channel, EDMA_MAX_DMACH);