Skip to contentSkip to conversation

thermal: cut the spaces when user sets policy

PATCH Applied Andy Shevchenko 3 participants 3 messages May 17, 2013 – May 20, 2013 Thermal

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 thermal: cut the spaces when user sets policy

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.

---
Since v2:
- fix typo in variable definition block

 drivers/thermal/thermal_core.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/thermal/thermal_core.c +5 -1
index d755440..1067fb0 100644
@@ -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;
 
Signature · 1 line
1.8.2.rc0.22.gb3600c3
Acked-by Tested-by on v3 1/1
#1 lore raw
Quoted 9 lines · 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.

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

Quoted 34 lines

---
Since v2:
- fix typo in variable definition block

 drivers/thermal/thermal_core.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/thermal/thermal_core.c +5 -1
index d755440..1067fb0 100644
@@ -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;
 
reviewer Applied
#2 lore raw
Quoted 18 lines

-----Original Message-----
From: Eduardo Valentin [mailto:[email protected]]
Sent: Friday, May 17, 2013 8:43 PM
To: Andy Shevchenko
Cc: Zhang, Rui; Eduardo Valentin; [email protected]
Subject: Re: [PATCH v3] thermal: cut the spaces when user sets policy
Importance: High

Quoted 7 lines · 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.

Quoted 9 lines
Quoted 2 lines

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

Applied to thermal -next.

Thanks,
rui

Quoted 36 lines

drivers/thermal/thermal_core.c policy_store(struct device *dev, struct

Quoted 19 lines

---
Since v2:
- fix typo in variable definition block
drivers/thermal/thermal_core.c | 6 +++++-

 1 file changed, 5 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/thermal/thermal_core.c index d755440..1067fb0 100644

drivers/thermal/thermal_core.c +1 -0
@@ -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,

Quoted 15 lines
drivers/thermal/thermal_core.c +4 -1
 	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;