All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <me@felipebalbi.com>
To: David Brownell <david-b@pacbell.net>
Cc: Felipe Balbi <felipe.balbi@nokia.com>, linux-omap@vger.kernel.org
Subject: Re: [PATCH 5/6] leds: lp5521: move to drivers/leds
Date: Sat, 14 Feb 2009 00:36:37 +0200	[thread overview]
Message-ID: <20090213223636.GP10711@frodo> (raw)
In-Reply-To: <200902131249.00592.david-b@pacbell.net>

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.

========== 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);
 
-- 
1.6.2.rc0.61.g5cd12


-- 
balbi
--
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

  reply	other threads:[~2009-02-13 22:36 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-10 12:15 [PATCH 0/8] updates to two nokia drivers Felipe Balbi
2009-02-10 12:15 ` [PATCH 1/8] i2c: lp5521: remove dead code Felipe Balbi
2009-02-10 12:15   ` [PATCH 2/8] i2c: lp5521: cosmetic fixes Felipe Balbi
2009-02-10 12:16     ` [PATCH 3/8] i2c: lp5521: simplify mode setting Felipe Balbi
2009-02-10 12:16       ` [PATCH 4/8] i2c: lp5521: move to LED framework Felipe Balbi
2009-02-10 12:16         ` [PATCH 5/8] leds: lp5521: move to drivers/leds Felipe Balbi
2009-02-10 12:16           ` [PATCH 6/8] input: lm8323: get rid of global pdata pointer Felipe Balbi
2009-02-10 12:16             ` [PATCH 7/8] input: lm8323: get rid of useless debug macro Felipe Balbi
2009-02-10 12:16               ` [PATCH 8/8] input: lm8323: general clean up Felipe Balbi
2009-02-12 22:18         ` [PATCH 4/8] i2c: lp5521: move to LED framework David Brownell
2009-02-13  0:00           ` Felipe Balbi
2009-02-13 12:43             ` [RESEND] lp5521 patches Felipe Balbi
2009-02-13 12:43               ` [PATCH 1/6] i2c: lp5521: remove dead code Felipe Balbi
2009-02-13 12:43                 ` [PATCH 2/6] i2c: lp5521: cosmetic fixes Felipe Balbi
2009-02-13 12:43                   ` [PATCH 3/6] i2c: lp5521: simplify mode setting Felipe Balbi
2009-02-13 12:43                     ` [PATCH 4/6] i2c: lp5521: move to LED framework Felipe Balbi
2009-02-13 12:43                       ` [PATCH 5/6] leds: lp5521: move to drivers/leds Felipe Balbi
2009-02-13 12:43                         ` [PATCH 6/6] arm: omap: n810: add lp5521 platform_data Felipe Balbi
2009-02-13 20:49                         ` [PATCH 5/6] leds: lp5521: move to drivers/leds David Brownell
2009-02-13 22:36                           ` Felipe Balbi [this message]
2009-02-13 23:54                             ` David Brownell
2009-02-14  0:07                               ` Felipe Balbi
2009-02-17 21:38               ` [RESEND] lp5521 patches Otto Solares
2009-02-17 23:07                 ` Felipe Balbi
2009-02-17 23:29                   ` Felipe Balbi
2009-02-17 23:44                     ` Tony Lindgren
2009-02-17 23:50                       ` Felipe Balbi

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=20090213223636.GP10711@frodo \
    --to=me@felipebalbi.com \
    --cc=david-b@pacbell.net \
    --cc=felipe.balbi@nokia.com \
    --cc=linux-omap@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.