aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/cpufreq.c
diff options
context:
space:
mode:
authorviresh kumar <viresh.kumar@linaro.org>2012-10-22 19:23:43 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2012-11-14 18:33:06 -0500
commit4b972f0b04eaae645b22d99479b9aea43c3d64e7 (patch)
treeab9fd0b4ebe200738bb6836fa2e27c8db56352b2 /drivers/cpufreq/cpufreq.c
parent8bf1ac723639c4260f76df0e45ee23aa35a23067 (diff)
cpufreq / core: Fix printing of governor and driver name
Arrays for governer and driver name are of size CPUFREQ_NAME_LEN or 16. i.e. 15 bytes for name and 1 for trailing '\0'. When cpufreq driver print these names (for sysfs), it includes '\n' or ' ' in the fmt string and still passes length as CPUFREQ_NAME_LEN. If the driver or governor names are using all 15 fields allocated to them, then the trailing '\n' or ' ' will never be printed. And so commands like: root@linaro-developer# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver will print something like: cpufreq_foodrvroot@linaro-developer# Fix this by increasing print length by one character. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpufreq/cpufreq.c')
-rw-r--r--drivers/cpufreq/cpufreq.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 021973b7dc56..db6e337ad337 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -445,7 +445,7 @@ static ssize_t show_scaling_governor(struct cpufreq_policy *policy, char *buf)
445 else if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) 445 else if (policy->policy == CPUFREQ_POLICY_PERFORMANCE)
446 return sprintf(buf, "performance\n"); 446 return sprintf(buf, "performance\n");
447 else if (policy->governor) 447 else if (policy->governor)
448 return scnprintf(buf, CPUFREQ_NAME_LEN, "%s\n", 448 return scnprintf(buf, CPUFREQ_NAME_PLEN, "%s\n",
449 policy->governor->name); 449 policy->governor->name);
450 return -EINVAL; 450 return -EINVAL;
451} 451}
@@ -491,7 +491,7 @@ static ssize_t store_scaling_governor(struct cpufreq_policy *policy,
491 */ 491 */
492static ssize_t show_scaling_driver(struct cpufreq_policy *policy, char *buf) 492static ssize_t show_scaling_driver(struct cpufreq_policy *policy, char *buf)
493{ 493{
494 return scnprintf(buf, CPUFREQ_NAME_LEN, "%s\n", cpufreq_driver->name); 494 return scnprintf(buf, CPUFREQ_NAME_PLEN, "%s\n", cpufreq_driver->name);
495} 495}
496 496
497/** 497/**
@@ -512,7 +512,7 @@ static ssize_t show_scaling_available_governors(struct cpufreq_policy *policy,
512 if (i >= (ssize_t) ((PAGE_SIZE / sizeof(char)) 512 if (i >= (ssize_t) ((PAGE_SIZE / sizeof(char))
513 - (CPUFREQ_NAME_LEN + 2))) 513 - (CPUFREQ_NAME_LEN + 2)))
514 goto out; 514 goto out;
515 i += scnprintf(&buf[i], CPUFREQ_NAME_LEN, "%s ", t->name); 515 i += scnprintf(&buf[i], CPUFREQ_NAME_PLEN, "%s ", t->name);
516 } 516 }
517out: 517out:
518 i += sprintf(&buf[i], "\n"); 518 i += sprintf(&buf[i], "\n");