public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Wolfram Sang <w.sang@pengutronix.de>
To: Antonio Ospite <ospite@studenti.unina.it>
Cc: Axel Lin <axel.lin@gmail.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Richard Purdie <rpurdie@linux.intel.com>
Subject: Re: [PATCH] leds-lp3944: properly handle lp3944_configure fail in lp3944_probe
Date: Mon, 17 May 2010 11:24:57 +0200	[thread overview]
Message-ID: <20100517092457.GD22781@pengutronix.de> (raw)
In-Reply-To: <20100517111513.f76c0bb9.ospite@studenti.unina.it>

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

On Mon, May 17, 2010 at 11:15:13AM +0200, Antonio Ospite wrote:
> On Mon, 17 May 2010 09:34:02 +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.
> >
> 
> Hi Axel, thanks for the fix, I agree it's needed.
> There are some minor comments inlined below.
> 
> Plus, when possible, I prefer commit messages to be wrapped to 72/80
> characters per line. Please, consider this if you are sending a v2.
> 
> Ah, may I ask where you are using this driver? Just curious.
> 
> > Signed-off-by: Axel Lin <axel.lin@gmail.com>
> > ---
> >  drivers/leds/leds-lp3944.c |   10 +++++++++-
> >  1 files changed, 9 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/leds/leds-lp3944.c b/drivers/leds/leds-lp3944.c
> > index 8d5ecce..03a24d0 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");
> > @@ -403,8 +404,15 @@ static int __devinit lp3944_probe(struct i2c_client *client,
> >  
> >  	dev_info(&client->dev, "lp3944 enabled\n");
> >  
> > -	lp3944_configure(client, data, lp3944_pdata);
> > +	err = lp3944_configure(client, data, lp3944_pdata);
> > +	if (err < 0)
> > +		goto err_configure;
> > +
> 
> The dev_info(&client->dev, "lp3944 enabled\n"); could now go right
> here, before the return 0, so we don't report the driver as enabled
> even in the case its probe fails.
> 
> >  	return 0;
> > +
> > +err_configure:
> > +	kfree(data);
> 
> add i2c_set_clientdata(client, NULL) here just like in lp3944_remove()

Just to note:
This is not needed anymore, the i2c-core does this meanwhile for the drivers.
I am preparing a cleanup patch fixing this in all drivers for -rc1.

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

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

  reply	other threads:[~2010-05-17  9:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-17  1:34 [PATCH] leds-lp3944: properly handle lp3944_configure fail in lp3944_probe Axel Lin
2010-05-17  9:15 ` Antonio Ospite
2010-05-17  9:24   ` Wolfram Sang [this message]
2010-05-17  9:52   ` Axel Lin

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=20100517092457.GD22781@pengutronix.de \
    --to=w.sang@pengutronix.de \
    --cc=axel.lin@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ospite@studenti.unina.it \
    --cc=rpurdie@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