From patchwork Mon Apr 18 03:35:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caesar Wang X-Patchwork-Id: 8867341 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 07713BF29F for ; Mon, 18 Apr 2016 03:39:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3C8D6200E6 for ; Mon, 18 Apr 2016 03:39:07 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 117D8201BC for ; Mon, 18 Apr 2016 03:39:06 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1as00U-0000II-GC; Mon, 18 Apr 2016 03:37:50 +0000 Received: from mail-pa0-f66.google.com ([209.85.220.66]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1as00Q-00004w-M9; Mon, 18 Apr 2016 03:37:47 +0000 Received: by mail-pa0-f66.google.com with SMTP id hb4so15075693pac.1; Sun, 17 Apr 2016 20:37:26 -0700 (PDT) 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=AvlThxMMEJ7uyPSBVMHS781jzTAArZKrRnBxz+5f+ms=; b=NFznwxs20QrKHmWI/NBoH+EBFvURNx+l0xLe6abc7JMnOM+XjDEoidOKytAMaqkbE+ tEglJPqizpUC3ez++LOzkcf9sjk479ZF4zTXuB6LOPAtYZPHTc9mDTM1w4Q+8/pvReao 1f74o94OD+0/2oPs+NPptoWrZIsG6prp1iMii9EKF0tBAmP3uGOo90HFSwCik3n4FA6C ZC7JwsWr45absyvE9BZKhE17ox6yUBi5s9Vxs4nu+Oo+lX8Edpo1pESv3TQ/OOw+aqEy uc8V6HphLoAz8sijFhiNtgTf7Y4V1CeLMdUbSx6ZCMRi6fMtGjBg9Kck7qH2F8XUxah8 i+bg== X-Gm-Message-State: AOPr4FVMTL03xHlLhQJuJ9Cf48I7YIKo9UibacukdXiFSz8GR7tHO3EkGjHQ21bxE1S47g== X-Received: by 10.66.225.235 with SMTP id rn11mr46218146pac.138.1460950646031; Sun, 17 Apr 2016 20:37:26 -0700 (PDT) Received: from localhost.localdomain ([104.37.5.139]) by smtp.gmail.com with ESMTPSA id tp9sm79756867pab.14.2016.04.17.20.37.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 Apr 2016 20:37:25 -0700 (PDT) From: Caesar Wang To: edubezval@gmail.com Subject: [PATCH 2/9] thermal: rockchip: fixes the code_to_temp for tsadc driver Date: Mon, 18 Apr 2016 11:35:54 +0800 Message-Id: <1460950562-20652-3-git-send-email-wxt@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1460950562-20652-1-git-send-email-wxt@rock-chips.com> References: <1460950562-20652-1-git-send-email-wxt@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160417_203746_809356_494CFCB5 X-CRM114-Status: GOOD ( 11.55 ) X-Spam-Score: -2.4 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Stuebner , linux-pm@vger.kernel.org, dianders@chromium.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, smbarber@google.com, briannorris@google.com, Zhang Rui , linux-arm-kernel@lists.infradead.org, Caesar Wang MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We should judge the table.id[mid].code insearch algorithm on matter the adc value increment or decrement. Or otherwise, the temperature return the incorrect value in some cases. [ 1.438589] adc_val=402,temp=-40000 [ 1.438903] adc_val=403,temp=-39375 [ 1.439217] adc_val=404,temp=-38750 ... [ 1.441102] adc_val=410,temp=-40000 [ 1.441416] adc_val=411,temp=-34445 [ 1.441737] adc_val=412,temp=-33889 ... Let's fix it right now. Fixes commit 020ba95dbbbe ("thermal: rockchip: Add the sort mode for adc value increment or decrement"). Reported-by: Rocky Hao Signed-off-by: Caesar Wang Cc: Zhang Rui Cc: Eduardo Valentin Cc: Heiko Stuebner --- drivers/thermal/rockchip_thermal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c index f4c4bcd..658772f 100644 --- a/drivers/thermal/rockchip_thermal.c +++ b/drivers/thermal/rockchip_thermal.c @@ -405,8 +405,8 @@ static int rk_tsadcv2_code_to_temp(struct chip_tsadc_table table, u32 code, return -EAGAIN; /* Incorrect reading */ while (low <= high) { - if (code >= table.id[mid - 1].code && - code < table.id[mid].code) + if (code <= table.id[mid].code && + code > table.id[mid - 1].code) break; else if (code > table.id[mid].code) low = mid + 1;