From patchwork Tue Nov 22 12:34:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caesar Wang X-Patchwork-Id: 9440979 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 72C1A60237 for ; Tue, 22 Nov 2016 12:35:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63A1728476 for ; Tue, 22 Nov 2016 12:35:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5873D28520; Tue, 22 Nov 2016 12:35:47 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1259528476 for ; Tue, 22 Nov 2016 12:35:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c9AIc-0006FL-Jv; Tue, 22 Nov 2016 12:35:46 +0000 Received: from mail-pg0-f67.google.com ([74.125.83.67]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c9AIZ-00067i-P3 for linux-rockchip@lists.infradead.org; Tue, 22 Nov 2016 12:35:44 +0000 Received: by mail-pg0-f67.google.com with SMTP id 3so2049379pgd.0 for ; Tue, 22 Nov 2016 04:35:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XA6ux3BSzE1NZb8gW6gT0I9edIe05BMpv6NeYi+LK+w=; b=Sht0CqnLLhg8waBKkycqo7ca16ThyRRzuLsSu1mc1VhcGkxGsJW9E93/rk3IPiPFsx wK/AO9HX9W6VwHSJPxEBXeweE+7v7FbOSlT2UwONb+Fy+bZHJdq00jYOmZ3wnKRTkoy0 hj121VH5NAKSwJR8GQlvNk6UM267HA5G9ymq0Rqm5l/rRRHX3RSTO9xxscB+T5jtJ8rG EJFQHaqY/vNRbjfFNwJSkYmmcRbtLJq+2OaXg9PcNrGFcf+ruEddYbZ8ZB38lCQSnQ1f qOUo7Aj7fBXVYs+qM98QtJdZwWY/YFeNqOPsTShofzoyMXUE2t+RVqR/uW9LnndJQhu2 qbVQ== X-Gm-Message-State: AKaTC03KLyauuXgCVmGjlI0A5vUspU77zYyCKUN3XohcIEhDSymWP8hMi0igq1LY0EIurw== X-Received: by 10.98.89.6 with SMTP id n6mr25644331pfb.43.1479818122791; Tue, 22 Nov 2016 04:35:22 -0800 (PST) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id m5sm27140335pgn.42.2016.11.22.04.35.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Nov 2016 04:35:20 -0800 (PST) From: Caesar Wang To: edubezval@gmail.com, rui.zhang@intel.com Subject: [PATCH 3/5] thermal: rockchip: fixes invalid temperature case Date: Tue, 22 Nov 2016 20:34:46 +0800 Message-Id: <1479818088-6007-4-git-send-email-wxt@rock-chips.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479818088-6007-1-git-send-email-wxt@rock-chips.com> References: <1479818088-6007-1-git-send-email-wxt@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161122_043543_893195_D29D58DB X-CRM114-Status: UNSURE ( 9.41 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: heiko@sntech.de, linux-pm@vger.kernel.org, briannorris@chromium.org, linux-kernel@vger.kernel.org, smbarber@chromium.org, linux-rockchip@lists.infradead.org, Caesar Wang MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The temp_to_code function will return 0 when we set the trip points value or valid temperature. This patch will prevent this case happening. Signed-off-by: Caesar Wang --- drivers/thermal/rockchip_thermal.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c index 766486f..535f1fa 100644 --- a/drivers/thermal/rockchip_thermal.c +++ b/drivers/thermal/rockchip_thermal.c @@ -401,17 +401,15 @@ static u32 rk_tsadcv2_temp_to_code(const struct chip_tsadc_table *table, int temp) { int high, low, mid; - u32 error = 0; + u32 error = table->data_mask; low = 0; high = table->length - 1; mid = (high + low) / 2; /* Return mask code data when the temp is over table range */ - if (temp < table->id[low].temp || temp > table->id[high].temp) { - error = table->data_mask; + if (temp < table->id[low].temp || temp > table->id[high].temp) goto exit; - } while (low <= high) { if (temp == table->id[mid].temp)