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: 8908331 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 CCC55BF29F for ; Fri, 22 Apr 2016 10:03:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EAA5920155 for ; Fri, 22 Apr 2016 10:03:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AB418202E9 for ; Fri, 22 Apr 2016 10:03:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752273AbcDVKDV (ORCPT ); Fri, 22 Apr 2016 06:03:21 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]:32955 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753319AbcDVKDT (ORCPT ); Fri, 22 Apr 2016 06:03:19 -0400 Received: by mail-pa0-f68.google.com with SMTP id vv3so9606147pab.0; Fri, 22 Apr 2016 03:03:19 -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=eAw+HEKoxcASiwFhUlwQvESYDtLWZP2o0TFGhsrgljqlf4Bt7iW5ZKU/dXeCTor6/B F3YS4mn3mz8sceYtEsFjeDHKeNI7FekU92McFxbFWqK8oPiN4AGJBDKZ9FKkKY/opk+G kKmlww+k7b79LnyMRo+OT6Su+97PinAnhoUnxUXh6s2JYx5+yjqW4PIlGeVCxh83xVqd lxciemPN3STNUHGcx5VmBjznrbXnW9FvvZjRVDDb0ag0Z56uLSHUmN9p6AtEmery8yl/ S1W3mKQUS11R4sSq9yZ3XH+XxCgzKgyhDVegJLAn7FFmrfDbrWH2LmGYcyPgQfv4wMlc zhRQ== X-Gm-Message-State: AOPr4FXsumCb37/nxfRRLwXop0DkRUEkUnXTe2TViTDgl+wZG6Cz9kh0JYnEOHbK85SVvQ== 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 Cc: 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: [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> 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=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;