From patchwork Fri Apr 22 10:02:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caesar Wang X-Patchwork-Id: 8908561 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 9F77CBF29F for ; Fri, 22 Apr 2016 10:05:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D210D201B4 for ; Fri, 22 Apr 2016 10:05:54 +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 93A5A20160 for ; Fri, 22 Apr 2016 10:05:53 +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 1atXwG-0006RK-NW; Fri, 22 Apr 2016 10:03:52 +0000 Received: from mail-pa0-f68.google.com ([209.85.220.68]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1atXw1-0006IB-0v; Fri, 22 Apr 2016 10:03:37 +0000 Received: by mail-pa0-f68.google.com with SMTP id yl2so5933770pac.1; Fri, 22 Apr 2016 03:03:18 -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=k3vCYCuo1eemUxJ+UgRPo8NZvBQdi9jAbG8/MgvrjBoUYJkxpwsO9WIAzQOx8W7WhS BGEMjIs8bv1ySG52KMqPZ5nwr8lqs9/c1K7uErw6/kDEDOIMs/VV/sRndxY2awOvt+ej 3nebVH9KMjJKiOqkKw1evGpIfnKOQbFlhFM/HJiNCZaOr59C6zsl/jf40totaDZFRe0O fKFEDjx4ejcJcI1TADdU6C/ch132xsTsGSgN4P44lppjDR9uo/C9Ht1Wf6gcjD4GUBC6 3EEd9MBXFzABBLW64jytmGyy5/qR8723cC+hSG2gOQvHidEdb6IvUkbJ63mbcV/KLwEL +R+w== X-Gm-Message-State: AOPr4FURwB2sogNuLS5ioAHHBuqTTIfYv4OWRPTaHqOoQZdth9Tz/ieb059P768bAwZNDQ== X-Received: by 10.67.14.6 with SMTP id fc6mr26532185pad.55.1461319398696; Fri, 22 Apr 2016 03:03:18 -0700 (PDT) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id 27sm7132490pfo.58.2016.04.22.03.03.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Apr 2016 03:03:17 -0700 (PDT) From: Caesar Wang To: edubezval@gmail.com, Heiko Stuebner Subject: [RESEND PATCH 2/8] thermal: rockchip: fixes the code_to_temp for tsadc driver Date: Fri, 22 Apr 2016 18:02:48 +0800 Message-Id: <1461319374-10024-3-git-send-email-wxt@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461319374-10024-1-git-send-email-wxt@rock-chips.com> References: <1461319374-10024-1-git-send-email-wxt@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160422_030337_148620_CA3685FC X-CRM114-Status: GOOD ( 10.20 ) 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: 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;