From patchwork Thu Dec 4 04:12:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 41902 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 77A4B25E88 for ; Thu, 4 Dec 2014 04:13:59 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id l15sf10551274wiw.0 for ; Wed, 03 Dec 2014 20:13:58 -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=cUmtx5xzjDWsu1Mq7qNRF5vFt6SEuP5ZLsHBzfiPqLA=; b=LXEnfIqZ6hpRVtqZhEgT2p+HoZrOcmjvFNSGcANYELQwRo3FiPgI5HLkuLKPFTJTDV lPgzS7AKzZBT/mazOMutnLlL2u2QgZBA0EWCxS7Ec+QHPU+gepov2XuP7VhflCE4F80Q 6YQLW4zQhMiqs3fVSuVgszQ8aJBAbrbHu2qWA+KjCenDGCLMxWxg8wy0vXN7AEmr2i7B lmvpNcl7fyvCQ7/wWS1ed2qmZx0r9w7If9nUJ03fovfgudY/yHzBsLoQOZoMkONYbq0v R+ggrWLxptQ/FttanJsfdXiyFaEsUM3A3h2GQ0GKs9bEjFP5K3iSeZrum6C9rFdAlZZP Nxqw== X-Gm-Message-State: ALoCoQmjM9+ILabg5GpYIAm0NnZwxLyDI4sK7/o/XVmik+SBoUNdgSO2dsLiGYoiXfvJyTzsnG53 X-Received: by 10.112.32.163 with SMTP id k3mr7086lbi.17.1417666438658; Wed, 03 Dec 2014 20:13:58 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.39 with SMTP id b7ls200529lae.38.gmail; Wed, 03 Dec 2014 20:13:58 -0800 (PST) X-Received: by 10.152.5.132 with SMTP id s4mr7229787las.39.1417666438261; Wed, 03 Dec 2014 20:13:58 -0800 (PST) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id bc1si24630400lbc.80.2014.12.03.20.13.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Dec 2014 20:13:58 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by mail-lb0-f169.google.com with SMTP id p9so13465778lbv.0 for ; Wed, 03 Dec 2014 20:13:58 -0800 (PST) X-Received: by 10.152.43.12 with SMTP id s12mr7075429lal.67.1417666438174; Wed, 03 Dec 2014 20:13:58 -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 ew9csp781088lbc; Wed, 3 Dec 2014 20:13:57 -0800 (PST) X-Received: by 10.70.87.173 with SMTP id az13mr14948150pdb.134.1417666436470; Wed, 03 Dec 2014 20:13:56 -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.55 for ; Wed, 03 Dec 2014 20:13:56 -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 S1753019AbaLDENz (ORCPT + 12 others); Wed, 3 Dec 2014 23:13:55 -0500 Received: from mail-pa0-f48.google.com ([209.85.220.48]:57367 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753014AbaLDENy (ORCPT ); Wed, 3 Dec 2014 23:13:54 -0500 Received: by mail-pa0-f48.google.com with SMTP id rd3so17124729pab.35 for ; Wed, 03 Dec 2014 20:13:54 -0800 (PST) X-Received: by 10.66.246.196 with SMTP id xy4mr15089863pac.29.1417666434473; Wed, 03 Dec 2014 20:13:54 -0800 (PST) Received: from localhost ([122.166.92.172]) by mx.google.com with ESMTPSA id kj3sm8352915pdb.85.2014.12.03.20.13.53 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 03 Dec 2014 20:13:53 -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 18/26] thermal: cpu_cooling: Merge cpufreq_apply_cooling() into cpufreq_set_cur_state() Date: Thu, 4 Dec 2014 09:42:00 +0530 Message-Id: <0d5df172b71fae0d9becd9389f7cf3c74163b7e9.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.169 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: , cpufreq_apply_cooling() has a single caller, cpufreq_set_cur_state() and cpufreq_set_cur_state() is an unnecessary wrapper over cpufreq_apply_cooling(). Get rid of it by merging both routines. Signed-off-by: Viresh Kumar --- drivers/thermal/cpu_cooling.c | 52 +++++++++++++------------------------------ 1 file changed, 16 insertions(+), 36 deletions(-) diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 86bcf8d..a3dd74f 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -254,41 +254,6 @@ static unsigned int get_cpu_frequency(unsigned int cpu, unsigned long level) } /** - * cpufreq_apply_cooling - function to apply frequency clipping. - * @cpufreq_device: cpufreq_cooling_device pointer containing frequency - * clipping data. - * @cooling_state: value of the cooling state. - * - * Function used to make sure the cpufreq layer is aware of current thermal - * limits. The limits are applied by updating the cpufreq policy. - * - * Return: 0 on success, an error code otherwise (-EINVAL in case wrong - * cooling state). - */ -static int cpufreq_apply_cooling(struct cpufreq_cooling_device *cpufreq_device, - unsigned long cooling_state) -{ - unsigned int clip_freq; - struct cpumask *mask = &cpufreq_device->allowed_cpus; - unsigned int cpu = cpumask_any(mask); - - /* Check if the old cooling action is same as new cooling action */ - if (cpufreq_device->cpufreq_state == cooling_state) - return 0; - - clip_freq = get_cpu_frequency(cpu, cooling_state); - if (!clip_freq) - return -EINVAL; - - cpufreq_device->cpufreq_state = cooling_state; - cpufreq_device->cpufreq_val = clip_freq; - - cpufreq_update_policy(cpu); - - return 0; -} - -/** * cpufreq_thermal_notifier - notifier callback for cpufreq policy change. * @nb: struct notifier_block * with callback info. * @event: value showing cpufreq event for which this function invoked. @@ -391,8 +356,23 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state) { struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; + unsigned int cpu = cpumask_any(&cpufreq_device->allowed_cpus); + unsigned int clip_freq; + + /* Check if the old cooling action is same as new cooling action */ + if (cpufreq_device->cpufreq_state == state) + return 0; - return cpufreq_apply_cooling(cpufreq_device, state); + clip_freq = get_cpu_frequency(cpu, state); + if (!clip_freq) + return -EINVAL; + + cpufreq_device->cpufreq_state = state; + cpufreq_device->cpufreq_val = clip_freq; + + cpufreq_update_policy(cpu); + + return 0; } /* Bind cpufreq callbacks to thermal cooling device ops */