* [PATCH] cpufreq:core: Fix printing of governor and driver name
@ 2012-10-10 4:42 Viresh Kumar
2012-10-15 17:51 ` Rafael J. Wysocki
0 siblings, 1 reply; 4+ messages in thread
From: Viresh Kumar @ 2012-10-10 4:42 UTC (permalink / raw)
To: rjw
Cc: cpufreq, linux-pm, linux-kernel, linaro-dev, patches,
Sudeep.KarkadaNagesha, Robin.Randhawa, Arvind.Chauhan,
Viresh Kumar
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>
---
drivers/cpufreq/cpufreq.c | 6 +++---
include/linux/cpufreq.h | 2 ++
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 021973b..db6e337 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)
else if (policy->policy == CPUFREQ_POLICY_PERFORMANCE)
return sprintf(buf, "performance\n");
else if (policy->governor)
- return scnprintf(buf, CPUFREQ_NAME_LEN, "%s\n",
+ return scnprintf(buf, CPUFREQ_NAME_PLEN, "%s\n",
policy->governor->name);
return -EINVAL;
}
@@ -491,7 +491,7 @@ static ssize_t store_scaling_governor(struct cpufreq_policy *policy,
*/
static ssize_t show_scaling_driver(struct cpufreq_policy *policy, char *buf)
{
- return scnprintf(buf, CPUFREQ_NAME_LEN, "%s\n", cpufreq_driver->name);
+ return scnprintf(buf, CPUFREQ_NAME_PLEN, "%s\n", cpufreq_driver->name);
}
/**
@@ -512,7 +512,7 @@ static ssize_t show_scaling_available_governors(struct cpufreq_policy *policy,
if (i >= (ssize_t) ((PAGE_SIZE / sizeof(char))
- (CPUFREQ_NAME_LEN + 2)))
goto out;
- i += scnprintf(&buf[i], CPUFREQ_NAME_LEN, "%s ", t->name);
+ i += scnprintf(&buf[i], CPUFREQ_NAME_PLEN, "%s ", t->name);
}
out:
i += sprintf(&buf[i], "\n");
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index b60f6ba..fc4b785 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -22,6 +22,8 @@
#include <asm/div64.h>
#define CPUFREQ_NAME_LEN 16
+/* Print length for names. Extra 1 space for accomodating '\n' in prints */
+#define CPUFREQ_NAME_PLEN (CPUFREQ_NAME_LEN + 1)
/*********************************************************************
--
1.7.12.rc2.18.g61b472e
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] cpufreq:core: Fix printing of governor and driver name
2012-10-10 4:42 [PATCH] cpufreq:core: Fix printing of governor and driver name Viresh Kumar
@ 2012-10-15 17:51 ` Rafael J. Wysocki
2012-10-16 3:39 ` Viresh Kumar
0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2012-10-15 17:51 UTC (permalink / raw)
To: Viresh Kumar
Cc: cpufreq, linux-pm, linux-kernel, linaro-dev, patches,
Sudeep.KarkadaNagesha, Robin.Randhawa, Arvind.Chauhan
On Wednesday 10 of October 2012 10:12:11 Viresh Kumar wrote:
> 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>
Thanks for the patch, I'll queue it up for v3.8.
Rafael
> ---
> drivers/cpufreq/cpufreq.c | 6 +++---
> include/linux/cpufreq.h | 2 ++
> 2 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 021973b..db6e337 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)
> else if (policy->policy == CPUFREQ_POLICY_PERFORMANCE)
> return sprintf(buf, "performance\n");
> else if (policy->governor)
> - return scnprintf(buf, CPUFREQ_NAME_LEN, "%s\n",
> + return scnprintf(buf, CPUFREQ_NAME_PLEN, "%s\n",
> policy->governor->name);
> return -EINVAL;
> }
> @@ -491,7 +491,7 @@ static ssize_t store_scaling_governor(struct cpufreq_policy *policy,
> */
> static ssize_t show_scaling_driver(struct cpufreq_policy *policy, char *buf)
> {
> - return scnprintf(buf, CPUFREQ_NAME_LEN, "%s\n", cpufreq_driver->name);
> + return scnprintf(buf, CPUFREQ_NAME_PLEN, "%s\n", cpufreq_driver->name);
> }
>
> /**
> @@ -512,7 +512,7 @@ static ssize_t show_scaling_available_governors(struct cpufreq_policy *policy,
> if (i >= (ssize_t) ((PAGE_SIZE / sizeof(char))
> - (CPUFREQ_NAME_LEN + 2)))
> goto out;
> - i += scnprintf(&buf[i], CPUFREQ_NAME_LEN, "%s ", t->name);
> + i += scnprintf(&buf[i], CPUFREQ_NAME_PLEN, "%s ", t->name);
> }
> out:
> i += sprintf(&buf[i], "\n");
> diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
> index b60f6ba..fc4b785 100644
> --- a/include/linux/cpufreq.h
> +++ b/include/linux/cpufreq.h
> @@ -22,6 +22,8 @@
> #include <asm/div64.h>
>
> #define CPUFREQ_NAME_LEN 16
> +/* Print length for names. Extra 1 space for accomodating '\n' in prints */
> +#define CPUFREQ_NAME_PLEN (CPUFREQ_NAME_LEN + 1)
>
>
> /*********************************************************************
>
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] cpufreq:core: Fix printing of governor and driver name
2012-10-15 17:51 ` Rafael J. Wysocki
@ 2012-10-16 3:39 ` Viresh Kumar
2012-10-16 16:20 ` Rafael J. Wysocki
0 siblings, 1 reply; 4+ messages in thread
From: Viresh Kumar @ 2012-10-16 3:39 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: cpufreq, linux-pm, linux-kernel, linaro-dev, patches,
Sudeep.KarkadaNagesha, Robin.Randhawa, Arvind.Chauhan
On 15 October 2012 23:21, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> On Wednesday 10 of October 2012 10:12:11 Viresh Kumar wrote:
>> 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>
>
> Thanks for the patch, I'll queue it up for v3.8.
Hi Rafael,
Thanks for accepting the patch.
I thought both of my patches would go in 3.7-rc2 as they are bug
fixes. Isn't that correct?
--
viresh
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] cpufreq:core: Fix printing of governor and driver name
2012-10-16 3:39 ` Viresh Kumar
@ 2012-10-16 16:20 ` Rafael J. Wysocki
0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2012-10-16 16:20 UTC (permalink / raw)
To: Viresh Kumar
Cc: cpufreq, linux-pm, linux-kernel, linaro-dev, patches,
Sudeep.KarkadaNagesha, Robin.Randhawa, Arvind.Chauhan
On Tuesday 16 of October 2012 09:09:15 Viresh Kumar wrote:
> On 15 October 2012 23:21, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> > On Wednesday 10 of October 2012 10:12:11 Viresh Kumar wrote:
> >> 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>
> >
> > Thanks for the patch, I'll queue it up for v3.8.
>
> Hi Rafael,
>
> Thanks for accepting the patch.
> I thought both of my patches would go in 3.7-rc2 as they are bug
> fixes. Isn't that correct?
They don't fix serious bugs, though, so they don't look like urgent.
Thanks,
Rafael
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-10-16 16:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-10 4:42 [PATCH] cpufreq:core: Fix printing of governor and driver name Viresh Kumar
2012-10-15 17:51 ` Rafael J. Wysocki
2012-10-16 3:39 ` Viresh Kumar
2012-10-16 16:20 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®