From patchwork Thu Jan 3 13:22:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 1927731 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by patchwork2.kernel.org (Postfix) with ESMTP id A5114DF215 for ; Thu, 3 Jan 2013 13:27:05 +0000 (UTC) Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id r03DN5Ox031693; Thu, 3 Jan 2013 07:23:05 -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 r03DN5sG020123; Thu, 3 Jan 2013 07:23:05 -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:23:04 -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 r03DN45Y004821; Thu, 3 Jan 2013 07:23:04 -0600 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 4A6ED80627; Thu, 3 Jan 2013 07:23:04 -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 D78F680626 for ; Thu, 3 Jan 2013 07:23:02 -0600 (CST) Received: from white.ext.ti.com (white.ext.ti.com [192.94.93.38]) by dflp53.itg.ti.com (8.13.8/8.13.8) with ESMTP id r03DN225001607 for ; Thu, 3 Jan 2013 07:23:02 -0600 (CST) Received: from psmtp.com (na3sys009amx220.postini.com [74.125.149.60]) by white.ext.ti.com (8.13.7/8.13.7) with SMTP id r03DN1RW029698 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 3 Jan 2013 07:23:02 -0600 Received: from mail-pb0-f49.google.com ([209.85.160.49]) (using TLSv1) by na3sys009amx220.postini.com ([74.125.148.10]) with SMTP; Thu, 03 Jan 2013 05:23:02 PST Received: by mail-pb0-f49.google.com with SMTP id un15so8552441pbc.36 for ; Thu, 03 Jan 2013 05:23:01 -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; bh=DU+IJTpbRozaPlcmsIWH2o2OQ2KFDFCVWfw2A/fMbeQ=; b=s9p3SIv6m7O2KZ5iSlI+N/s6Ubwl5RZzgcR52zuYh+RkcdAgJbFPdmKZVgksLLSndG LkzavhvsIrdGS+X6UitzLbvlI8w4ePqOHgkdEXwr2Zv+OJoUmw1rKIElW2sUmxp8BlCq /DVGlhdQbXrrhv6+a6HGvo4uIyKCDw5jSktLbSvTmBuFTrKk8VuN18gxkW9xkHpCceDl Ukxkns6BnjfAuPNlKLo2FRzxGEQIU+1N+dSST4d+INgKwGwvqjW+IujqFg4lfR2ENEcp dcKmxPIzVrYIHu9C+C/ddVVFugHNTYWF0YouJbp5jRXx1FUxAXyZapMMhDo/AjzH8ilx 5RgQ== X-Received: by 10.68.131.8 with SMTP id oi8mr152884061pbb.29.1357219381203; Thu, 03 Jan 2013 05:23:01 -0800 (PST) Received: from localhost.localdomain ([122.166.13.141]) by mx.google.com with ESMTPS id ix9sm30343226pbc.7.2013.01.03.05.22.56 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 03 Jan 2013 05:23:00 -0800 (PST) From: "Lad, Prabhakar" To: LMML Subject: [PATCH] adv7343: use devm_kzalloc() instead of kzalloc() Date: Thu, 3 Jan 2013 18:52:39 +0530 Message-ID: <1357219362-9080-1-git-send-email-prabhakar.lad@ti.com> X-Mailer: git-send-email 1.7.4.1 X-pstn-neptune: 0/0/0.00/0 X-pstn-levels: (S: 7.96658/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/adv7343.c | 13 ++++--------- 1 files changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/media/i2c/adv7343.c b/drivers/media/i2c/adv7343.c index 2b5aa67..ceaf548 100644 --- a/drivers/media/i2c/adv7343.c +++ b/drivers/media/i2c/adv7343.c @@ -397,7 +397,8 @@ static int adv7343_probe(struct i2c_client *client, v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); - state = kzalloc(sizeof(struct adv7343_state), GFP_KERNEL); + state = devm_kzalloc(&client->dev, sizeof(struct adv7343_state), + GFP_KERNEL); if (state == NULL) return -ENOMEM; @@ -428,19 +429,14 @@ static int adv7343_probe(struct i2c_client *client, ADV7343_GAIN_DEF); state->sd.ctrl_handler = &state->hdl; if (state->hdl.error) { - int err = state->hdl.error; - v4l2_ctrl_handler_free(&state->hdl); - kfree(state); - return err; + return state->hdl.error; } v4l2_ctrl_handler_setup(&state->hdl); err = adv7343_initialize(&state->sd); - if (err) { + if (err) v4l2_ctrl_handler_free(&state->hdl); - kfree(state); - } return err; } @@ -451,7 +447,6 @@ static int adv7343_remove(struct i2c_client *client) v4l2_device_unregister_subdev(sd); v4l2_ctrl_handler_free(&state->hdl); - kfree(state); return 0; }