From patchwork Wed Dec 30 05:13:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 7931941 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 932E89F349 for ; Wed, 30 Dec 2015 05:14:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C8635202F0 for ; Wed, 30 Dec 2015 05:14:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E74CE202E6 for ; Wed, 30 Dec 2015 05:14:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750842AbbL3FNZ (ORCPT ); Wed, 30 Dec 2015 00:13:25 -0500 Received: from mail-pa0-f46.google.com ([209.85.220.46]:35361 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750798AbbL3FNY (ORCPT ); Wed, 30 Dec 2015 00:13:24 -0500 Received: by mail-pa0-f46.google.com with SMTP id ho8so1765595pac.2 for ; Tue, 29 Dec 2015 21:13:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=Wm2yDFz26wwyxtXzgWz25hub+X06CsVL7bdH5xH8LUQ=; b=BHCBC07n0py/qlLp/psOczED/MLOO8CH5y4x5zWUW4zwQTAB+Nf4ZHnzSQJutIo/cw nSbJif2cpdmoSI/JKdS4BTXVfh8ha0E/mjAIzBtnivehDSCJkq2nL1WJgRc6RcsZ/8J5 uW8r0B0YGrywitaot6x4mTT8byFkxB7+N6YPI= 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; bh=Wm2yDFz26wwyxtXzgWz25hub+X06CsVL7bdH5xH8LUQ=; b=A8Co7WQ16T06K+bBDLaB1kHbNsoulNqp2qwYHA/NTuxQjiO96sEfW9ITR68ksBlmaP +3BhCyGuzS80v+hi04cWNYXR0JZ1ImLBleR7RerEqCDHe9ew0+wDo1YAUDFS7GDXV8AZ qeeS5NuJY3p/zSHGnSxyzzdAUex5kdWcCVG4mguqbjYiHyOmaagDa9TAvagZIUM2gNcV S84psbwg9A7SorJmyJkqrTzcJxcnct8HLzQGUPBZb5gFjP3xCtpYeCAXuXC8nG8fCk3w ldmsLupn6BW0JcPCeocIS2ZkjtV4mzEJ44RE99BgKyRgxEB3AelSViOwH5NvIyREHCVS VoHg== X-Gm-Message-State: ALoCoQkw2hNsJ7zxjqu+cHtyXAZI5p4BkGwFpaUAecOjcRpATJ+6fF5AY/QB1y6WisIVNDR2sexlV4Rm/2eaTg57sXsPRhJslg== X-Received: by 10.66.100.198 with SMTP id fa6mr49490827pab.123.1451452403686; Tue, 29 Dec 2015 21:13:23 -0800 (PST) Received: from localhost.localdomain (v17.blockcn.net. [192.241.236.26]) by smtp.gmail.com with ESMTPSA id r193sm86624869pfr.65.2015.12.29.21.13.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Dec 2015 21:13:22 -0800 (PST) From: Leo Yan To: Zhang Rui , Eduardo Valentin , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, kongxinwei Cc: Leo Yan Subject: [PATCH] thermal: hisilicon: increase temperature resolution Date: Wed, 30 Dec 2015 13:13:02 +0800 Message-Id: <1451452382-4498-1-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 When calculate temperature, old code firstly do division and then convert to "millicelsius" unit. This will lose resolution and only can read back temperature with "Celsius" unit. So firstly scale step value to "millicelsius" and then do division, so finally we can increase resolution for temperature value. Also refine the calculation from temperature value to step value. Signed-off-by: Leo Yan --- drivers/thermal/hisi_thermal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 36d0729..5e820b5 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -68,12 +68,12 @@ static inline int _step_to_temp(int step) * Every step equals (1 * 200) / 255 celsius, and finally * need convert to millicelsius. */ - return (HISI_TEMP_BASE + (step * 200 / 255)) * 1000; + return (HISI_TEMP_BASE * 1000 + (step * 200000 / 255)); } static inline long _temp_to_step(long temp) { - return ((temp / 1000 - HISI_TEMP_BASE) * 255 / 200); + return ((temp - HISI_TEMP_BASE * 1000) * 255) / 200000; } static long hisi_thermal_get_sensor_temp(struct hisi_thermal_data *data,