From patchwork Fri Oct 26 12:35:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1651321 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id D2AAB3FD4E for ; Fri, 26 Oct 2012 12:37:38 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TRj8S-0007P1-8M; Fri, 26 Oct 2012 12:35:36 +0000 Received: from mail-pa0-f49.google.com ([209.85.220.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TRj8N-0007MJ-Bm for linux-arm-kernel@lists.infradead.org; Fri, 26 Oct 2012 12:35:32 +0000 Received: by mail-pa0-f49.google.com with SMTP id bi5so1758595pad.36 for ; Fri, 26 Oct 2012 05:35:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=J8yw1KhrBtPR9T5kgqorvxKSja2pC/K1pWXRy5P8gV4=; b=QjjrcKgFBBKgEygVUEphq5KvJ7wUePJZiF5yt5iddiWt5k/F17uleuYOowAzSrC3MU rgBIsZBrnOgWk6c73ekv0twueJfUoClg/3di28369RpG69gD7Ue/5+e4ZCwIZbFdHgwE sA17ZtxuE+/XmuTt8jQHKUkV7tBtGufagsvN50/q1oqSgHVQWSzhE7hvLwi6hYe62FBi LZ0m7ASFt9LoTXBL2Mh54sQgOZ8VARJ6Vxi0BzDJ7gbFDhbdPnmxqd56PDXVWuWu/q4d FMYcCMWX50J1dJ8nyn+8F0v6TZYcfZGvXR8d+Evpj87Yc/GvHwRgJtTcqU7I2t58ut5m Bduw== Received: by 10.66.80.66 with SMTP id p2mr61407916pax.84.1351254929318; Fri, 26 Oct 2012 05:35:29 -0700 (PDT) Received: from localhost ([122.167.123.224]) by mx.google.com with ESMTPS id oi2sm1113165pbb.62.2012.10.26.05.35.25 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 26 Oct 2012 05:35:28 -0700 (PDT) From: Viresh Kumar To: rjw@sisk.pl Subject: [PATCH RESEND] cpufreq: Make sure target freq is within limits Date: Fri, 26 Oct 2012 18:05:21 +0530 Message-Id: X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e X-Gm-Message-State: ALoCoQkzsBT8d31ST/qRFsm19eECumrc7P0LmAwLlKr0MRtVbHugkz0bNRqZeP9mK42a7tXBNvdi X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.220.49 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linaro-dev@lists.linaro.org, patches@linaro.org, Viresh Kumar , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org, pdsw-power-team@arm.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org __cpufreq_driver_target() must not pass target frequency beyond the limits of current policy. Today most of cpufreq platform drivers are doing this check in their target routines. Why not move it to __cpufreq_driver_target(). Signed-off-by: Viresh Kumar --- Hi Rafael, Resend doesn't contain any change, but fixed commit log drivers/cpufreq/cpufreq.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 28dc134..2f5ac2d 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1470,12 +1470,19 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, unsigned int relation) { int retval = -EINVAL; + unsigned int old_target_freq = target_freq; if (cpufreq_disabled()) return -ENODEV; - pr_debug("target for CPU %u: %u kHz, relation %u\n", policy->cpu, - target_freq, relation); + /* Make sure that target_freq is within supported range */ + if (target_freq > policy->max) + target_freq = policy->max; + if (target_freq < policy->min) + target_freq = policy->min; + + pr_debug("target for CPU %u: %u kHz, relation %u, requested %u kHz\n", + policy->cpu, target_freq, relation, old_target_freq); if (target_freq == policy->cur) return 0;