From patchwork Wed Apr 19 05:29:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 9686873 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 C339460375 for ; Wed, 19 Apr 2017 05:33:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B51D6268AE for ; Wed, 19 Apr 2017 05:33:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A9DE3283E8; Wed, 19 Apr 2017 05:33:22 +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=unavailable 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 40C79268AE for ; Wed, 19 Apr 2017 05:33:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759907AbdDSFdT (ORCPT ); Wed, 19 Apr 2017 01:33:19 -0400 Received: from mail-pg0-f46.google.com ([74.125.83.46]:36771 "EHLO mail-pg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759968AbdDSFb1 (ORCPT ); Wed, 19 Apr 2017 01:31:27 -0400 Received: by mail-pg0-f46.google.com with SMTP id g2so7363576pge.3 for ; Tue, 18 Apr 2017 22:31:27 -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=ahpmI1YLl0RT+Uo2v5QzlQE3xRyjtadMKU23p1gghBY=; b=KEaTY1ETyw8paFPEL3abDtpwMIQnFcCDWhhHycILe0qwwJoN8iJKybmEhI4HsqC7fJ a/gJowTtblYWrZUmNOHxP2EQDGMiFMhS6s+SdY+vv8CVNuk+iudzNEbgwi+ZcWbEQLYI gNCGYW3L3ai3JuSK9MNyjaEgFMQctTP5WWbCk= 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=ahpmI1YLl0RT+Uo2v5QzlQE3xRyjtadMKU23p1gghBY=; b=iSkDQCBdezddwdMpd6K28Jb1qGyxJ+8eRjWpXJefsKaqMJRG5Y3ELGWJV2A0JrxM3S 5kCY1ErozEoeGuqvI7O4+/4VonlJmKArybW2Ousf80m7sM+VPjtNGnYGPwnAxikUqQW4 unL3prhU6srFROA8Rem2+szKp2S73QIUseLf+925IFn8t4KWLoHaf+/p5epDqjhBkL2g r2w1F0ftaJVAQ98eYvAhE/C1PzKqoHPND0BO5KXMOEMw4aXswuT/pSifu+pyyvyX9IK/ CB4S0cYj+hhnoTIjLsjKg7LX8rnxe/S9KpEzCQ7CXRJrwQBJcdf5p1jlBaZTJLKPSPQq MqAw== X-Gm-Message-State: AN3rC/4vLGlyeGlzyD4sLHh/1++K69Qpkitz0fWM+cKBaL4X6fJNv+jb BWB+ksX1f/ve1jEY X-Received: by 10.98.78.195 with SMTP id c186mr1173296pfb.155.1492579886864; Tue, 18 Apr 2017 22:31:26 -0700 (PDT) Received: from localhost ([122.172.121.5]) by smtp.gmail.com with ESMTPSA id u23sm1664673pgo.58.2017.04.18.22.31.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Apr 2017 22:31:26 -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 V3 14/17] thermal: cpu_cooling: get_level() can't fail Date: Wed, 19 Apr 2017 10:59:09 +0530 Message-Id: <09e52ed89325153b65be7896918d7dcf8b7f1684.1492579345.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 --- 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 71d15448a293..762ddfc4e654 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; } /** @@ -623,13 +620,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;