linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russell King <rmk+kernel@arm.linux.org.uk>
To: linux-arm-kernel@lists.infradead.org
Cc: Jason Cooper <jason@lakedaemon.net>,
	Wolfram Sang <wsa@the-dreams.de>,
	"Mark A. Greer" <mgreer@animalcreek.com>,
	linux-i2c@vger.kernel.org,
	"Ben Dooks (embedded platforms)" <ben-linux@fluff.org>,
	Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Subject: [PATCH 5/9] I2C: mv64xxx: use devm_kzalloc()
Date: Thu, 16 May 2013 21:35:10 +0100	[thread overview]
Message-ID: <E1Ud4tK-0004Jo-Ik@rmk-PC.arm.linux.org.uk> (raw)
In-Reply-To: <20130516202921.GW18614@n2100.arm.linux.org.uk>

As we're changing to using devm_* APIs to fix various problems
in this driver, lets also do devm_kzalloc() while we're here too.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 drivers/i2c/busses/i2c-mv64xxx.c |   24 ++++++++++--------------
 1 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
index 0b4da77..841792f 100644
--- a/drivers/i2c/busses/i2c-mv64xxx.c
+++ b/drivers/i2c/busses/i2c-mv64xxx.c
@@ -580,16 +580,15 @@ mv64xxx_i2c_probe(struct platform_device *pd)
 	if ((!pdata && !pd->dev.of_node))
 		return -ENODEV;
 
-	drv_data = kzalloc(sizeof(struct mv64xxx_i2c_data), GFP_KERNEL);
+	drv_data = devm_kzalloc(&pd->dev, sizeof(struct mv64xxx_i2c_data),
+				GFP_KERNEL);
 	if (!drv_data)
 		return -ENOMEM;
 
 	r = platform_get_resource(pd, IORESOURCE_MEM, 0);
 	drv_data->reg_base = devm_ioremap_resource(&pd->dev, r);
-	if (IS_ERR(drv_data->reg_base)) {
-		rc = PTR_ERR(drv_data->reg_base);
-		goto exit_kfree;
-	}
+	if (IS_ERR(drv_data->reg_base))
+		return PTR_ERR(drv_data->reg_base);
 
 	strlcpy(drv_data->adapter.name, MV64XXX_I2C_CTLR_NAME " adapter",
 		sizeof(drv_data->adapter.name));
@@ -613,11 +612,11 @@ mv64xxx_i2c_probe(struct platform_device *pd)
 	} else if (pd->dev.of_node) {
 		rc = mv64xxx_of_config(drv_data, pd->dev.of_node);
 		if (rc)
-			goto exit_unmap_regs;
+			goto exit_clk;
 	}
 	if (drv_data->irq < 0) {
 		rc = -ENXIO;
-		goto exit_unmap_regs;
+		goto exit_clk;
 	}
 
 	drv_data->adapter.dev.parent = &pd->dev;
@@ -637,7 +636,7 @@ mv64xxx_i2c_probe(struct platform_device *pd)
 			"mv64xxx: Can't register intr handler irq: %d\n",
 			drv_data->irq);
 		rc = -EINVAL;
-		goto exit_unmap_regs;
+		goto exit_clk;
 	} else if ((rc = i2c_add_numbered_adapter(&drv_data->adapter)) != 0) {
 		dev_err(&drv_data->adapter.dev,
 			"mv64xxx: Can't add i2c adapter, rc: %d\n", -rc);
@@ -648,9 +647,9 @@ mv64xxx_i2c_probe(struct platform_device *pd)
 
 	return 0;
 
-	exit_free_irq:
-		free_irq(drv_data->irq, drv_data);
-	exit_unmap_regs:
+exit_free_irq:
+	free_irq(drv_data->irq, drv_data);
+exit_clk:
 #if defined(CONFIG_HAVE_CLK)
 	/* Not all platforms have a clk */
 	if (!IS_ERR(drv_data->clk)) {
@@ -658,8 +657,6 @@ mv64xxx_i2c_probe(struct platform_device *pd)
 		clk_unprepare(drv_data->clk);
 	}
 #endif
-	exit_kfree:
-		kfree(drv_data);
 	return rc;
 }
 
@@ -678,7 +675,6 @@ mv64xxx_i2c_remove(struct platform_device *dev)
 		clk_unprepare(drv_data->clk);
 	}
 #endif
-	kfree(drv_data);
 
 	return rc;
 }
-- 
1.7.4.4

  parent reply	other threads:[~2013-05-16 20:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-16 20:29 [PATCH 0/9] Fix Marvell mv63xxx I2C driver Russell King - ARM Linux
2013-05-16 20:30 ` [PATCH 1/9] I2C: mv64xxx: work around signals causing I2C transactions to be aborted Russell King
     [not found]   ` <E1Ud4pH-0004JQ-Jq-eh5Bv4kxaXIANfyc6IWni62ZND6+EDdj@public.gmane.org>
2013-05-17  6:37     ` Jean-Francois Moine
2013-05-17  8:31       ` Russell King - ARM Linux
2013-05-17 12:17     ` Wolfram Sang
2013-05-17 17:06   ` Mark A. Greer
2013-05-16 20:32 ` [PATCH 2/9] I2C: mv64xxx: use return value from mv64xxx_i2c_map_regs() Russell King
2013-05-16 20:33 ` [PATCH 3/9] I2C: mv64xxx: use devm_ioremap_resource() Russell King
     [not found]   ` <E1Ud4rN-0004Jc-CL-eh5Bv4kxaXIANfyc6IWni62ZND6+EDdj@public.gmane.org>
2013-05-17  9:23     ` Jean-Francois Moine
2013-05-17  9:34       ` Russell King - ARM Linux
2013-05-16 20:34 ` [PATCH 4/9] I2C: mv64xxx: use devm_clk_get() to avoid missing clk_put() Russell King
2013-05-16 20:35 ` Russell King [this message]
2013-05-16 20:36 ` [PATCH 6/9] I2C: mv64xxx: fix error handling for request_irq() Russell King
2013-05-16 20:37 ` [PATCH 7/9] I2C: mv64xxx: remove I2C_M_NOSTART code Russell King
     [not found]   ` <E1Ud4vH-0004Jz-F6-eh5Bv4kxaXIANfyc6IWni62ZND6+EDdj@public.gmane.org>
2013-05-22 19:05     ` Mark Brown
2013-05-16 20:38 ` [PATCH 8/9] I2C: mv64xxx: move mv64xxx_i2c_prepare_for_io() Russell King
2013-05-16 20:39 ` [PATCH 9/9] I2C: mv64xxx: fix race between FSM/interrupt and process context Russell King
     [not found]   ` <E1Ud4xE-0004KB-2T-eh5Bv4kxaXIANfyc6IWni62ZND6+EDdj@public.gmane.org>
2013-05-17  9:51     ` Wolfram Sang
2013-05-17 10:00       ` Russell King - ARM Linux
     [not found]         ` <20130517100016.GB18614-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2013-05-17 12:15           ` Wolfram Sang
     [not found] ` <20130516202921.GW18614-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2013-06-05 21:48   ` [PATCH 0/9] Fix Marvell mv63xxx I2C driver Wolfram Sang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1Ud4tK-0004Jo-Ik@rmk-PC.arm.linux.org.uk \
    --to=rmk+kernel@arm.linux.org.uk \
    --cc=ben-linux@fluff.org \
    --cc=jason@lakedaemon.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=mgreer@animalcreek.com \
    --cc=sebastian.hesselbarth@gmail.com \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).