diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2013-05-17 07:52:02 -0400 |
---|---|---|
committer | Zhang Rui <rui.zhang@intel.com> | 2013-05-27 22:04:22 -0400 |
commit | 42a5bf507d7f7ecbf606eb392dd9d2e4d009c36b (patch) | |
tree | 6c8fc95ce2004bdd0e0692110a09b4a023624893 | |
parent | 3db46c939677e32e311d354b619fd552ceafd123 (diff) |
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.
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>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
-rw-r--r-- | drivers/thermal/thermal_core.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index d755440791b7..1067fb0107b9 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/idr.h> | 33 | #include <linux/idr.h> |
34 | #include <linux/thermal.h> | 34 | #include <linux/thermal.h> |
35 | #include <linux/reboot.h> | 35 | #include <linux/reboot.h> |
36 | #include <linux/string.h> | ||
36 | #include <net/netlink.h> | 37 | #include <net/netlink.h> |
37 | #include <net/genetlink.h> | 38 | #include <net/genetlink.h> |
38 | 39 | ||
@@ -713,10 +714,13 @@ policy_store(struct device *dev, struct device_attribute *attr, | |||
713 | int ret = -EINVAL; | 714 | int ret = -EINVAL; |
714 | struct thermal_zone_device *tz = to_thermal_zone(dev); | 715 | struct thermal_zone_device *tz = to_thermal_zone(dev); |
715 | struct thermal_governor *gov; | 716 | struct thermal_governor *gov; |
717 | char name[THERMAL_NAME_LENGTH]; | ||
718 | |||
719 | snprintf(name, sizeof(name), "%s", buf); | ||
716 | 720 | ||
717 | mutex_lock(&thermal_governor_lock); | 721 | mutex_lock(&thermal_governor_lock); |
718 | 722 | ||
719 | gov = __find_governor(buf); | 723 | gov = __find_governor(strim(name)); |
720 | if (!gov) | 724 | if (!gov) |
721 | goto exit; | 725 | goto exit; |
722 | 726 | ||