From patchwork Thu Dec 10 12:48:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumeet Pawnikar X-Patchwork-Id: 11964475 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E98F2C4361B for ; Thu, 10 Dec 2020 12:52:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9ECC223E1D for ; Thu, 10 Dec 2020 12:52:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732028AbgLJMwS (ORCPT ); Thu, 10 Dec 2020 07:52:18 -0500 Received: from mga12.intel.com ([192.55.52.136]:26357 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387545AbgLJMwG (ORCPT ); Thu, 10 Dec 2020 07:52:06 -0500 IronPort-SDR: ljOmEhNXsfUB3Zd1xATnE958FSX1P6Fu5GRQFIT8TBciH40UYVCYhRPTjfjCSDBPqPxSly2EZP GJ70g56q5V2A== X-IronPort-AV: E=McAfee;i="6000,8403,9830"; a="153481136" X-IronPort-AV: E=Sophos;i="5.78,408,1599548400"; d="scan'208";a="153481136" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2020 04:51:21 -0800 IronPort-SDR: zMhGeLDLV+I+Gs/yc8yu1CBaVblxWNO+V1vRFf/q1wFfUjFttEWzHWAJI/PDqRUitkAgGS+SqR LkTVDiHHsZIA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,408,1599548400"; d="scan'208";a="408517044" Received: from srpawnik-nuc8i7beh.iind.intel.com ([10.223.107.144]) by orsmga001.jf.intel.com with ESMTP; 10 Dec 2020 04:51:19 -0800 From: Sumeet Pawnikar To: daniel.lezcano@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: andriy.shevchenko@intel.com, rui.zhang@intel.com, sumeet.r.pawnikar@intel.com Subject: [PATCH -next] thermal: intel: pch: use macro for temperature calculation Date: Thu, 10 Dec 2020 18:18:01 +0530 Message-Id: <20201210124801.13850-1-sumeet.r.pawnikar@intel.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Use macro for temperature calculation Signed-off-by: Sumeet Pawnikar Reviewed-by: Andy Shevchenko Reviewed-by: Zhang Rui --- drivers/thermal/intel/intel_pch_thermal.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) -- 2.28.0 diff --git a/drivers/thermal/intel/intel_pch_thermal.c b/drivers/thermal/intel/intel_pch_thermal.c index d7c05c00881e..41723c6c6c0c 100644 --- a/drivers/thermal/intel/intel_pch_thermal.c +++ b/drivers/thermal/intel/intel_pch_thermal.c @@ -167,8 +167,7 @@ static int pch_wpt_init(struct pch_thermal_device *ptd, int *nr_trips) trip_temp = readw(ptd->hw_base + WPT_CTT); trip_temp &= 0x1FF; if (trip_temp) { - /* Resolution of 1/2 degree C and an offset of -50C */ - ptd->crt_temp = trip_temp * 1000 / 2 - 50000; + ptd->crt_temp = GET_WPT_TEMP(trip_temp); ptd->crt_trip_id = 0; ++(*nr_trips); } @@ -177,8 +176,7 @@ static int pch_wpt_init(struct pch_thermal_device *ptd, int *nr_trips) trip_temp = readw(ptd->hw_base + WPT_PHL); trip_temp &= 0x1FF; if (trip_temp) { - /* Resolution of 1/2 degree C and an offset of -50C */ - ptd->hot_temp = trip_temp * 1000 / 2 - 50000; + ptd->hot_temp = GET_WPT_TEMP(trip_temp); ptd->hot_trip_id = *nr_trips; ++(*nr_trips); } @@ -190,12 +188,7 @@ static int pch_wpt_init(struct pch_thermal_device *ptd, int *nr_trips) static int pch_wpt_get_temp(struct pch_thermal_device *ptd, int *temp) { - u16 wpt_temp; - - wpt_temp = WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TEMP); - - /* Resolution of 1/2 degree C and an offset of -50C */ - *temp = (wpt_temp * 1000 / 2 - 50000); + *temp = GET_WPT_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TEMP)); return 0; }