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: 64588 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1947799lbc; Tue, 29 Mar 2016 04:23:49 -0700 (PDT) X-Received: by 10.98.8.219 with SMTP id 88mr2466492pfi.51.1459250629414; Tue, 29 Mar 2016 04:23:49 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ey12si10223250pac.203.2016.03.29.04.23.49; Tue, 29 Mar 2016 04:23:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751895AbcC2LXr (ORCPT + 13 others); 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 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(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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,