From patchwork Fri Nov 28 09:44:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 5402481 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1E903BEEA8 for ; Fri, 28 Nov 2014 09:45:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2BF8320148 for ; Fri, 28 Nov 2014 09:45:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 490492013D for ; Fri, 28 Nov 2014 09:45:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751763AbaK1Jpm (ORCPT ); Fri, 28 Nov 2014 04:45:42 -0500 Received: from mail-pd0-f178.google.com ([209.85.192.178]:55558 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751761AbaK1Jpl (ORCPT ); Fri, 28 Nov 2014 04:45:41 -0500 Received: by mail-pd0-f178.google.com with SMTP id g10so6460358pdj.9 for ; Fri, 28 Nov 2014 01:45:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=eq0Yrtpu4oe3ftg5lwTtWklzNS4AG5JeO0/v4A+Y9lI=; b=LlzvKkhlLX26wNjgs2/BQjPsihwVOIcPVoAe/3QXj3vjqfXKCGSJQbSMv7am4o+azF ESJTJGpJf5tfnovHxBJSvZQwsOeE9LJ+wnKY/hYEy4ZkzZI55d/FoBAoj1qrpe5Otjdb Fkurtrzc7eKCoYVSf4Pf8bfJo3f6kMjcLqZ4QX8abzSBbBlYxVDkWyLgxXg1z1L3KBwz WTGzA8MY5/bRcFkXd1TZWMPMpu/WlRSFfNKj6WqiyhOPp1aMEWavNF/Y1pFMjCrdElZ7 8MhZCaw9RYecUYjZYJQI8UhU3HMFgFF7eUBCmbXLFp91jIee3T/M32FhFXidC8fo709I K1zg== X-Gm-Message-State: ALoCoQk0PJHGEY/NK+aazJIakpMUY40Hm7hiHnMVGykXji4q1k1tyG7zhj/S/4KgkhQWa6QwmgPW X-Received: by 10.66.97.39 with SMTP id dx7mr71626036pab.65.1417167941455; Fri, 28 Nov 2014 01:45:41 -0800 (PST) Received: from localhost ([122.167.111.40]) by mx.google.com with ESMTPSA id zn2sm9360959pbb.41.2014.11.28.01.45.40 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 28 Nov 2014 01:45:40 -0800 (PST) From: Viresh Kumar To: linux-pm@vger.kernel.org, edubezval@gmail.com Cc: linaro-kernel@lists.linaro.org, rui.zhang@intel.com, Viresh Kumar Subject: [PATCH 17/26] cpu_cooling: Merge cpufreq_apply_cooling() into cpufreq_set_cur_state() Date: Fri, 28 Nov 2014 15:14:11 +0530 Message-Id: <24d76b5957d9c9c54f372f1ba8cc5cee8faf0d64.1417167599.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: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 | 58 ++++++++++++++----------------------------- 1 file changed, 19 insertions(+), 39 deletions(-) diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index ca8f1bb..9673b48 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -219,44 +219,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; - notify_device = cpufreq_device; - - cpufreq_update_policy(cpu); - - notify_device = NOTIFY_INVALID; - - 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. @@ -357,8 +319,26 @@ 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; - return cpufreq_apply_cooling(cpufreq_device, state); + /* Check if the old cooling action is same as new cooling action */ + if (cpufreq_device->cpufreq_state == state) + return 0; + + clip_freq = get_cpu_frequency(cpu, state); + if (!clip_freq) + return -EINVAL; + + cpufreq_device->cpufreq_state = state; + cpufreq_device->cpufreq_val = clip_freq; + notify_device = cpufreq_device; + + cpufreq_update_policy(cpu); + + notify_device = NOTIFY_INVALID; + + return 0; } /* Bind cpufreq callbacks to thermal cooling device ops */