From patchwork Fri Feb 13 22:36:37 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 7093 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n1DMakV3019091 for ; Fri, 13 Feb 2009 22:36:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753457AbZBMWgp (ORCPT ); Fri, 13 Feb 2009 17:36:45 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753461AbZBMWgp (ORCPT ); Fri, 13 Feb 2009 17:36:45 -0500 Received: from ns1.siteground211.com ([209.62.36.12]:57447 "EHLO serv01.siteground211.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753457AbZBMWgo (ORCPT ); Fri, 13 Feb 2009 17:36:44 -0500 Received: from [91.154.126.168] (port=19402 helo=frodo) by serv01.siteground211.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69) (envelope-from ) id 1LY6eG-0005Vl-B0; Fri, 13 Feb 2009 16:36:40 -0600 Date: Sat, 14 Feb 2009 00:36:37 +0200 From: Felipe Balbi To: David Brownell Cc: Felipe Balbi , linux-omap@vger.kernel.org Subject: Re: [PATCH 5/6] leds: lp5521: move to drivers/leds Message-ID: <20090213223636.GP10711@frodo> Reply-To: me@felipebalbi.com References: <1234529032-25354-5-git-send-email-felipe.balbi@nokia.com> <1234529032-25354-6-git-send-email-felipe.balbi@nokia.com> <200902131249.00592.david-b@pacbell.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <200902131249.00592.david-b@pacbell.net> User-Agent: Mutt/1.5.18 (2008-05-17) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - serv01.siteground211.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - felipebalbi.com Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org 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 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 --- 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);