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 15/16] mfd: max77686: Convert to managed resources for allocating memory
Date: Thu, 23 May 2013 16:25:16 +0100	[thread overview]
Message-ID: <1369322717-30429-15-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/max77686.c |   25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c
index 1cbb176..b094ac5 100644
--- a/drivers/mfd/max77686.c
+++ b/drivers/mfd/max77686.c
@@ -84,12 +84,12 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
 		pdata = max77686_i2c_parse_dt_pdata(&i2c->dev);
 
 	if (!pdata) {
-		ret = -EIO;
 		dev_err(&i2c->dev, "No platform data found.\n");
-		goto err;
+		return -EIO;
 	}
 
-	max77686 = kzalloc(sizeof(struct max77686_dev), GFP_KERNEL);
+	max77686 = devm_kzalloc(&i2c->dev,
+				sizeof(struct max77686_dev), GFP_KERNEL);
 	if (max77686 == NULL)
 		return -ENOMEM;
 
@@ -107,7 +107,6 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
 		ret = PTR_ERR(max77686->regmap);
 		dev_err(max77686->dev, "Failed to allocate register map: %d\n",
 				ret);
-		kfree(max77686);
 		return ret;
 	}
 
@@ -115,8 +114,7 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
 			 MAX77686_REG_DEVICE_ID, &data) < 0) {
 		dev_err(max77686->dev,
 			"device not found on this channel (this is not an error)\n");
-		ret = -ENODEV;
-		goto err;
+		return -ENODEV;
 	} else
 		dev_info(max77686->dev, "device found\n");
 
@@ -127,17 +125,11 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
 
 	ret = mfd_add_devices(max77686->dev, -1, max77686_devs,
 			      ARRAY_SIZE(max77686_devs), NULL, 0, NULL);
+	if (ret < 0) {
+		mfd_remove_devices(max77686->dev);
+		i2c_unregister_device(max77686->rtc);
+	}
 
-	if (ret < 0)
-		goto err_mfd;
-
-	return ret;
-
-err_mfd:
-	mfd_remove_devices(max77686->dev);
-	i2c_unregister_device(max77686->rtc);
-err:
-	kfree(max77686);
 	return ret;
 }
 
@@ -147,7 +139,6 @@ static int max77686_i2c_remove(struct i2c_client *i2c)
 
 	mfd_remove_devices(max77686->dev);
 	i2c_unregister_device(max77686->rtc);
-	kfree(max77686);
 
 	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 ` [PATCH 09/16] mfd: cros_ec: " Lee Jones
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 ` Lee Jones [this message]
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-15-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®