From patchwork Mon May 26 21:32:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himangi Saraogi X-Patchwork-Id: 352628 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 1C420140082 for ; Tue, 27 May 2014 07:32:18 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751454AbaEZVcR (ORCPT ); Mon, 26 May 2014 17:32:17 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:45899 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751231AbaEZVcQ (ORCPT ); Mon, 26 May 2014 17:32:16 -0400 Received: by mail-pa0-f45.google.com with SMTP id ey11so8054273pad.18 for ; Mon, 26 May 2014 14:32:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=HJa5APCsV3EXeQYe/cJK2rYLkJB9LGFSRHhMAFwEBA4=; b=EB1kNi6ubIQxSaE80/qCxEu03VR0mftEmJAX7KUQQW3rtAgAWZ3mj732dCgKaIdmQX AbDdq7mlDrX5OqEypITZNe3pY170I3jNkYupQJvrYuB/G80MUOhi+IdEJmm2AliQMJcI WrvKtuofezWwbsJCLfM/jCg7MjTkZdCnehHrh/ehPusvOn2m7vzY0Aq6RjgcUEpWFm4l 4uRyX3LSrhRJa0mg736UQzxE59qRPlJgaUBXg2cC+4+7bFLVmtt8exEw0cESX2AcN41M 6LhAq8sqcQxuvVmVzR7Zg+O/FT6SYgR1ARR3iFRye0RoBAORbwC3wtAzvT7qjv6fV2O9 tDAg== X-Received: by 10.66.142.233 with SMTP id rz9mr31282543pab.71.1401139935960; Mon, 26 May 2014 14:32:15 -0700 (PDT) Received: from localhost ([122.178.79.171]) by mx.google.com with ESMTPSA id jq6sm19780424pbb.76.2014.05.26.14.32.12 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 26 May 2014 14:32:14 -0700 (PDT) Date: Tue, 27 May 2014 03:02:07 +0530 From: Himangi Saraogi To: "David S. Miller" , sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org Cc: julia.lawall@lip6.fr, Sam Ravnborg Subject: [PATCH] display7seg: Introduce the use of the managed version of kzalloc Message-ID: <20140526213207.GA1815@himangi-Dell> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: sparclinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: sparclinux@vger.kernel.org This patch moves data allocated using kzalloc to managed data allocated using devm_kzalloc and cleans now unnecessary kfrees in probe and remove functions. The header file is added to make the devm function explicitly available. The following Coccinelle semantic patch was used for making a part of the change: @platform@ identifier p, probefn, removefn; @@ struct platform_driver p = { .probe = probefn, .remove = removefn, }; @prb@ identifier platform.probefn, pdev; expression e, e1, e2; @@ probefn(struct platform_device *pdev, ...) { <+... - e = kzalloc(e1, e2) + e = devm_kzalloc(&pdev->dev, e1, e2) ... ?-kfree(e); ...+> } @rem depends on prb@ identifier platform.removefn; expression e; @@ removefn(...) { <... - kfree(e); ...> } Signed-off-by: Himangi Saraogi Acked-by: Julia Lawall Acked-by: Sam Ravnborg --- Not compile tested due to incompatible architecture. drivers/sbus/char/display7seg.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/sbus/char/display7seg.c b/drivers/sbus/char/display7seg.c index 7c71e7b..b48899c 100644 --- a/drivers/sbus/char/display7seg.c +++ b/drivers/sbus/char/display7seg.c @@ -4,6 +4,7 @@ * Copyright (c) 2000 Eric Brower (ebrower@usa.net) */ +#include #include #include #include @@ -180,7 +181,7 @@ static int d7s_probe(struct platform_device *op) if (d7s_device) goto out; - p = kzalloc(sizeof(*p), GFP_KERNEL); + p = devm_kzalloc(&op->dev, sizeof(*p), GFP_KERNEL); err = -ENOMEM; if (!p) goto out; @@ -231,7 +232,6 @@ out_iounmap: of_iounmap(&op->resource[0], p->regs, sizeof(u8)); out_free: - kfree(p); goto out; } @@ -251,7 +251,6 @@ static int d7s_remove(struct platform_device *op) misc_deregister(&d7s_miscdev); of_iounmap(&op->resource[0], p->regs, sizeof(u8)); - kfree(p); return 0; }