public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <jhovold@gmail.com>
To: Samuel Ortiz <sameo@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, Johan Hovold <jhovold@gmail.com>
Subject: [PATCH] mfd: lm3533: convert to use devres
Date: Tue, 15 May 2012 19:24:53 +0200	[thread overview]
Message-ID: <1337102693-30911-1-git-send-email-jhovold@gmail.com> (raw)

Use devres to manage core driver data and regmap.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
---
 drivers/mfd/lm3533-core.c |   22 +++++-----------------
 1 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/drivers/mfd/lm3533-core.c b/drivers/mfd/lm3533-core.c
index 5770bea..104faba 100644
--- a/drivers/mfd/lm3533-core.c
+++ b/drivers/mfd/lm3533-core.c
@@ -603,33 +603,24 @@ static int __devinit lm3533_i2c_probe(struct i2c_client *i2c,
 
 	dev_dbg(&i2c->dev, "%s\n", __func__);
 
-	lm3533 = kzalloc(sizeof(*lm3533), GFP_KERNEL);
+	lm3533 = devm_kzalloc(&i2c->dev, sizeof(*lm3533), GFP_KERNEL);
 	if (!lm3533)
 		return -ENOMEM;
 
 	i2c_set_clientdata(i2c, lm3533);
 
-	lm3533->regmap = regmap_init_i2c(i2c, &regmap_config);
-	if (IS_ERR(lm3533->regmap)) {
-		ret = PTR_ERR(lm3533->regmap);
-		goto err_regmap;
-	}
+	lm3533->regmap = devm_regmap_init_i2c(i2c, &regmap_config);
+	if (IS_ERR(lm3533->regmap))
+		return PTR_ERR(lm3533->regmap);
 
 	lm3533->dev = &i2c->dev;
 	lm3533->irq = i2c->irq;
 
 	ret = lm3533_device_init(lm3533);
 	if (ret)
-		goto err_dev;
+		return ret;
 
 	return 0;
-
-err_dev:
-	regmap_exit(lm3533->regmap);
-err_regmap:
-	kfree(lm3533);
-
-	return ret;
 }
 
 static int __devexit lm3533_i2c_remove(struct i2c_client *i2c)
@@ -639,9 +630,6 @@ static int __devexit lm3533_i2c_remove(struct i2c_client *i2c)
 	dev_dbg(&i2c->dev, "%s\n", __func__);
 
 	lm3533_device_exit(lm3533);
-	regmap_exit(lm3533->regmap);
-
-	kfree(lm3533);
 
 	return 0;
 }
-- 
1.7.8.5


             reply	other threads:[~2012-05-15 17:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-15 17:24 Johan Hovold [this message]
2012-05-18 10:37 ` [PATCH] mfd: lm3533: convert to use devres 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=1337102693-30911-1-git-send-email-jhovold@gmail.com \
    --to=jhovold@gmail.com \
    --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