From patchwork Sat Aug 25 17:41:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 179981 X-Patchwork-Delegate: galak@kernel.crashing.org Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 971142C0336 for ; Sun, 26 Aug 2012 03:42:39 +1000 (EST) Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "smtp.inria.fr", Issuer "TERENA SSL CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 433022C00D5 for ; Sun, 26 Aug 2012 03:41:48 +1000 (EST) X-IronPort-AV: E=Sophos;i="4.80,311,1344204000"; d="scan'208";a="170801701" Received: from palace.lip6.fr (HELO localhost.localdomain) ([132.227.105.202]) by mail1-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 25 Aug 2012 19:41:44 +0200 From: Julia Lawall To: Jochen Friedrich Subject: [PATCH 1/6] i2c: cpm: use devm_ functions Date: Sat, 25 Aug 2012 19:41:34 +0200 Message-Id: <1345916499-6657-1-git-send-email-Julia.Lawall@lip6.fr> X-Mailer: git-send-email 1.7.8.6 Cc: kernel-janitors@vger.kernel.org, "Wolfram Sang \(embedded platforms\)" , linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, "Ben Dooks \(embedded platforms\)" , "Jean Delvare \(PC drivers, core\)" , linuxppc-dev@lists.ozlabs.org X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Julia Lawall The various devm_ functions allocate memory that is released when a driver detaches. This patch uses these functions for data that is allocated in the probe function of a platform device and is only freed in the remove function. Signed-off-by: Julia Lawall --- Not compiled. drivers/i2c/busses/i2c-cpm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c index c1e1096..ec97415 100644 --- a/drivers/i2c/busses/i2c-cpm.c +++ b/drivers/i2c/busses/i2c-cpm.c @@ -640,7 +640,7 @@ static int __devinit cpm_i2c_probe(struct platform_device *ofdev) struct cpm_i2c *cpm; const u32 *data; - cpm = kzalloc(sizeof(struct cpm_i2c), GFP_KERNEL); + cpm = devm_kzalloc(&ofdev->dev, sizeof(struct cpm_i2c), GFP_KERNEL); if (!cpm) return -ENOMEM; @@ -683,7 +683,6 @@ out_shut: cpm_i2c_shutdown(cpm); out_free: dev_set_drvdata(&ofdev->dev, NULL); - kfree(cpm); return result; } @@ -697,7 +696,6 @@ static int __devexit cpm_i2c_remove(struct platform_device *ofdev) cpm_i2c_shutdown(cpm); dev_set_drvdata(&ofdev->dev, NULL); - kfree(cpm); return 0; }