From patchwork Mon Apr 17 06:01:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 97502 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp1212757qgf; Sun, 16 Apr 2017 23:03:55 -0700 (PDT) X-Received: by 10.98.72.86 with SMTP id v83mr2079330pfa.29.1492409035549; Sun, 16 Apr 2017 23:03:55 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g26si10020227pge.96.2017.04.16.23.03.55; Sun, 16 Apr 2017 23:03:55 -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 S932967AbdDQGDe (ORCPT + 12 others); Mon, 17 Apr 2017 02:03:34 -0400 Received: from mail-pg0-f43.google.com ([74.125.83.43]:36808 "EHLO mail-pg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932989AbdDQGDc (ORCPT ); Mon, 17 Apr 2017 02:03:32 -0400 Received: by mail-pg0-f43.google.com with SMTP id g2so67324276pge.3 for ; Sun, 16 Apr 2017 23:03:32 -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=DWPc9OP4YILOJaC/aFXluQxItm3LNrgmYWqZRjNNVY8=; b=fSvZChuohLJgqKaaHirtYvvztydQgpLVf5n9qUMXRvWdHsqqF/tvddifR51y7kbmbc FqjYKWp5bEE9P7AQniqsvNtD9XCRFKdE05aC1rIRJMSUNcJcmgsPDhpDkHrrGZvYoeNZ mJhHiMlyEVVi8j1k86ExuwnVcDX7Y3sKnu3PU= 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=DWPc9OP4YILOJaC/aFXluQxItm3LNrgmYWqZRjNNVY8=; b=gHRsQD5HIkrwj5dZzQ5ASOe2NNxLjSuzgcfff/T1SxQu3h7ypQqRQKWGXbWYzC/nu6 DR7tcN41UBWqJad8YgmIDFuydnFZlaFLee7GWXGe3t6PTfVvPD3+iIa1savFgM5V5I3G YEf+INnWX2G9yd+cp9hWgcJFWKX5yk79Rul/Kzz+wlmlfasV0v9xHYHnQoeC2CdfPUEV HflLVmYFoo45HTGlcE+uDSE5/5N6nlcfzljKPbDvKOMJS71rtzasD4CI+aevMSrN/WEO o/oP37/9qqCjF1IRFJIWLXo7K7RQB/TNidTQuKrPnUhY/xju8PaIThVA5af+Dj2j4oDH olxw== X-Gm-Message-State: AN3rC/7ZzFaAhsJGdqMcWqhtScyZe5d8myvLrNqw17jV3317bC3vCa7q ivoPi3XmQoqBMOFw X-Received: by 10.84.236.10 with SMTP id q10mr13788024plk.1.1492409011562; Sun, 16 Apr 2017 23:03:31 -0700 (PDT) Received: from localhost ([122.172.121.5]) by smtp.gmail.com with ESMTPSA id r7sm15297099pfj.20.2017.04.16.23.03.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Apr 2017 23:03:30 -0700 (PDT) From: Viresh Kumar To: Javi Merino , Zhang Rui , Eduardo Valentin , 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 Subject: [PATCH V2 14/17] thermal: cpu_cooling: get_level() can't fail Date: Mon, 17 Apr 2017 11:31:59 +0530 Message-Id: <97570bba76733addd028e3292d02d70035a029c4.1492408342.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 --- 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 fa29f830fdc0..4ec9234488c6 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;