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: 8867421 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: X-Original-To: patchwork-linux-pm@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 8E6EBBF29F for ; Mon, 18 Apr 2016 03:39:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9EB902010E for ; Mon, 18 Apr 2016 03:39:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DBEEA20221 for ; Mon, 18 Apr 2016 03:39:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752979AbcDRDha (ORCPT ); Sun, 17 Apr 2016 23:37:30 -0400 Received: from mail-pa0-f67.google.com ([209.85.220.67]:33815 "EHLO mail-pa0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752916AbcDRDh1 (ORCPT ); Sun, 17 Apr 2016 23:37:27 -0400 Received: by mail-pa0-f67.google.com with SMTP id hb4so15075691pac.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=fSxW5NEvX0JJjzg92RUjXpxQF298FzoRSB2dUkaTfQSYiCJaULv+1YCKwZJxuMide9 LFCdN8DtEBEt+BqVW5FVMqN13f4lxt7dhjv/Lh226lI3fsZ5Y2XMqTLaMJMqiFMmovg0 7VPOcw3oW5JfUjVfDBMvzdiWIiYd0mvKUhALvCHzz+11RJ94rgn3xMEo3tM257cdBEpP gA92lRHFBC18sdGscjs16q/e3VeVGepWrn9noOz6uwRdwOu7ZDYn3P5DO1hPL0lQqZgd JmSV5udGEEqcZsT96mkC4Z3h1Z+owylP5252UkQyA0eQvb/bMMxSgKZDqX0NaV2NdZtC X1cw== X-Gm-Message-State: AOPr4FX8OKnTbYEr29mzObwn1osxqdtt+Ly66f/PsqJQQst0rL01xQl2v4AtXjOsyftOmw== 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 Cc: Heiko Stuebner , dianders@chromium.org, briannorris@google.com, smbarber@google.com, linux-rockchip@lists.infradead.org, Caesar Wang , Zhang Rui , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org 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> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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;