linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert+renesas@glider.be>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Viresh Kumar <viresh.kumar@linaro.org>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	cpufreq@vger.kernel.org, linux-pm@vger.kernel.org
Subject: [PATCH 3/3] cpufreq: ppc: Fix handling of non-existent clocks
Date: Thu, 17 Apr 2014 11:53:27 +0200	[thread overview]
Message-ID: <1397728407-13909-3-git-send-email-geert+renesas@glider.be> (raw)
In-Reply-To: <1397728407-13909-1-git-send-email-geert+renesas@glider.be>

If the clock doesn't exist, clk_get_rate() returns -EINVAL, which becomes
a large number (freq is u32), failing the "freq < min_cpufreq" test.
Explicitly test for "(u32)-EINVAL" to fix this.

Update the comment, and fix a grammer issue while we're at it.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/cpufreq/ppc-corenet-cpufreq.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/cpufreq/ppc-corenet-cpufreq.c b/drivers/cpufreq/ppc-corenet-cpufreq.c
index 53881d78a931..7027eab814ce 100644
--- a/drivers/cpufreq/ppc-corenet-cpufreq.c
+++ b/drivers/cpufreq/ppc-corenet-cpufreq.c
@@ -179,10 +179,11 @@ static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy)
 		clk = of_clk_get(data->parent, i);
 		freq = clk_get_rate(clk);
 		/*
-		 * the clock is valid if its frequency is not masked
-		 * and large than minimum allowed frequency.
+		 * the clock is valid if it exists, its frequency is not
+		 * masked, and larger than minimum allowed frequency.
 		 */
-		if (freq < min_cpufreq || (mask & (1 << i)))
+		if (freq == (u32)-EINVAL || freq < min_cpufreq ||
+		    (mask & (1 << i)))
 			table[i].frequency = CPUFREQ_ENTRY_INVALID;
 		else
 			table[i].frequency = freq / 1000;
-- 
1.7.9.5

  parent reply	other threads:[~2014-04-17 10:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-17  9:53 [PATCH 1/3] cpufreq: ppc: Add missing #include <asm/smp.h> Geert Uytterhoeven
2014-04-17  9:53 ` [PATCH 2/3] cpufreq: ppc: Fix integer overflow in expression Geert Uytterhoeven
2014-04-21  5:52   ` Viresh Kumar
2014-04-17  9:53 ` Geert Uytterhoeven [this message]
2014-04-21  6:01   ` [PATCH 3/3] cpufreq: ppc: Fix handling of non-existent clocks Viresh Kumar
2014-04-21  8:01     ` Geert Uytterhoeven
2014-04-21  5:51 ` [PATCH 1/3] cpufreq: ppc: Add missing #include <asm/smp.h> Viresh Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1397728407-13909-3-git-send-email-geert+renesas@glider.be \
    --to=geert+renesas@glider.be \
    --cc=cpufreq@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=rjw@rjwysocki.net \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).