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: 5435171 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 E7559BEEA8 for ; Thu, 4 Dec 2014 04:13:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9F9262024F for ; Thu, 4 Dec 2014 04:13:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B933620254 for ; Thu, 4 Dec 2014 04:13:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753019AbaLDENz (ORCPT ); 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-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=DBin1NBG4RSDqHQjOQn1nUHCojT/wJE/9ssw7bnmzQA=; b=kxdmz9XHWHeZQunVHO09ul8QYhXVgu4KYEOSaJpFkjy1SSoUYuFzuHtA6SPA3QpdCh jiPzQ5LfQ6RK/Aj32vK7gPyxjq1VK++s3NZ/R1yv3WyONPm8485esGnZFEI4A1mGrZKz H6DY2Tyz2UHVOe6Yypf+kU5CQshjPBi1HKvao4J72Y8BKCEXBoPbnaguJJ1fnsQ1XReU msQ2JrChUnsg25WQwSbgkmPHCrmZ9SNEOWPSvmz2fR5xaYFT8S9OTWeZZLZWVgs7hIm6 MYkgLW3zPFcnu8Zz2W1i4GrpoUmFiGjouAxFHepl9v9et/vnZHnOg2c+M/37BVg9dxrO Ww6A== X-Gm-Message-State: ALoCoQnNqJjea2XLFaXHCLlX/FQxIQNNuJsxS6wbM6BdBf0uMQfPHH55WYlN6QJyKYwFcrfwVfmk 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: 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=unavailable 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 | 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 */