From patchwork Thu Dec 4 04:11:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 41901 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E2E6B25E88 for ; Thu, 4 Dec 2014 04:13:54 +0000 (UTC) Received: by mail-wg0-f71.google.com with SMTP id l18sf10295458wgh.10 for ; Wed, 03 Dec 2014 20:13:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=czULiA1oypz/rCZNZvwfnRiatsnx9cOIe0tuOogkX8Q=; b=QfvnWIL/VYuo7gLU4DsJ3tF8p4pzB1o0Qi4j4vnPKS1pIck1CWErOPOSVhm1w9AdTJ nTleXlAa7gz/9BxHt9A8mEknJGw/thg3aY0O/shIBOxRKrpc/AC7K/Wrp8ni6/fYJ9op C+iaTUjWkDsWcUYqFTJdCKBOo+qUxCR8MYocAGkVjZmdcUIG8HrT/rnbs83oKM2O3K8A tzHJhsyfXUF5QvDzEVztHqUVSgNDg0U1Ls1pKqHPdiMrXMrPNgF7Nr2vnsZ88/zmMMih Po5A5RCqxV920OGznFcl+FK2MFe8aZYftePGhC5ECLpBsGnuB1e9wRLwQ2vKeSDvpck2 nDWg== X-Gm-Message-State: ALoCoQl86wGkcu6DU/MD/evYf7Us8OGAZrYjRQaDUMijKO1jq5huGUlMROdUy99AKql5DojlsWW3 X-Received: by 10.180.94.3 with SMTP id cy3mr2810949wib.7.1417666434260; Wed, 03 Dec 2014 20:13:54 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.166 with SMTP id t6ls257674lat.20.gmail; Wed, 03 Dec 2014 20:13:54 -0800 (PST) X-Received: by 10.152.37.38 with SMTP id v6mr7487205laj.10.1417666434104; Wed, 03 Dec 2014 20:13:54 -0800 (PST) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id os10si24693991lbb.3.2014.12.03.20.13.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Dec 2014 20:13:54 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by mail-lb0-f175.google.com with SMTP id u10so13235606lbd.6 for ; Wed, 03 Dec 2014 20:13:54 -0800 (PST) X-Received: by 10.112.189.10 with SMTP id ge10mr7118614lbc.23.1417666434035; Wed, 03 Dec 2014 20:13:54 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp781082lbc; Wed, 3 Dec 2014 20:13:53 -0800 (PST) X-Received: by 10.70.50.1 with SMTP id y1mr15296928pdn.12.1417666432418; Wed, 03 Dec 2014 20:13:52 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id df1si18139882pdb.237.2014.12.03.20.13.51 for ; Wed, 03 Dec 2014 20:13:52 -0800 (PST) Received-SPF: none (google.com: linux-pm-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753015AbaLDENv (ORCPT + 12 others); Wed, 3 Dec 2014 23:13:51 -0500 Received: from mail-pa0-f53.google.com ([209.85.220.53]:60778 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753005AbaLDENu (ORCPT ); Wed, 3 Dec 2014 23:13:50 -0500 Received: by mail-pa0-f53.google.com with SMTP id kq14so16912372pab.26 for ; Wed, 03 Dec 2014 20:13:50 -0800 (PST) X-Received: by 10.66.231.10 with SMTP id tc10mr14968319pac.112.1417666430321; Wed, 03 Dec 2014 20:13:50 -0800 (PST) Received: from localhost ([122.166.92.172]) by mx.google.com with ESMTPSA id v4sm22532593pdc.61.2014.12.03.20.13.49 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 03 Dec 2014 20:13:49 -0800 (PST) From: Viresh Kumar To: linux-pm@vger.kernel.org, edubezval@gmail.com Cc: linaro-kernel@lists.linaro.org, rui.zhang@intel.com, amit.daniel@samsung.com, javi.merino@arm.com, Viresh Kumar Subject: [PATCH V2 17/26] thermal: cpu_cooling: initialize 'cpufreq_val' on registration Date: Thu, 4 Dec 2014 09:41:59 +0530 Message-Id: <09752de4819071ad00297894d53439d801b7c120.1417664938.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.0.3.693.g996b0fd In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , There is no point checking for validity of 'cpufreq_val' from cpufreq_thermal_notifier() every time the routine is called. Its guaranteed to be 0 on the first call but will be valid otherwise. Lets update it once while the device registers. Signed-off-by: Viresh Kumar --- drivers/thermal/cpu_cooling.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 491d90a..86bcf8d 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -316,11 +316,6 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb, &cpufreq_dev->allowed_cpus)) continue; - if (!cpufreq_dev->cpufreq_val) - cpufreq_dev->cpufreq_val = get_cpu_frequency( - cpumask_any(&cpufreq_dev->allowed_cpus), - cpufreq_dev->cpufreq_state); - max_freq = cpufreq_dev->cpufreq_val; if (policy->max != max_freq) @@ -444,6 +439,13 @@ __cpufreq_cooling_register(struct device_node *np, if (!cpufreq_dev) return ERR_PTR(-ENOMEM); + cpufreq_dev->cpufreq_val = get_cpu_frequency(cpumask_any(clip_cpus), 0); + if (!cpufreq_dev->cpufreq_val) { + pr_err("%s: Failed to get frequency", __func__); + cool_dev = ERR_PTR(-EINVAL); + goto free_cdev; + } + cpumask_copy(&cpufreq_dev->allowed_cpus, clip_cpus); ret = get_idr(&cpufreq_idr, &cpufreq_dev->id);