From patchwork Fri Jan 4 05:11:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 1930941 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 1E6653FDDA for ; Fri, 4 Jan 2013 05:12:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751513Ab3ADFLu (ORCPT ); Fri, 4 Jan 2013 00:11:50 -0500 Received: from mail-da0-f45.google.com ([209.85.210.45]:57057 "EHLO mail-da0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750899Ab3ADFLr (ORCPT ); Fri, 4 Jan 2013 00:11:47 -0500 Received: by mail-da0-f45.google.com with SMTP id w4so7296973dam.18 for ; Thu, 03 Jan 2013 21:11:46 -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=G2NJQ5cCjpAytQ06R3UAx4FzEgYr1VpwT1c66DVlz7c=; b=FIwpYzM+lo6QN1+8p2l/GEflKVp6ndiA6RMUIoH7OpUjXGPpGv8F4+Z6ayl4oaS4r0 W+xiKfDY/zAe6G5o1FO1LHP9JldZ//bygdkJz1gSzf86QiZMcLqaPfRMhB/YE82K0rX4 WidD+N13GP2UCHkq4JczG057BXL/mjiWwMVwiE21pvQ1ZqmT6Zk12F0xMbw+ZVE2jOs2 A4G/Mk1zbh/RIZq/gLoRetS7L3VQqb5TCa2OewXWn5qTROkzF+TvBJyP1fvBNQnCz850 HkKW5/o4ykBELM595q7WoYD5ZuGaXdvhOKyXRCTO/PrDZClybKXZWoVdKv1za+M1nQTG 7J5Q== X-Received: by 10.68.130.225 with SMTP id oh1mr13865750pbb.147.1357276306160; Thu, 03 Jan 2013 21:11:46 -0800 (PST) Received: from localhost.localdomain ([122.166.13.141]) by mx.google.com with ESMTPS id w5sm32501182pax.28.2013.01.03.21.11.38 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 03 Jan 2013 21:11:45 -0800 (PST) From: "Lad, Prabhakar" To: LMML Cc: LKML , Mauro Carvalho Chehab , Laurent Pinchart , Hans Verkuil , "Lad, Prabhakar" , Manjunath Hadli Subject: [PATCH v2] tvp514x: use devm_kzalloc() instead of kzalloc() Date: Fri, 4 Jan 2013 10:41:16 +0530 Message-Id: <1357276277-21812-2-git-send-email-prabhakar.lad@ti.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1357276277-21812-1-git-send-email-prabhakar.lad@ti.com> References: <1357276277-21812-1-git-send-email-prabhakar.lad@ti.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 --- Changes for v2: 1: Fixed comments pointed out by Laurent. drivers/media/i2c/tvp514x.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c index d5e1021..aa94ebc 100644 --- a/drivers/media/i2c/tvp514x.c +++ b/drivers/media/i2c/tvp514x.c @@ -951,7 +951,7 @@ tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id) return -ENODEV; } - decoder = kzalloc(sizeof(*decoder), GFP_KERNEL); + decoder = devm_kzalloc(&client->dev, sizeof(*decoder), GFP_KERNEL); if (!decoder) return -ENOMEM; @@ -998,7 +998,6 @@ tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id) int err = decoder->hdl.error; v4l2_ctrl_handler_free(&decoder->hdl); - kfree(decoder); return err; } v4l2_ctrl_handler_setup(&decoder->hdl); @@ -1023,7 +1022,6 @@ static int tvp514x_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(&decoder->hdl); - kfree(decoder); return 0; } /* TVP5146 Init/Power on Sequence */