From 93e14baa4494607efe81608725f591e3ba31e3c1 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Wed, 14 Jan 2009 13:16:27 -0800 Subject: regulator: minor cleanup of virtual consumer 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 Acked-by: Mark Brown Signed-off-by: Liam Girdwood --- drivers/regulator/virtual.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/regulator/virtual.c') diff --git a/drivers/regulator/virtual.c b/drivers/regulator/virtual.c index 5ddb464b1c3..a38d42bc8f8 100644 --- a/drivers/regulator/virtual.c +++ b/drivers/regulator/virtual.c @@ -226,13 +226,13 @@ static ssize_t set_mode(struct device *dev, struct device_attribute *attr, 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"); -- cgit v1.2.3-70-g09d2 From 9485397aa2195e82da6373586a66689526675ad4 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Thu, 15 Jan 2009 16:13:01 -0800 Subject: regulator: minor cleanup of virtual consumer On Thu, 15 Jan 2009 16:10:22 -0800 Andrew Morton wrote: > On Wed, 14 Jan 2009 13:16:27 -0800 > David Brownell wrote: > > > From: David Brownell > > > > 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 > > --- > > 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? Acked-by: Mark Brown Signed-off-by: Liam Girdwood --- drivers/regulator/virtual.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/regulator/virtual.c') diff --git a/drivers/regulator/virtual.c b/drivers/regulator/virtual.c index a38d42bc8f8..45ebbc22f47 100644 --- a/drivers/regulator/virtual.c +++ b/drivers/regulator/virtual.c @@ -226,6 +226,10 @@ static ssize_t set_mode(struct device *dev, struct device_attribute *attr, 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) -- cgit v1.2.3-70-g09d2 From fefdae42465facfa26d41a7f0010f1ade32c3386 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 19 Jan 2009 13:37:06 +0000 Subject: regulator: Mark attributes table for virtual regulator static It's not exported. Signed-off-by: Mark Brown Signed-off-by: Liam Girdwood --- drivers/regulator/virtual.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/regulator/virtual.c') diff --git a/drivers/regulator/virtual.c b/drivers/regulator/virtual.c index 45ebbc22f47..3d08348584e 100644 --- a/drivers/regulator/virtual.c +++ b/drivers/regulator/virtual.c @@ -260,7 +260,7 @@ static DEVICE_ATTR(min_microamps, 0666, show_min_uA, set_min_uA); static DEVICE_ATTR(max_microamps, 0666, show_max_uA, set_max_uA); static DEVICE_ATTR(mode, 0666, show_mode, set_mode); -struct device_attribute *attributes[] = { +static struct device_attribute *attributes[] = { &dev_attr_min_microvolts, &dev_attr_max_microvolts, &dev_attr_min_microamps, -- cgit v1.2.3-70-g09d2