From patchwork Thu Jan 3 13:22:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 1927761 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from devils.ext.ti.com (devils.ext.ti.com [198.47.26.153]) by patchwork1.kernel.org (Postfix) with ESMTP id F1D023FC33 for ; Thu, 3 Jan 2013 13:27:48 +0000 (UTC) Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id r03DO6xq006030; Thu, 3 Jan 2013 07:24:06 -0600 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id r03DO6Ix020877; Thu, 3 Jan 2013 07:24:06 -0600 Received: from dlelxv24.itg.ti.com (172.17.1.199) by dfle72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.1.323.3; Thu, 3 Jan 2013 07:24:05 -0600 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dlelxv24.itg.ti.com (8.13.8/8.13.8) with ESMTP id r03DO5GM005255; Thu, 3 Jan 2013 07:24:05 -0600 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 9875E80626; Thu, 3 Jan 2013 07:24:05 -0600 (CST) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp53.itg.ti.com (dflp53.itg.ti.com [128.247.5.6]) by linux.omap.com (Postfix) with ESMTP id 68F1B80626 for ; Thu, 3 Jan 2013 07:24:03 -0600 (CST) Received: from red.ext.ti.com (red.ext.ti.com [192.94.93.37]) by dflp53.itg.ti.com (8.13.8/8.13.8) with ESMTP id r03DO3a1001818 for ; Thu, 3 Jan 2013 07:24:03 -0600 (CST) Received: from psmtp.com (na3sys009amx177.postini.com [74.125.149.158]) by red.ext.ti.com (8.13.7/8.13.7) with SMTP id r03DO2BV017683 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 3 Jan 2013 07:24:02 -0600 Received: from mail-da0-f54.google.com ([209.85.210.54]) (using TLSv1) by na3sys009amx177.postini.com ([74.125.148.10]) with SMTP; Thu, 03 Jan 2013 13:24:02 GMT Received: by mail-da0-f54.google.com with SMTP id n2so6985747dad.27 for ; Thu, 03 Jan 2013 05:24:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=S5iOuCOTK60tRYQxcKEYMfOzaoTIyjL0xhiEfZeQ51c=; b=GB+iqGjnq6TNA2A4AnyeFAcJEdJlSe48qXPBDFTXAfkAfXtZp39KogZ+OP0N72wUs/ gHJzGIKre4s6PEL1/MQ9XMUnk93e7GAlYQME5UW+CO9gbuVY+wehFN5kakRJIYqMhklI oHBT6/gX0RP/XRlppwYd+zdwyBIsWxnTC3IDHo2LhTk8BAeGI6n2RxkwVvT7xyXr/zL1 +6q5yBwPDrq8/mBAduQdx7M5m8X7p5YAvsh8qz2PEPvT6C2Wne1ZuWy745JOSlWLUvUS 7ubZ8C7AUmYRame+TYXjy3bDNU50ufg7nJpMhOB9VHERruS0YzIq5cKY2vXo174obVE2 Bjmg== X-Received: by 10.68.130.161 with SMTP id of1mr134294891pbb.32.1357219441913; Thu, 03 Jan 2013 05:24:01 -0800 (PST) Received: from localhost.localdomain ([122.166.13.141]) by mx.google.com with ESMTPS id ix9sm30343226pbc.7.2013.01.03.05.23.58 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 03 Jan 2013 05:24:01 -0800 (PST) From: "Lad, Prabhakar" To: LMML Subject: [PATCH] tvp7002: use devm_kzalloc() instead of kzalloc() Date: Thu, 3 Jan 2013 18:52:42 +0530 Message-ID: <1357219362-9080-4-git-send-email-prabhakar.lad@ti.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1357219362-9080-1-git-send-email-prabhakar.lad@ti.com> References: <1357219362-9080-1-git-send-email-prabhakar.lad@ti.com> X-pstn-neptune: 1/1/1.00/100 X-pstn-levels: (S: 7.55172/99.90000 CV:99.9000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) X-pstn-dkim: 1 skipped:no-policies X-pstn-settings: 2 (0.5000:0.0050) s cv GT3 gt2 gt1 r p m c X-pstn-addresses: from [82/3] CC: DLOS , LKML , Hans Verkuil , Mauro Carvalho Chehab X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com I2C drivers can use devm_kzalloc() too in their .probe() methods. Doing so simplifies their clean up paths. Signed-off-by: Lad, Prabhakar Signed-off-by: Manjunath Hadli --- drivers/media/i2c/tvp7002.c | 10 ++-------- 1 files changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c index fb6a5b5..2d4c86e 100644 --- a/drivers/media/i2c/tvp7002.c +++ b/drivers/media/i2c/tvp7002.c @@ -1036,7 +1036,7 @@ static int tvp7002_probe(struct i2c_client *c, const struct i2c_device_id *id) return -ENODEV; } - device = kzalloc(sizeof(struct tvp7002), GFP_KERNEL); + device = devm_kzalloc(&c->dev, sizeof(struct tvp7002), GFP_KERNEL); if (!device) return -ENOMEM; @@ -1088,17 +1088,12 @@ static int tvp7002_probe(struct i2c_client *c, const struct i2c_device_id *id) V4L2_CID_GAIN, 0, 255, 1, 0); sd->ctrl_handler = &device->hdl; if (device->hdl.error) { - int err = device->hdl.error; - v4l2_ctrl_handler_free(&device->hdl); - kfree(device); - return err; + return device->hdl.error; } v4l2_ctrl_handler_setup(&device->hdl); found_error: - if (error < 0) - kfree(device); return error; } @@ -1120,7 +1115,6 @@ static int tvp7002_remove(struct i2c_client *c) v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(&device->hdl); - kfree(device); return 0; }