mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: linux-kernel@vger.kernel.org, sameo@linux.intel.com
Cc: Lee Jones <lee.jones@linaro.org>
Subject: [PATCH 09/16] mfd: cros_ec: Convert to managed resources for allocating memory
Date: Thu, 23 May 2013 16:25:10 +0100	[thread overview]
Message-ID: <1369322717-30429-9-git-send-email-lee.jones@linaro.org> (raw)
In-Reply-To: <1369322717-30429-1-git-send-email-lee.jones@linaro.org>

Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/mfd/cros_ec.c |   28 +++++++++-------------------
 1 file changed, 9 insertions(+), 19 deletions(-)

diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c
index 10cd14e..1f36885 100644
--- a/drivers/mfd/cros_ec.c
+++ b/drivers/mfd/cros_ec.c
@@ -104,23 +104,19 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
 	ec_dev->command_sendrecv = cros_ec_command_sendrecv;
 
 	if (ec_dev->din_size) {
-		ec_dev->din = kmalloc(ec_dev->din_size, GFP_KERNEL);
-		if (!ec_dev->din) {
-			err = -ENOMEM;
-			goto fail_din;
-		}
+		ec_dev->din = devm_kzalloc(dev, ec_dev->din_size, GFP_KERNEL);
+		if (!ec_dev->din)
+			return -ENOMEM;
 	}
 	if (ec_dev->dout_size) {
-		ec_dev->dout = kmalloc(ec_dev->dout_size, GFP_KERNEL);
-		if (!ec_dev->dout) {
-			err = -ENOMEM;
-			goto fail_dout;
-		}
+		ec_dev->dout = devm_kzalloc(dev, ec_dev->dout_size, GFP_KERNEL);
+		if (!ec_dev->dout)
+			return -ENOMEM;
 	}
 
 	if (!ec_dev->irq) {
 		dev_dbg(dev, "no valid IRQ: %d\n", ec_dev->irq);
-		goto fail_irq;
+		return err;
 	}
 
 	err = request_threaded_irq(ec_dev->irq, NULL, ec_irq_thread,
@@ -128,7 +124,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
 				   "chromeos-ec", ec_dev);
 	if (err) {
 		dev_err(dev, "request irq %d: error %d\n", ec_dev->irq, err);
-		goto fail_irq;
+		return err;
 	}
 
 	err = mfd_add_devices(dev, 0, cros_devs,
@@ -145,11 +141,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
 
 fail_mfd:
 	free_irq(ec_dev->irq, ec_dev);
-fail_irq:
-	kfree(ec_dev->dout);
-fail_dout:
-	kfree(ec_dev->din);
-fail_din:
+
 	return err;
 }
 EXPORT_SYMBOL(cros_ec_register);
@@ -158,8 +150,6 @@ int cros_ec_remove(struct cros_ec_device *ec_dev)
 {
 	mfd_remove_devices(ec_dev->dev);
 	free_irq(ec_dev->irq, ec_dev);
-	kfree(ec_dev->dout);
-	kfree(ec_dev->din);
 
 	return 0;
 }
-- 
1.7.10.4


  parent reply	other threads:[~2013-05-23 15:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-23 15:25 [PATCH 01/16] mfd: tps65912: " Lee Jones
2013-05-23 15:25 ` [PATCH 02/16] mfd: 88pm860x: " Lee Jones
2013-05-23 15:25 ` [PATCH 03/16] mfd: ab3100-otp: " Lee Jones
2013-05-23 15:25 ` [PATCH 04/16] mfd: ab8500-debug: " Lee Jones
2013-05-23 15:25 ` [PATCH 05/16] mfd: ab8500-gpadc: " Lee Jones
2013-05-23 15:25 ` [PATCH 06/16] mfd: abx500-core: " Lee Jones
2013-05-23 15:25 ` [PATCH 07/16] mfd: adp5520: " Lee Jones
2013-05-23 15:25 ` [PATCH 08/16] mfd: asic3: " Lee Jones
2013-05-23 15:25 ` Lee Jones [this message]
2013-05-23 15:25 ` [PATCH 10/16] mfd: davinci_voicecodec: " Lee Jones
2013-05-23 15:25 ` [PATCH 11/16] mfd: htc-egpio: " Lee Jones
2013-05-23 15:25 ` [PATCH 12/16] mfd: htc-i2cpld: " Lee Jones
2013-05-23 15:25 ` [PATCH 13/16] mfd: htc-pasic3: " Lee Jones
2013-05-23 15:25 ` [PATCH 14/16] mfd: janz-cmodio: " Lee Jones
2013-05-23 15:25 ` [PATCH 15/16] mfd: max77686: " Lee Jones
2013-05-23 15:25 ` [PATCH 16/16] mfd: max8925: " Lee Jones
2013-06-11 18:19 ` [PATCH 01/16] mfd: tps65912: " Samuel Ortiz

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=1369322717-30429-9-git-send-email-lee.jones@linaro.org \
    --to=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sameo@linux.intel.com \
    /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

all inboxes | Powered by JetHome®