public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] mfd: max8997: use devm_*() functions
@ 2013-08-20  7:03 Jingoo Han
  2013-08-20  7:47 ` Lee Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Jingoo Han @ 2013-08-20  7:03 UTC (permalink / raw)
  To: 'Samuel Ortiz', 'Lee Jones'
  Cc: linux-kernel, 'Jingoo Han'

Use devm_*() functions to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
 drivers/mfd/max8997.c |   14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
index 1523047..cee098c 100644
--- a/drivers/mfd/max8997.c
+++ b/drivers/mfd/max8997.c
@@ -191,7 +191,8 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
 	struct max8997_platform_data *pdata = dev_get_platdata(&i2c->dev);
 	int ret = 0;
 
-	max8997 = kzalloc(sizeof(struct max8997_dev), GFP_KERNEL);
+	max8997 = devm_kzalloc(&i2c->dev, sizeof(struct max8997_dev),
+				GFP_KERNEL);
 	if (max8997 == NULL)
 		return -ENOMEM;
 
@@ -203,14 +204,12 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
 
 	if (max8997->dev->of_node) {
 		pdata = max8997_i2c_parse_dt_pdata(max8997->dev);
-		if (IS_ERR(pdata)) {
-			ret = PTR_ERR(pdata);
-			goto err;
-		}
+		if (IS_ERR(pdata))
+			return PTR_ERR(pdata);
 	}
 
 	if (!pdata)
-		goto err;
+		return ret;
 
 	max8997->pdata = pdata;
 	max8997->ono = pdata->ono;
@@ -250,8 +249,6 @@ err_mfd:
 	i2c_unregister_device(max8997->muic);
 	i2c_unregister_device(max8997->haptic);
 	i2c_unregister_device(max8997->rtc);
-err:
-	kfree(max8997);
 	return ret;
 }
 
@@ -263,7 +260,6 @@ static int max8997_i2c_remove(struct i2c_client *i2c)
 	i2c_unregister_device(max8997->muic);
 	i2c_unregister_device(max8997->haptic);
 	i2c_unregister_device(max8997->rtc);
-	kfree(max8997);
 
 	return 0;
 }
-- 
1.7.10.4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/6] mfd: max8997: use devm_*() functions
  2013-08-20  7:03 [PATCH 1/6] mfd: max8997: use devm_*() functions Jingoo Han
@ 2013-08-20  7:47 ` Lee Jones
  0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2013-08-20  7:47 UTC (permalink / raw)
  To: Jingoo Han; +Cc: 'Samuel Ortiz', linux-kernel

> Use devm_*() functions to make cleanup paths simpler.
> 
> Signed-off-by: Jingoo Han <jg1.han@samsung.com>

Patches look good to me 1-6 applied.

By the way, when you're sending patch-sets would you mind adding a
cover letter? Or at least thread patches 2-n on to patch 1. It just
makes them easier to track if they receive comments.

If you don't already, send your patches with `git send-mail` and try
playing around with: --thread (turns on threading) and
--[no-]chain-reply-to (controlls shallow and deep threading) to find
your preference. Cover letters are added with --compose and for
convenience you can annotate them with, surprise surprise --annotate. :)

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-08-20  7:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-20  7:03 [PATCH 1/6] mfd: max8997: use devm_*() functions Jingoo Han
2013-08-20  7:47 ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox