public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] thermal: cut the spaces when user sets policy
@ 2013-05-17 11:52 Andy Shevchenko
  2013-05-17 12:43 ` Eduardo Valentin
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2013-05-17 11:52 UTC (permalink / raw)
  To: Zhang Rui, Eduardo Valentin, linux-pm; +Cc: Andy Shevchenko

Setting policy results in invalid value error.
	% echo "step_wise" > policy
	% echo: write error: Invalid argument

Need clean up of the buffer which "echo" may add based on the arguments, before
comparing aganist list of governor names.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reported-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
Since v2:
 - fix typo in variable definition block
 drivers/thermal/thermal_core.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index d755440..1067fb0 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -33,6 +33,7 @@
 #include <linux/idr.h>
 #include <linux/thermal.h>
 #include <linux/reboot.h>
+#include <linux/string.h>
 #include <net/netlink.h>
 #include <net/genetlink.h>
 
@@ -713,10 +714,13 @@ policy_store(struct device *dev, struct device_attribute *attr,
 	int ret = -EINVAL;
 	struct thermal_zone_device *tz = to_thermal_zone(dev);
 	struct thermal_governor *gov;
+	char name[THERMAL_NAME_LENGTH];
+
+	snprintf(name, sizeof(name), "%s", buf);
 
 	mutex_lock(&thermal_governor_lock);
 
-	gov = __find_governor(buf);
+	gov = __find_governor(strim(name));
 	if (!gov)
 		goto exit;
 
-- 
1.8.2.rc0.22.gb3600c3


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

* Re: [PATCH v3] thermal: cut the spaces when user sets policy
  2013-05-17 11:52 [PATCH v3] thermal: cut the spaces when user sets policy Andy Shevchenko
@ 2013-05-17 12:43 ` Eduardo Valentin
  2013-05-20 15:10   ` Zhang, Rui
  0 siblings, 1 reply; 3+ messages in thread
From: Eduardo Valentin @ 2013-05-17 12:43 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Zhang Rui, Eduardo Valentin, linux-pm

[-- Attachment #1: Type: text/plain, Size: 1686 bytes --]

On 17-05-2013 07:52, Andy Shevchenko wrote:
> Setting policy results in invalid value error.
> 	% echo "step_wise" > policy
> 	% echo: write error: Invalid argument
> 
> Need clean up of the buffer which "echo" may add based on the arguments, before
> comparing aganist list of governor names.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reported-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

Acked-by: Eduardo Valentin <eduardo.valentin@ti.com>
Tested-by: Eduardo Valentin <eduardo.valentin@ti.com>

Tested on panda OMAP4430. As this is not platform dependent, I am fine
with the test I did.

> ---
> Since v2:
>  - fix typo in variable definition block
>  drivers/thermal/thermal_core.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index d755440..1067fb0 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -33,6 +33,7 @@
>  #include <linux/idr.h>
>  #include <linux/thermal.h>
>  #include <linux/reboot.h>
> +#include <linux/string.h>
>  #include <net/netlink.h>
>  #include <net/genetlink.h>
>  
> @@ -713,10 +714,13 @@ policy_store(struct device *dev, struct device_attribute *attr,
>  	int ret = -EINVAL;
>  	struct thermal_zone_device *tz = to_thermal_zone(dev);
>  	struct thermal_governor *gov;
> +	char name[THERMAL_NAME_LENGTH];
> +
> +	snprintf(name, sizeof(name), "%s", buf);
>  
>  	mutex_lock(&thermal_governor_lock);
>  
> -	gov = __find_governor(buf);
> +	gov = __find_governor(strim(name));
>  	if (!gov)
>  		goto exit;
>  
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 295 bytes --]

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

* RE: [PATCH v3] thermal: cut the spaces when user sets policy
  2013-05-17 12:43 ` Eduardo Valentin
@ 2013-05-20 15:10   ` Zhang, Rui
  0 siblings, 0 replies; 3+ messages in thread
From: Zhang, Rui @ 2013-05-20 15:10 UTC (permalink / raw)
  To: Eduardo Valentin, Andy Shevchenko; +Cc: linux-pm@vger.kernel.org



> -----Original Message-----
> From: Eduardo Valentin [mailto:eduardo.valentin@ti.com]
> Sent: Friday, May 17, 2013 8:43 PM
> To: Andy Shevchenko
> Cc: Zhang, Rui; Eduardo Valentin; linux-pm@vger.kernel.org
> Subject: Re: [PATCH v3] thermal: cut the spaces when user sets policy
> Importance: High
> 
> On 17-05-2013 07:52, Andy Shevchenko wrote:
> > Setting policy results in invalid value error.
> > 	% echo "step_wise" > policy
> > 	% echo: write error: Invalid argument
> >
> > Need clean up of the buffer which "echo" may add based on the
> > arguments, before comparing aganist list of governor names.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Reported-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> 
> Acked-by: Eduardo Valentin <eduardo.valentin@ti.com>
> Tested-by: Eduardo Valentin <eduardo.valentin@ti.com>
> 
> Tested on panda OMAP4430. As this is not platform dependent, I am fine
> with the test I did.
> 
Applied to thermal -next.

Thanks,
rui
> > ---
> > Since v2:
> >  - fix typo in variable definition block
> > drivers/thermal/thermal_core.c | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/thermal/thermal_core.c
> > b/drivers/thermal/thermal_core.c index d755440..1067fb0 100644
> > --- a/drivers/thermal/thermal_core.c
> > +++ b/drivers/thermal/thermal_core.c
> > @@ -33,6 +33,7 @@
> >  #include <linux/idr.h>
> >  #include <linux/thermal.h>
> >  #include <linux/reboot.h>
> > +#include <linux/string.h>
> >  #include <net/netlink.h>
> >  #include <net/genetlink.h>
> >
> > @@ -713,10 +714,13 @@ policy_store(struct device *dev, struct
> device_attribute *attr,
> >  	int ret = -EINVAL;
> >  	struct thermal_zone_device *tz = to_thermal_zone(dev);
> >  	struct thermal_governor *gov;
> > +	char name[THERMAL_NAME_LENGTH];
> > +
> > +	snprintf(name, sizeof(name), "%s", buf);
> >
> >  	mutex_lock(&thermal_governor_lock);
> >
> > -	gov = __find_governor(buf);
> > +	gov = __find_governor(strim(name));
> >  	if (!gov)
> >  		goto exit;
> >
> >
> 


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

end of thread, other threads:[~2013-05-20 15:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-17 11:52 [PATCH v3] thermal: cut the spaces when user sets policy Andy Shevchenko
2013-05-17 12:43 ` Eduardo Valentin
2013-05-20 15:10   ` Zhang, Rui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox