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: 97603 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp159671qgf; Tue, 18 Apr 2017 22:32:51 -0700 (PDT) X-Received: by 10.84.204.8 with SMTP id a8mr1593431ple.4.1492579971327; Tue, 18 Apr 2017 22:32:51 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m77si1320339pfk.78.2017.04.18.22.32.51; Tue, 18 Apr 2017 22:32:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1760092AbdDSFct (ORCPT + 17 others); Wed, 19 Apr 2017 01:32:49 -0400 Received: from mail-pg0-f45.google.com ([74.125.83.45]:36771 "EHLO mail-pg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759948AbdDSFbc (ORCPT ); Wed, 19 Apr 2017 01:31:32 -0400 Received: by mail-pg0-f45.google.com with SMTP id g2so7363574pge.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=W2iubgiv+FjeWV5wpOltNURlYHA49eBQ5lTFLpR36tWs+YidlzqNuowv8/jcbiWB6h CopeZG23eiHFHQQQT0uxKVDSZdEWvV9soNCIqxbVuZmFDzdmV97LR92KfC4yCLo5iqpK RBkpJmDHfI/oNFOaa51ET8o1MLRwpkkDHfFVdDveViyRUQK1EcEbDqtzyQQOOrB9QKX3 xJoPU8iomLruu6X6hlEcmtes6x3DBpID29YLsyA2hBruTJjSK0Zjprk5taVZGFw73pYP GJD8yB8Ikcr1j93TYy84BAOwrIEwVfPnr+PprrTndOk/6ynqpFhqH1JEfHyzfiRl2w/J o5ig== X-Gm-Message-State: AN3rC/6+NREoGLv9O1gPril/+mso0d24Tlo7w3oLKfOTRmO7GwNGsKxQ TzLAeaQfpigORaw3 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 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;