public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] leds-lp3944: properly handle lp3944_configure fail in lp3944_probe
@ 2010-05-17  9:47 Axel Lin
  2010-05-17  9:53 ` Wolfram Sang
  2010-05-17 10:15 ` Antonio Ospite
  0 siblings, 2 replies; 4+ messages in thread
From: Axel Lin @ 2010-05-17  9:47 UTC (permalink / raw)
  To: linux-kernel; +Cc: Antonio Ospite, Wolfram Sang, Richard Purdie

In current implementation, lp3944_probe return 0 even if lp3944_configure fail.
Therefore, led_classdev_unregister will be executed twice
( in error handling of lp3944_configure and lp3944_remove ).
This patch properly handles lp3944_configure fail in lp3944_probe.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/leds/leds-lp3944.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/leds/leds-lp3944.c b/drivers/leds/leds-lp3944.c
index 8d5ecce..932a58d 100644
--- a/drivers/leds/leds-lp3944.c
+++ b/drivers/leds/leds-lp3944.c
@@ -379,6 +379,7 @@ static int __devinit lp3944_probe(struct i2c_client *client,
 {
 	struct lp3944_platform_data *lp3944_pdata = client->dev.platform_data;
 	struct lp3944_data *data;
+	int err;
 
 	if (lp3944_pdata == NULL) {
 		dev_err(&client->dev, "no platform data\n");
@@ -401,9 +402,13 @@ static int __devinit lp3944_probe(struct i2c_client *client,
 
 	mutex_init(&data->lock);
 
-	dev_info(&client->dev, "lp3944 enabled\n");
+	err = lp3944_configure(client, data, lp3944_pdata);
+	if (err < 0) {
+		kfree(data);
+		return err;
+	}
 
-	lp3944_configure(client, data, lp3944_pdata);
+	dev_info(&client->dev, "lp3944 enabled\n");
 	return 0;
 }
 
-- 
1.5.4.3




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

* Re: [PATCH v2] leds-lp3944: properly handle lp3944_configure fail in lp3944_probe
  2010-05-17  9:47 [PATCH v2] leds-lp3944: properly handle lp3944_configure fail in lp3944_probe Axel Lin
@ 2010-05-17  9:53 ` Wolfram Sang
  2010-05-17 10:15 ` Antonio Ospite
  1 sibling, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2010-05-17  9:53 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Antonio Ospite, Richard Purdie

[-- Attachment #1: Type: text/plain, Size: 619 bytes --]

On Mon, May 17, 2010 at 05:47:48PM +0800, Axel Lin wrote:
> In current implementation, lp3944_probe return 0 even if lp3944_configure fail.
> Therefore, led_classdev_unregister will be executed twice
> ( in error handling of lp3944_configure and lp3944_remove ).
> This patch properly handles lp3944_configure fail in lp3944_probe.
> 
> Signed-off-by: Axel Lin <axel.lin@gmail.com>

Looks good to me.

Acked-by: Wolfram Sang <w.sang@pengutronix.de>

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: [PATCH v2] leds-lp3944: properly handle lp3944_configure fail in lp3944_probe
  2010-05-17  9:47 [PATCH v2] leds-lp3944: properly handle lp3944_configure fail in lp3944_probe Axel Lin
  2010-05-17  9:53 ` Wolfram Sang
@ 2010-05-17 10:15 ` Antonio Ospite
  2010-05-26 11:31   ` Richard Purdie
  1 sibling, 1 reply; 4+ messages in thread
From: Antonio Ospite @ 2010-05-17 10:15 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Wolfram Sang, Richard Purdie

[-- Attachment #1: Type: text/plain, Size: 772 bytes --]

On Mon, 17 May 2010 17:47:48 +0800
Axel Lin <axel.lin@gmail.com> wrote:

> In current implementation, lp3944_probe return 0 even if lp3944_configure fail.
> Therefore, led_classdev_unregister will be executed twice
> ( in error handling of lp3944_configure and lp3944_remove ).
> This patch properly handles lp3944_configure fail in lp3944_probe.
> 
> Signed-off-by: Axel Lin <axel.lin@gmail.com>

Acked-by: Antonio Ospite <ospite@studenti.unina.it>

Thanks.

-- 
Antonio Ospite
http://ao2.it

PGP public key ID: 0x4553B001

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH v2] leds-lp3944: properly handle lp3944_configure fail in lp3944_probe
  2010-05-17 10:15 ` Antonio Ospite
@ 2010-05-26 11:31   ` Richard Purdie
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Purdie @ 2010-05-26 11:31 UTC (permalink / raw)
  To: Antonio Ospite; +Cc: Axel Lin, linux-kernel, Wolfram Sang

On Mon, 2010-05-17 at 12:15 +0200, Antonio Ospite wrote:
> On Mon, 17 May 2010 17:47:48 +0800
> Axel Lin <axel.lin@gmail.com> wrote:
> 
> > In current implementation, lp3944_probe return 0 even if lp3944_configure fail.
> > Therefore, led_classdev_unregister will be executed twice
> > ( in error handling of lp3944_configure and lp3944_remove ).
> > This patch properly handles lp3944_configure fail in lp3944_probe.
> > 
> > Signed-off-by: Axel Lin <axel.lin@gmail.com>
> 
> Acked-by: Antonio Ospite <ospite@studenti.unina.it>
> 

Queued in the leds tree, thanks.

Richard


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

end of thread, other threads:[~2010-05-26 11:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-17  9:47 [PATCH v2] leds-lp3944: properly handle lp3944_configure fail in lp3944_probe Axel Lin
2010-05-17  9:53 ` Wolfram Sang
2010-05-17 10:15 ` Antonio Ospite
2010-05-26 11:31   ` Richard Purdie

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