All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch 2.6.29-rc] regulator: minor cleanup of virtual consumer
@ 2009-01-14 21:16 David Brownell
  2009-01-14 22:36 ` Mark Brown
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: David Brownell @ 2009-01-14 21:16 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood; +Cc: lkml

From: David Brownell <dbrownell@users.sourceforge.net>

Minor cleanup to the regulator set_mode sysfs support:
switch to sysfs_streq() in set_mode(), which is also
a code shrink.  Use the same strings that get_mode()
uses, shrinking data too.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
---
 drivers/regulator/virtual.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

--- a/drivers/regulator/virtual.c
+++ b/drivers/regulator/virtual.c
@@ -226,13 +226,13 @@ static ssize_t set_mode(struct device *d
 	unsigned int mode;
 	int ret;
 
-	if (strncmp(buf, "fast", strlen("fast")) == 0)
+	if (sysfs_streq(buf, "fast\n") == 0)
 		mode = REGULATOR_MODE_FAST;
-	else if (strncmp(buf, "normal", strlen("normal")) == 0)
+	else if (sysfs_streq(buf, "normal\n") == 0)
 		mode = REGULATOR_MODE_NORMAL;
-	else if (strncmp(buf, "idle", strlen("idle")) == 0)
+	else if (sysfs_streq(buf, "idle\n") == 0)
 		mode = REGULATOR_MODE_IDLE;
-	else if (strncmp(buf, "standby", strlen("standby")) == 0)
+	else if (sysfs_streq(buf, "standby\n") == 0)
 		mode = REGULATOR_MODE_STANDBY;
 	else {
 		dev_err(dev, "Configuring invalid mode\n");

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

* Re: [patch 2.6.29-rc] regulator: minor cleanup of virtual consumer
  2009-01-14 21:16 [patch 2.6.29-rc] regulator: minor cleanup of virtual consumer David Brownell
@ 2009-01-14 22:36 ` Mark Brown
  2009-01-15 12:04 ` Liam Girdwood
  2009-01-16  0:10 ` Andrew Morton
  2 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2009-01-14 22:36 UTC (permalink / raw)
  To: David Brownell; +Cc: Liam Girdwood, lkml

On 14 Jan 2009, at 21:16, David Brownell <david-b@pacbell.net> wrote:

> From: David Brownell <dbrownell@users.sourceforge.net>
>
> Minor cleanup to the regulator set_mode sysfs support:
> switch to sysfs_streq() in set_mode(), which is also
> a code shrink.  Use the same strings that get_mode()
> uses, shrinking data too.
>
> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>

Excellent, thanks!

Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

>
> ---
> drivers/regulator/virtual.c |    8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> --- a/drivers/regulator/virtual.c
> +++ b/drivers/regulator/virtual.c
> @@ -226,13 +226,13 @@ static ssize_t set_mode(struct device *d
>    unsigned int mode;
>    int ret;
>
> -    if (strncmp(buf, "fast", strlen("fast")) == 0)
> +    if (sysfs_streq(buf, "fast\n") == 0)
>        mode = REGULATOR_MODE_FAST;
> -    else if (strncmp(buf, "normal", strlen("normal")) == 0)
> +    else if (sysfs_streq(buf, "normal\n") == 0)
>        mode = REGULATOR_MODE_NORMAL;
> -    else if (strncmp(buf, "idle", strlen("idle")) == 0)
> +    else if (sysfs_streq(buf, "idle\n") == 0)
>        mode = REGULATOR_MODE_IDLE;
> -    else if (strncmp(buf, "standby", strlen("standby")) == 0)
> +    else if (sysfs_streq(buf, "standby\n") == 0)
>        mode = REGULATOR_MODE_STANDBY;
>    else {
>        dev_err(dev, "Configuring invalid mode\n");

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

* Re: [patch 2.6.29-rc] regulator: minor cleanup of virtual consumer
  2009-01-14 21:16 [patch 2.6.29-rc] regulator: minor cleanup of virtual consumer David Brownell
  2009-01-14 22:36 ` Mark Brown
@ 2009-01-15 12:04 ` Liam Girdwood
  2009-01-16  0:10 ` Andrew Morton
  2 siblings, 0 replies; 8+ messages in thread
From: Liam Girdwood @ 2009-01-15 12:04 UTC (permalink / raw)
  To: David Brownell; +Cc: Mark Brown, lkml

On Wed, 2009-01-14 at 13:16 -0800, David Brownell wrote:
> From: David Brownell <dbrownell@users.sourceforge.net>
> 
> Minor cleanup to the regulator set_mode sysfs support:
> switch to sysfs_streq() in set_mode(), which is also
> a code shrink.  Use the same strings that get_mode()
> uses, shrinking data too.
> 
> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>

Applied.

Thanks

Liam


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

* Re: [patch 2.6.29-rc] regulator: minor cleanup of virtual consumer
  2009-01-14 21:16 [patch 2.6.29-rc] regulator: minor cleanup of virtual consumer David Brownell
  2009-01-14 22:36 ` Mark Brown
  2009-01-15 12:04 ` Liam Girdwood
@ 2009-01-16  0:10 ` Andrew Morton
  2009-01-16  0:13   ` Andrew Morton
  2009-01-16  1:06   ` David Brownell
  2 siblings, 2 replies; 8+ messages in thread
From: Andrew Morton @ 2009-01-16  0:10 UTC (permalink / raw)
  To: David Brownell; +Cc: broonie, lrg, linux-kernel

On Wed, 14 Jan 2009 13:16:27 -0800
David Brownell <david-b@pacbell.net> wrote:

> From: David Brownell <dbrownell@users.sourceforge.net>
> 
> Minor cleanup to the regulator set_mode sysfs support:
> switch to sysfs_streq() in set_mode(), which is also
> a code shrink.  Use the same strings that get_mode()
> uses, shrinking data too.
> 
> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
> ---
>  drivers/regulator/virtual.c |    8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> --- a/drivers/regulator/virtual.c
> +++ b/drivers/regulator/virtual.c
> @@ -226,13 +226,13 @@ static ssize_t set_mode(struct device *d
>  	unsigned int mode;
>  	int ret;
>  
> -	if (strncmp(buf, "fast", strlen("fast")) == 0)
> +	if (sysfs_streq(buf, "fast\n") == 0)
>  		mode = REGULATOR_MODE_FAST;
> -	else if (strncmp(buf, "normal", strlen("normal")) == 0)
> +	else if (sysfs_streq(buf, "normal\n") == 0)
>  		mode = REGULATOR_MODE_NORMAL;
> -	else if (strncmp(buf, "idle", strlen("idle")) == 0)
> +	else if (sysfs_streq(buf, "idle\n") == 0)
>  		mode = REGULATOR_MODE_IDLE;
> -	else if (strncmp(buf, "standby", strlen("standby")) == 0)
> +	else if (sysfs_streq(buf, "standby\n") == 0)
>  		mode = REGULATOR_MODE_STANDBY;

we don't need the \n's, do we?

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

* Re: [patch 2.6.29-rc] regulator: minor cleanup of virtual consumer
  2009-01-16  0:10 ` Andrew Morton
@ 2009-01-16  0:13   ` Andrew Morton
  2009-01-16  1:13     ` Mark Brown
  2009-01-16 12:21     ` Liam Girdwood
  2009-01-16  1:06   ` David Brownell
  1 sibling, 2 replies; 8+ messages in thread
From: Andrew Morton @ 2009-01-16  0:13 UTC (permalink / raw)
  To: david-b, broonie, lrg, linux-kernel

On Thu, 15 Jan 2009 16:10:22 -0800
Andrew Morton <akpm@linux-foundation.org> wrote:

> On Wed, 14 Jan 2009 13:16:27 -0800
> David Brownell <david-b@pacbell.net> wrote:
> 
> > From: David Brownell <dbrownell@users.sourceforge.net>
> > 
> > Minor cleanup to the regulator set_mode sysfs support:
> > switch to sysfs_streq() in set_mode(), which is also
> > a code shrink.  Use the same strings that get_mode()
> > uses, shrinking data too.
> > 
> > Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
> > ---
> >  drivers/regulator/virtual.c |    8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > --- a/drivers/regulator/virtual.c
> > +++ b/drivers/regulator/virtual.c
> > @@ -226,13 +226,13 @@ static ssize_t set_mode(struct device *d
> >  	unsigned int mode;
> >  	int ret;
> >  
> > -	if (strncmp(buf, "fast", strlen("fast")) == 0)
> > +	if (sysfs_streq(buf, "fast\n") == 0)
> >  		mode = REGULATOR_MODE_FAST;
> > -	else if (strncmp(buf, "normal", strlen("normal")) == 0)
> > +	else if (sysfs_streq(buf, "normal\n") == 0)
> >  		mode = REGULATOR_MODE_NORMAL;
> > -	else if (strncmp(buf, "idle", strlen("idle")) == 0)
> > +	else if (sysfs_streq(buf, "idle\n") == 0)
> >  		mode = REGULATOR_MODE_IDLE;
> > -	else if (strncmp(buf, "standby", strlen("standby")) == 0)
> > +	else if (sysfs_streq(buf, "standby\n") == 0)
> >  		mode = REGULATOR_MODE_STANDBY;
> 
> we don't need the \n's, do we?

oh, it's for the string sharing.  Sneaky.

I wonder how many people will try to fix that up for us?

--- a/drivers/regulator/virtual.c~regulator-minor-cleanup-of-virtual-consumer-fix
+++ a/drivers/regulator/virtual.c
@@ -226,6 +226,10 @@ static ssize_t set_mode(struct device *d
 	unsigned int mode;
 	int ret;
 
+	/*
+	 * sysfs_streq() doesn't need the \n's, but we add them so the strings
+	 * will be shared with show_mode(), above.
+	 */
 	if (sysfs_streq(buf, "fast\n") == 0)
 		mode = REGULATOR_MODE_FAST;
 	else if (sysfs_streq(buf, "normal\n") == 0)
_


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

* Re: [patch 2.6.29-rc] regulator: minor cleanup of virtual consumer
  2009-01-16  0:10 ` Andrew Morton
  2009-01-16  0:13   ` Andrew Morton
@ 2009-01-16  1:06   ` David Brownell
  1 sibling, 0 replies; 8+ messages in thread
From: David Brownell @ 2009-01-16  1:06 UTC (permalink / raw)
  To: Andrew Morton; +Cc: broonie, lrg, linux-kernel

On Thursday 15 January 2009, Andrew Morton wrote:
> > -	else if (strncmp(buf, "standby", strlen("standby")) == 0)
> > +	else if (sysfs_streq(buf, "standby\n") == 0)
> >  		mode = REGULATOR_MODE_STANDBY;
> 
> we don't need the \n's, do we?

No, but ...

That's what saves an extra couple dozen bytes of
memory ... the strings, with newlines, are used
to *write* these sysfs attributes.

- Dave




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

* Re: [patch 2.6.29-rc] regulator: minor cleanup of virtual consumer
  2009-01-16  0:13   ` Andrew Morton
@ 2009-01-16  1:13     ` Mark Brown
  2009-01-16 12:21     ` Liam Girdwood
  1 sibling, 0 replies; 8+ messages in thread
From: Mark Brown @ 2009-01-16  1:13 UTC (permalink / raw)
  To: Andrew Morton; +Cc: david-b, lrg, linux-kernel

On Thu, Jan 15, 2009 at 04:13:01PM -0800, Andrew Morton wrote:
> Andrew Morton <akpm@linux-foundation.org> wrote:

> I wonder how many people will try to fix that up for us?

Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

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

* Re: [patch 2.6.29-rc] regulator: minor cleanup of virtual consumer
  2009-01-16  0:13   ` Andrew Morton
  2009-01-16  1:13     ` Mark Brown
@ 2009-01-16 12:21     ` Liam Girdwood
  1 sibling, 0 replies; 8+ messages in thread
From: Liam Girdwood @ 2009-01-16 12:21 UTC (permalink / raw)
  To: Andrew Morton; +Cc: david-b, broonie, linux-kernel

On Thu, 2009-01-15 at 16:13 -0800, Andrew Morton wrote:
> On Thu, 15 Jan 2009 16:10:22 -0800
> Andrew Morton <akpm@linux-foundation.org> wrote:

> 
> --- a/drivers/regulator/virtual.c~regulator-minor-cleanup-of-virtual-consumer-fix
> +++ a/drivers/regulator/virtual.c
> @@ -226,6 +226,10 @@ static ssize_t set_mode(struct device *d
>  	unsigned int mode;
>  	int ret;
>  
> +	/*
> +	 * sysfs_streq() doesn't need the \n's, but we add them so the strings
> +	 * will be shared with show_mode(), above.
> +	 */
>  	if (sysfs_streq(buf, "fast\n") == 0)
>  		mode = REGULATOR_MODE_FAST;
>  	else if (sysfs_streq(buf, "normal\n") == 0)
> _
> 

Applied.

Thanks

Liam


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

end of thread, other threads:[~2009-01-16 12:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-14 21:16 [patch 2.6.29-rc] regulator: minor cleanup of virtual consumer David Brownell
2009-01-14 22:36 ` Mark Brown
2009-01-15 12:04 ` Liam Girdwood
2009-01-16  0:10 ` Andrew Morton
2009-01-16  0:13   ` Andrew Morton
2009-01-16  1:13     ` Mark Brown
2009-01-16 12:21     ` Liam Girdwood
2009-01-16  1:06   ` David Brownell

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.