public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tools, cpupower Fix error condition in cmd_freq_set()
@ 2014-02-07 18:55 Prarit Bhargava
  2014-02-07 20:39 ` Prarit Bhargava
  0 siblings, 1 reply; 2+ messages in thread
From: Prarit Bhargava @ 2014-02-07 18:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Prarit Bhargava, Dominik Brodowski, Thomas Renninger,
	Rafael J. Wysocki, Alan Cox, One Thousand Gnomes

On a system which has only 4.00GHz set as the only available frequency,

[root@amd-pike-05 ~]# cpupower frequency-info
<snip>
  current policy: frequency should be within 4.00 GHz and 4.00 GHz.
                  The governor "userspace" may decide which speed to use
                  within this range.
<snip>

setting the frequency to 2.8GHz does not return an error.

[root@amd-pike-05 ~]# cpupower frequency-set --freq 2800MHz
Setting cpu: 0
Setting cpu: 1
Setting cpu: 2
Setting cpu: 3
Setting cpu: 4
Setting cpu: 5
Setting cpu: 6
Setting cpu: 7
[root@amd-pike-05 ~]#

The frequency set error should stop with an error message after the first
failure.  Fix the error return in cmd_freq_set() to read errors as less
than zero.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Thomas Renninger <trenn@suse.de>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: Alan Cox <alan@linux.intel.com>
Cc: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
---
 tools/power/cpupower/utils/cpufreq-set.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/power/cpupower/utils/cpufreq-set.c b/tools/power/cpupower/utils/cpufreq-set.c
index a416de8..e5f78623 100644
--- a/tools/power/cpupower/utils/cpufreq-set.c
+++ b/tools/power/cpupower/utils/cpufreq-set.c
@@ -320,7 +320,7 @@ int cmd_freq_set(int argc, char **argv)
 
 		printf(_("Setting cpu: %d\n"), cpu);
 		ret = do_one_cpu(cpu, &new_pol, freq, policychange);
-		if (ret)
+		if (ret < 0)
 			break;
 	}
 
-- 
1.7.9.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] tools, cpupower Fix error condition in cmd_freq_set()
  2014-02-07 18:55 [PATCH] tools, cpupower Fix error condition in cmd_freq_set() Prarit Bhargava
@ 2014-02-07 20:39 ` Prarit Bhargava
  0 siblings, 0 replies; 2+ messages in thread
From: Prarit Bhargava @ 2014-02-07 20:39 UTC (permalink / raw)
  To: Prarit Bhargava
  Cc: linux-kernel, Dominik Brodowski, Thomas Renninger,
	Rafael J. Wysocki, Alan Cox, One Thousand Gnomes



On 02/07/2014 01:55 PM, Prarit Bhargava wrote:
> On a system which has only 4.00GHz set as the only available frequency,
> 
> [root@amd-pike-05 ~]# cpupower frequency-info
> <snip>
>   current policy: frequency should be within 4.00 GHz and 4.00 GHz.
>                   The governor "userspace" may decide which speed to use
>                   within this range.
> <snip>
> 
> setting the frequency to 2.8GHz does not return an error.
> 
> [root@amd-pike-05 ~]# cpupower frequency-set --freq 2800MHz
> Setting cpu: 0
> Setting cpu: 1
> Setting cpu: 2
> Setting cpu: 3
> Setting cpu: 4
> Setting cpu: 5
> Setting cpu: 6
> Setting cpu: 7
> [root@amd-pike-05 ~]#
> 
> The frequency set error should stop with an error message after the first
> failure.  Fix the error return in cmd_freq_set() to read errors as less
> than zero.
> 
> Signed-off-by: Prarit Bhargava <prarit@redhat.com>
> Cc: Dominik Brodowski <linux@dominikbrodowski.net>
> Cc: Thomas Renninger <trenn@suse.de>
> Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
> Cc: Alan Cox <alan@linux.intel.com>
> Cc: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
> ---
>  tools/power/cpupower/utils/cpufreq-set.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/power/cpupower/utils/cpufreq-set.c b/tools/power/cpupower/utils/cpufreq-set.c
> index a416de8..e5f78623 100644
> --- a/tools/power/cpupower/utils/cpufreq-set.c
> +++ b/tools/power/cpupower/utils/cpufreq-set.c
> @@ -320,7 +320,7 @@ int cmd_freq_set(int argc, char **argv)
>  
>  		printf(_("Setting cpu: %d\n"), cpu);
>  		ret = do_one_cpu(cpu, &new_pol, freq, policychange);
> -		if (ret)
> +		if (ret < 0)

Self-nack ... this won't work.

P.
>  			break;
>  	}
>  

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-02-07 20:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-07 18:55 [PATCH] tools, cpupower Fix error condition in cmd_freq_set() Prarit Bhargava
2014-02-07 20:39 ` Prarit Bhargava

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox