From patchwork Sun May 25 10:40:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: HIMANGI SARAOGI X-Patchwork-Id: 4238321 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 83F7A9F32B for ; Sun, 25 May 2014 10:40:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 80CA32028D for ; Sun, 25 May 2014 10:40:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9EE7E20265 for ; Sun, 25 May 2014 10:40:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751424AbaEYKko (ORCPT ); Sun, 25 May 2014 06:40:44 -0400 Received: from mail-pb0-f53.google.com ([209.85.160.53]:59246 "EHLO mail-pb0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751342AbaEYKkn (ORCPT ); Sun, 25 May 2014 06:40:43 -0400 Received: by mail-pb0-f53.google.com with SMTP id md12so6254925pbc.12 for ; Sun, 25 May 2014 03:40:42 -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=722J9LggtGTpBfcamOsPrHdpT0pBZHxC346fqSoc8II=; b=YfHiVGvZC4MCT8aFddIYqgO65FuMSrufneKexKEPMu/ZQ2qsCNEV6ppSAAlIA2RU0G JCyrrM6Ob8WwjOGVyvV7L2qIj/YI6v6ix9qz5K8ufHeBsKRqgSd0R3fH1nWMMLpPwoMr EfLDoBYGj5X1B4741iuiO08R7edb4ZyT5T2BMBYTB85JUyEn9IB0TqaRmnU9f2oCWYpF dqN6PpLjGiWfD9VYk/cZW6Ih3hqqZAeEq5nc+i6bX0/Y7QXTmR5JNGtNRroWnGbJriV2 bGzZIdMptGtmjdvPcdz9Y6Tx5bpxbIfGl4Q5W6EsNhxSP2VXPQb2Pp2JqmmB+G6VYyNr 8X3A== X-Received: by 10.67.1.39 with SMTP id bd7mr20057975pad.15.1401014442836; Sun, 25 May 2014 03:40:42 -0700 (PDT) Received: from localhost ([122.178.77.12]) by mx.google.com with ESMTPSA id iq10sm13056368pbc.14.2014.05.25.03.40.39 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 25 May 2014 03:40:41 -0700 (PDT) Date: Sun, 25 May 2014 16:10:35 +0530 From: Himangi Saraogi To: Jean-Christophe Plagniol-Villard , Tomi Valkeinen , linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: julia.lawall@lip6.fr Subject: [PATCH] video: Introduce the use of the managed version of kzalloc Message-ID: <20140525104035.GA3187@himangi-Dell> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch moves data allocated using kzalloc to managed data allocated using devm_kzalloc and cleans now unnecessary kfrees in probe and remove functions. Also, linux/device.h is added to make sure the devm_*() routine declarations are unambiguously available. The function mddi_dummy_remove is removed as it is no longer required after removing the kfree. The variable ret is also done away with. 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 --- drivers/video/fbdev/msm/mddi_client_dummy.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/drivers/video/fbdev/msm/mddi_client_dummy.c b/drivers/video/fbdev/msm/mddi_client_dummy.c index f1b0dfc..cdb8f69 100644 --- a/drivers/video/fbdev/msm/mddi_client_dummy.c +++ b/drivers/video/fbdev/msm/mddi_client_dummy.c @@ -15,6 +15,7 @@ * GNU General Public License for more details. */ +#include #include #include #include @@ -51,8 +52,7 @@ static int mddi_dummy_probe(struct platform_device *pdev) { struct msm_mddi_client_data *client_data = pdev->dev.platform_data; struct panel_info *panel = - kzalloc(sizeof(struct panel_info), GFP_KERNEL); - int ret; + devm_kzalloc(&pdev->dev, sizeof(struct panel_info), GFP_KERNEL); if (!panel) return -ENOMEM; platform_set_drvdata(pdev, panel); @@ -67,24 +67,11 @@ static int mddi_dummy_probe(struct platform_device *pdev) client_data->fb_resource, 1); panel->panel_data.fb_data = client_data->private_client_data; panel->pdev.dev.platform_data = &panel->panel_data; - ret = platform_device_register(&panel->pdev); - if (ret) { - kfree(panel); - return ret; - } - return 0; -} - -static int mddi_dummy_remove(struct platform_device *pdev) -{ - struct panel_info *panel = platform_get_drvdata(pdev); - kfree(panel); - return 0; + return platform_device_register(&panel->pdev); } static struct platform_driver mddi_client_dummy = { .probe = mddi_dummy_probe, - .remove = mddi_dummy_remove, .driver = { .name = "mddi_c_dummy" }, };