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: 9697863 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E2E8F60224 for ; Tue, 25 Apr 2017 10:29:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC4AE285E9 for ; Tue, 25 Apr 2017 10:29:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0AFF28609; Tue, 25 Apr 2017 10:29:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC2BF28600 for ; Tue, 25 Apr 2017 10:29:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1429642AbdDYK2q (ORCPT ); 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 X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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;