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: 9440999 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 ACDD060237 for ; Tue, 22 Nov 2016 12:36:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A9E628476 for ; Tue, 22 Nov 2016 12:36:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E4DE28520; Tue, 22 Nov 2016 12:36:32 +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=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 3D47B28476 for ; Tue, 22 Nov 2016 12:36:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932631AbcKVMfZ (ORCPT ); Tue, 22 Nov 2016 07:35:25 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:34239 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932127AbcKVMfX (ORCPT ); Tue, 22 Nov 2016 07:35:23 -0500 Received: by mail-pg0-f66.google.com with SMTP id e9so2041151pgc.1; 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=OEI6rmsiu3Vxf+vVtyq/g7Cw3p92bWcZ2sxbkblhx+Whop0vYPfqgd6Ig3uZPRE07U N4lTE5EdVVY6/3os6e/YEUVtZGRzyAYqpH/KVUsaR934oVe+mRsDedAtQlf1pU0D0HcQ wk9UTxmcpDn6Wt8qr4aU0+WjOxX2xtYnUYUIQ03cABLf2dVXFYaWipBjvIwAvB2PdWtt ZdqdZ8QHdnjMz5ptMhV3EoOCSvj04kPrSsz3UrtVGovjr/5MvHWmzAsineO+qlMXNJoI DR9TzvgATdT6ZmOrim6+2zc7qWTlpSHfEy0swxDwbphuXpsWtI0aVQaUsjUu0XIJlxDq h8WA== X-Gm-Message-State: AKaTC00esnER1XL7mmODDa+9OJ3RU/54LDtOyXipr/s3JDLBIhgUZqFgVYhtCDxtko1STQ== 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 Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-rockchip@lists.infradead.org, briannorris@chromium.org, heiko@sntech.de, smbarber@chromium.org, Caesar Wang 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> 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 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)