From patchwork Tue Mar 29 11:23:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 8685811 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 1E0519F44D for ; Tue, 29 Mar 2016 11:23:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4A33E200FF for ; Tue, 29 Mar 2016 11:23:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6980820103 for ; Tue, 29 Mar 2016 11:23:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751895AbcC2LXr (ORCPT ); Tue, 29 Mar 2016 07:23:47 -0400 Received: from mail-vk0-f53.google.com ([209.85.213.53]:33151 "EHLO mail-vk0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751852AbcC2LXr (ORCPT ); Tue, 29 Mar 2016 07:23:47 -0400 Received: by mail-vk0-f53.google.com with SMTP id k1so14168453vkb.0 for ; Tue, 29 Mar 2016 04:23:46 -0700 (PDT) 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=ILlwYPWf3Ejim8h5s/DgGRKnQsEeSZTRhvpRBxEzFaTGvNleDF7CTi+cSSH+NLn3Dk fN4JK4L9LNHLwUXxT/zBOlt0soTBBVdf1yfNotMJkJsASuM0gyhaT5QUTNfLuP84O4XS d2TnoDENRLZ1eINxKKIUcrGpoCIaHPs8oGpQw= 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=TWCnkJ+Koha4HIoGkmAYru31n9ox3jy+gzvCjKLAZ9E6AptRhQ0gNivkYItik1V/bF gfJxecZrnUmOT8SEbFqT01XB4nUdZNMjAgd/J7wmOd8EbUnPfGoXztFm/Of3l4LymWQu thgfSVv+9CahO9U2O/obM4D6uNQXX6tcGIPnoY6pOC32XqgQmo0MCZt4c0vvKNq9ataA gnT0yUUZr02qgf05L48QVZii8hhzrpDIoY6xhcrQv45Q0ZK8okTp1WXfH9l+J9cbnoxG KCGdUOFdLvY7nPi4kpE456xbMIbAkhFouDSa1zMAhzqSDgq/vRltW7otFBBhFhJu6Z49 6mPQ== X-Gm-Message-State: AD7BkJJbzbS3MPSyhuV4rROFaNoFmSYQKOedfPaXDh/uCGJqQ8Z7m83oNY6/pbTkB2iQGN4m X-Received: by 10.31.42.198 with SMTP id q189mr730460vkq.60.1459250625995; Tue, 29 Mar 2016 04:23:45 -0700 (PDT) Received: from leoy-linaro.a1.60in.com ([66.155.104.79]) by smtp.gmail.com with ESMTPSA id j66sm4654471uad.19.2016.03.29.04.23.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Mar 2016 04:23:45 -0700 (PDT) From: Leo Yan To: Zhang Rui , Eduardo Valentin Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Leo Yan Subject: [RESEND PATCH] thermal: hisilicon: increase temperature resolution Date: Tue, 29 Mar 2016 19:23:32 +0800 Message-Id: <1459250612-22239-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=-7.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,