* [PATCH RESEND] cpupower: Fix no-rounding MHz frequency output
@ 2017-10-23 11:56 Prarit Bhargava
2017-10-23 12:35 ` Stafford Horne
0 siblings, 1 reply; 3+ messages in thread
From: Prarit Bhargava @ 2017-10-23 11:56 UTC (permalink / raw)
To: linux-pm; +Cc: Prarit Bhargava, Thomas Renninger, Stafford Horne, Shuah Khan
Sent about a year ago ...
P.
---8<---
'cpupower frequency-info -ln' returns kHz values on systems with MHz range
minimum CPU frequency range. For example, on a 800MHz to 4.20GHz system
the command returns
hardware limits: 800000 MHz - 4.200000 GHz
The value of speed passed into print_speed is in kHz, so divide speed by
1000 in the MHz else-if section to get MHz.
Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Cc: Thomas Renninger <trenn@suse.com>
Cc: Stafford Horne <shorne@gmail.com>
Cc: Shuah Khan <shuah@kernel.org>
---
tools/power/cpupower/utils/cpufreq-info.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/power/cpupower/utils/cpufreq-info.c b/tools/power/cpupower/utils/cpufreq-info.c
index 3e701f0e9c14..fe7c25147b3a 100644
--- a/tools/power/cpupower/utils/cpufreq-info.c
+++ b/tools/power/cpupower/utils/cpufreq-info.c
@@ -94,7 +94,7 @@ static void print_speed(unsigned long speed)
printf("%u.%06u GHz", ((unsigned int) speed/1000000),
((unsigned int) speed%1000000));
else if (speed > 100000)
- printf("%u MHz", (unsigned int) speed);
+ printf("%u MHz", (unsigned int) speed/1000);
else if (speed > 1000)
printf("%u.%03u MHz", ((unsigned int) speed/1000),
(unsigned int) (speed%1000));
--
2.15.0.rc0.39.g2f0e14e64
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH RESEND] cpupower: Fix no-rounding MHz frequency output
2017-10-23 11:56 [PATCH RESEND] cpupower: Fix no-rounding MHz frequency output Prarit Bhargava
@ 2017-10-23 12:35 ` Stafford Horne
2017-10-25 13:41 ` Prarit Bhargava
0 siblings, 1 reply; 3+ messages in thread
From: Stafford Horne @ 2017-10-23 12:35 UTC (permalink / raw)
To: Prarit Bhargava; +Cc: linux-pm, Thomas Renninger, Shuah Khan
On Mon, Oct 23, 2017 at 07:56:32AM -0400, Prarit Bhargava wrote:
> Sent about a year ago ...
>
> P.
>
> ---8<---
>
> 'cpupower frequency-info -ln' returns kHz values on systems with MHz range
> minimum CPU frequency range. For example, on a 800MHz to 4.20GHz system
> the command returns
>
> hardware limits: 800000 MHz - 4.200000 GHz
>
> The value of speed passed into print_speed is in kHz, so divide speed by
> 1000 in the MHz else-if section to get MHz.
>
> Signed-off-by: Prarit Bhargava <prarit@redhat.com>
> Cc: Thomas Renninger <trenn@suse.com>
> Cc: Stafford Horne <shorne@gmail.com>
> Cc: Shuah Khan <shuah@kernel.org>
> ---
> tools/power/cpupower/utils/cpufreq-info.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/power/cpupower/utils/cpufreq-info.c b/tools/power/cpupower/utils/cpufreq-info.c
> index 3e701f0e9c14..fe7c25147b3a 100644
> --- a/tools/power/cpupower/utils/cpufreq-info.c
> +++ b/tools/power/cpupower/utils/cpufreq-info.c
> @@ -94,7 +94,7 @@ static void print_speed(unsigned long speed)
> printf("%u.%06u GHz", ((unsigned int) speed/1000000),
> ((unsigned int) speed%1000000));
> else if (speed > 100000)
> - printf("%u MHz", (unsigned int) speed);
> + printf("%u MHz", (unsigned int) speed/1000);
This looks ok to me, but can't we just remove this condition and depend on the
condition with the decimal point below?
-Stafford
> else if (speed > 1000)
> printf("%u.%03u MHz", ((unsigned int) speed/1000),
> (unsigned int) (speed%1000));
> --
> 2.15.0.rc0.39.g2f0e14e64
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RESEND] cpupower: Fix no-rounding MHz frequency output
2017-10-23 12:35 ` Stafford Horne
@ 2017-10-25 13:41 ` Prarit Bhargava
0 siblings, 0 replies; 3+ messages in thread
From: Prarit Bhargava @ 2017-10-25 13:41 UTC (permalink / raw)
To: Stafford Horne; +Cc: linux-pm, Thomas Renninger, Shuah Khan
On 10/23/2017 08:35 AM, Stafford Horne wrote:
> On Mon, Oct 23, 2017 at 07:56:32AM -0400, Prarit Bhargava wrote:
>> Sent about a year ago ...
>>
>> P.
>>
>> ---8<---
>>
>> 'cpupower frequency-info -ln' returns kHz values on systems with MHz range
>> minimum CPU frequency range. For example, on a 800MHz to 4.20GHz system
>> the command returns
>>
>> hardware limits: 800000 MHz - 4.200000 GHz
>>
>> The value of speed passed into print_speed is in kHz, so divide speed by
>> 1000 in the MHz else-if section to get MHz.
>>
>> Signed-off-by: Prarit Bhargava <prarit@redhat.com>
>> Cc: Thomas Renninger <trenn@suse.com>
>> Cc: Stafford Horne <shorne@gmail.com>
>> Cc: Shuah Khan <shuah@kernel.org>
>> ---
>> tools/power/cpupower/utils/cpufreq-info.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/power/cpupower/utils/cpufreq-info.c b/tools/power/cpupower/utils/cpufreq-info.c
>> index 3e701f0e9c14..fe7c25147b3a 100644
>> --- a/tools/power/cpupower/utils/cpufreq-info.c
>> +++ b/tools/power/cpupower/utils/cpufreq-info.c
>> @@ -94,7 +94,7 @@ static void print_speed(unsigned long speed)
>> printf("%u.%06u GHz", ((unsigned int) speed/1000000),
>> ((unsigned int) speed%1000000));
>> else if (speed > 100000)
>> - printf("%u MHz", (unsigned int) speed);
>> + printf("%u MHz", (unsigned int) speed/1000);
>
> This looks ok to me, but can't we just remove this condition and depend on the
> condition with the decimal point below?
>
> -Stafford
>
>> else if (speed > 1000)
>> printf("%u.%03u MHz", ((unsigned int) speed/1000),
>> (unsigned int) (speed%1000));
Yeah we can. I think I made a cut-and-paste error when I originally did this
code. I'll submit a v2 to clean that up.
P.
>> --
>> 2.15.0.rc0.39.g2f0e14e64
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-10-25 13:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-23 11:56 [PATCH RESEND] cpupower: Fix no-rounding MHz frequency output Prarit Bhargava
2017-10-23 12:35 ` Stafford Horne
2017-10-25 13:41 ` Prarit Bhargava
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).