From patchwork Thu Apr 17 09:53:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 339827 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 57D821402CB for ; Thu, 17 Apr 2014 20:06:10 +1000 (EST) X-Greylist: delayed 711 seconds by postgrey-1.34 at bilbo; Thu, 17 Apr 2014 20:05:29 EST Received: from wilson.telenet-ops.be (wilson.telenet-ops.be [195.130.132.42]) by ozlabs.org (Postfix) with ESMTP id 2CF9A140307 for ; Thu, 17 Apr 2014 20:05:28 +1000 (EST) Received: from andre.telenet-ops.be (andre.telenet-ops.be [195.130.132.53]) by wilson.telenet-ops.be (Postfix) with ESMTP id 45C35346F2 for ; Thu, 17 Apr 2014 11:53:34 +0200 (CEST) Received: from ayla.of.borg ([84.193.72.141]) by andre.telenet-ops.be with bizsmtp id qxtZ1n01C32ts5g01xtZcU; Thu, 17 Apr 2014 11:53:33 +0200 Received: from geert by ayla.of.borg with local (Exim 4.76) (envelope-from ) id 1Waj0f-0003cz-LI; Thu, 17 Apr 2014 11:53:33 +0200 From: Geert Uytterhoeven To: "Rafael J. Wysocki" , Viresh Kumar Subject: [PATCH 3/3] cpufreq: ppc: Fix handling of non-existent clocks Date: Thu, 17 Apr 2014 11:53:27 +0200 Message-Id: <1397728407-13909-3-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1397728407-13909-1-git-send-email-geert+renesas@glider.be> References: <1397728407-13909-1-git-send-email-geert+renesas@glider.be> Cc: Geert Uytterhoeven , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 --- 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;