From patchwork Tue Apr 25 10:27:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 98191 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp1880047qgf; Tue, 25 Apr 2017 03:29:29 -0700 (PDT) X-Received: by 10.98.209.74 with SMTP id t10mr28300305pfl.203.1493116169281; Tue, 25 Apr 2017 03:29:29 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l12si21879097plk.280.2017.04.25.03.29.28; Tue, 25 Apr 2017 03:29:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1429642AbdDYK2q (ORCPT + 14 others); Tue, 25 Apr 2017 06:28:46 -0400 Received: from mail-pf0-f174.google.com ([209.85.192.174]:36375 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1429598AbdDYK2W (ORCPT ); Tue, 25 Apr 2017 06:28:22 -0400 Received: by mail-pf0-f174.google.com with SMTP id 194so25043785pfv.3 for ; Tue, 25 Apr 2017 03:28:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=dfM3Z0N189A4LrnU83F6bYdw21RpAiNWdlQnhZk/yBY=; b=j4O1Bocf5VeAxC0dCXJydG7c8rxiN5AMv5imy48GvR1Od6puWtECSDi38VRJwWRnzt pWllCRv/KKViGMEHDxpnTS8HK40YKtcQeiz1bAjoHsNMdKqsy061/JuSNCN4LdmJIti5 WdOapFr+jIrJ0z4ylv4gKkMQyMa1XIno8a/OI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=dfM3Z0N189A4LrnU83F6bYdw21RpAiNWdlQnhZk/yBY=; b=fBv5XEGINWHxaX2wsJXCRRtgvSGNSaz2IOiz67wcyh/Ka7QnkyU+yEYF2uj98BXHh5 iEA4hmqGw17z4ihw1Otnbg3DeX7x+a5zlwiFxHUBcnBt22+ufpao/JC2t8FChwvvnarH 7UaZDZLtOavm8BJTNdaEYwkEAiel59/1Thl6xCTq9HZ7yFoxoKVWtpNIHyxeyd84jKlF 549sunNkGIlcvTj4TXQ48f8fyu7BF3FgaYSHF9N0WZG4+yDe9oaiIKlyw80lohK68uDG cYg5iPHABfsOjrdFFEjiLu53Qeoz0wd7+VLmbSniO2XUl+xwrhKzRuNY4Fn0hAprtwGH pDfg== X-Gm-Message-State: AN3rC/75TYCgRymx9N2gow7svMZfOe6V+kpBXRtDIlGaVCkjIrOQTjcz MEq8XhE6gp43i/It X-Received: by 10.84.134.35 with SMTP id 32mr11292490plg.178.1493116096354; Tue, 25 Apr 2017 03:28:16 -0700 (PDT) Received: from localhost ([122.172.121.5]) by smtp.gmail.com with ESMTPSA id s3sm35894979pgn.29.2017.04.25.03.28.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Apr 2017 03:28:15 -0700 (PDT) From: Viresh Kumar To: Javi Merino , Zhang Rui , Eduardo Valentin , Lukasz Luba , Amit Daniel Kachhap , Viresh Kumar Cc: linaro-kernel@lists.linaro.org, Rafael Wysocki , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot , Punit Agrawal Subject: [PATCH V4 14/17] thermal: cpu_cooling: get_level() can't fail Date: Tue, 25 Apr 2017 15:57:21 +0530 Message-Id: <312061b66700517ab58889f5f781ccd4e1e8a5d7.1493115651.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.12.0.432.g71c3a4f4ba37 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 The frequency passed to get_level() is returned by cpu_power_to_freq() and it is guaranteed that get_level() can't fail. Get rid of error code. Signed-off-by: Viresh Kumar Tested-by: Lukasz Luba --- drivers/thermal/cpu_cooling.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) -- 2.12.0.432.g71c3a4f4ba37 diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 11735dba1456..2c2d76ac04c3 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -119,22 +119,19 @@ static LIST_HEAD(cpufreq_cdev_list); * @cpufreq_cdev: cpufreq_cdev for which the property is required * @freq: Frequency * - * Return: level on success, THERMAL_CSTATE_INVALID on error. + * Return: level corresponding to the frequency. */ static unsigned long get_level(struct cpufreq_cooling_device *cpufreq_cdev, unsigned int freq) { + struct freq_table *freq_table = cpufreq_cdev->freq_table; unsigned long level; - for (level = 0; level <= cpufreq_cdev->max_level; level++) { - if (freq == cpufreq_cdev->freq_table[level].frequency) - return level; - - if (freq > cpufreq_cdev->freq_table[level].frequency) + for (level = 1; level <= cpufreq_cdev->max_level; level++) + if (freq > freq_table[level].frequency) break; - } - return THERMAL_CSTATE_INVALID; + return level - 1; } /** @@ -627,13 +624,6 @@ static int cpufreq_power2state(struct thermal_cooling_device *cdev, target_freq = cpu_power_to_freq(cpufreq_cdev, normalised_power); *state = get_level(cpufreq_cdev, target_freq); - if (*state == THERMAL_CSTATE_INVALID) { - dev_err_ratelimited(&cdev->device, - "Failed to convert %dKHz for cpu %d into a cdev state\n", - target_freq, policy->cpu); - return -EINVAL; - } - trace_thermal_power_cpu_limit(policy->related_cpus, target_freq, *state, power); return 0;