diff mbox

[5/6] leds: lp5521: move to drivers/leds

Message ID 20090213223636.GP10711@frodo (mailing list archive)
State Awaiting Upstream, archived
Headers show

Commit Message

Felipe Balbi Feb. 13, 2009, 10:36 p.m. UTC
On Fri, Feb 13, 2009 at 12:49:00PM -0800, David Brownell wrote:
> On Friday 13 February 2009, Felipe Balbi wrote:
> > +       if (!strncmp(buf, "run", 3))
> > +               lp5521_set_mode(chip, LP5521_MODE_RUN);
> > +       else if (!strncmp(buf, "load", 4))
> > +               lp5521_set_mode(chip, LP5521_MODE_LOAD);
> > +       else if (!strncmp(buf, "direct", 6))
> > +               lp5521_set_mode(chip, LP5521_MODE_DIRECT_CONTROL);
> 
> Minor nit, which could be addressed by a followon patch:
> This is an ideal use-case for using sysfs_streq().
> 
> And there's no terminal "else len = -EINVAL" to handle the
> case of illegal modes...

Ok, here's an *untested* patch solving issues.

Comments

David Brownell Feb. 13, 2009, 11:54 p.m. UTC | #1
On Friday 13 February 2009, Felipe Balbi wrote:
> From: Felipe Balbi <felipe.balbi@nokia.com>
> Date: Sat, 14 Feb 2009 00:34:56 +0200
> Subject: [PATCH] leds: lp5521: use sysfs_streq()
> 
> instead of using strcmp() for comparing strings,
> use sysfs_streq().
> 
> Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>

Yes, just like that.


> ---
>  drivers/leds/leds-lp5521.c |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
> index b3ba52a..3e1ca31 100644
> --- a/drivers/leds/leds-lp5521.c
> +++ b/drivers/leds/leds-lp5521.c
> @@ -352,12 +352,14 @@ static ssize_t store_mode(struct device *dev,
>  
>         mutex_lock(&chip->lock);
>  
> -       if (!strncmp(buf, "run", 3))
> +       if (sysfs_streq(buf, "run"))
>                 lp5521_set_mode(chip, LP5521_MODE_RUN);
> -       else if (!strncmp(buf, "load", 4))
> +       else if (sysfs_streq(buf, "load"))
>                 lp5521_set_mode(chip, LP5521_MODE_LOAD);
> -       else if (!strncmp(buf, "direct", 6))
> +       else if (sysfs_streq(buf, "direct"))
>                 lp5521_set_mode(chip, LP5521_MODE_DIRECT_CONTROL);
> +       else
> +               len = -EINVAL;
>  
>         mutex_unlock(&chip->lock);
>  
> --


--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Felipe Balbi Feb. 14, 2009, 12:07 a.m. UTC | #2
On Fri, 13 Feb 2009 15:54:20 -0800, David Brownell <david-b@pacbell.net>
wrote:
> On Friday 13 February 2009, Felipe Balbi wrote:
>> From: Felipe Balbi <felipe.balbi@nokia.com>
>> Date: Sat, 14 Feb 2009 00:34:56 +0200
>> Subject: [PATCH] leds: lp5521: use sysfs_streq()
>>
>> instead of using strcmp() for comparing strings,
>> use sysfs_streq().
>>
>> Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
> 
> Yes, just like that.

Good, so we can apply these to l-o and I'll send the
driver upstream after these patches are applied.

Same for lm8323

> 
> 
>> ---
>>  drivers/leds/leds-lp5521.c |    8 +++++---
>>  1 files changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
>> index b3ba52a..3e1ca31 100644
>> --- a/drivers/leds/leds-lp5521.c
>> +++ b/drivers/leds/leds-lp5521.c
>> @@ -352,12 +352,14 @@ static ssize_t store_mode(struct device *dev,
>>  
>>         mutex_lock(&chip->lock);
>>  
>> -       if (!strncmp(buf, "run", 3))
>> +       if (sysfs_streq(buf, "run"))
>>                 lp5521_set_mode(chip, LP5521_MODE_RUN);
>> -       else if (!strncmp(buf, "load", 4))
>> +       else if (sysfs_streq(buf, "load"))
>>                 lp5521_set_mode(chip, LP5521_MODE_LOAD);
>> -       else if (!strncmp(buf, "direct", 6))
>> +       else if (sysfs_streq(buf, "direct"))
>>                 lp5521_set_mode(chip,
> LP5521_MODE_DIRECT_CONTROL);
>> +       else
>> +               len = -EINVAL;
>>  
>>         mutex_unlock(&chip->lock);
>>  
>> --
diff mbox

Patch

========== cut here ==========
From 0872878daaa4a1768a3f56995ec416941758be6b Mon Sep 17 00:00:00 2001
From: Felipe Balbi <felipe.balbi@nokia.com>
Date: Sat, 14 Feb 2009 00:34:56 +0200
Subject: [PATCH] leds: lp5521: use sysfs_streq()

instead of using strcmp() for comparing strings,
use sysfs_streq().

Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
---
 drivers/leds/leds-lp5521.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index b3ba52a..3e1ca31 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -352,12 +352,14 @@  static ssize_t store_mode(struct device *dev,
 
 	mutex_lock(&chip->lock);
 
-	if (!strncmp(buf, "run", 3))
+	if (sysfs_streq(buf, "run"))
 		lp5521_set_mode(chip, LP5521_MODE_RUN);
-	else if (!strncmp(buf, "load", 4))
+	else if (sysfs_streq(buf, "load"))
 		lp5521_set_mode(chip, LP5521_MODE_LOAD);
-	else if (!strncmp(buf, "direct", 6))
+	else if (sysfs_streq(buf, "direct"))
 		lp5521_set_mode(chip, LP5521_MODE_DIRECT_CONTROL);
+	else
+		len = -EINVAL;
 
 	mutex_unlock(&chip->lock);