From patchwork Sun Nov 24 14:08:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11259179 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5D7EC1390 for ; Sun, 24 Nov 2019 14:09:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 398D42084B for ; Sun, 24 Nov 2019 14:09:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UZIHl+Fv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727112AbfKXOJO (ORCPT ); Sun, 24 Nov 2019 09:09:14 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:44235 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726767AbfKXOJN (ORCPT ); Sun, 24 Nov 2019 09:09:13 -0500 Received: by mail-pf1-f195.google.com with SMTP id d199so1330965pfd.11; Sun, 24 Nov 2019 06:09:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uiVaOYC0AJAeDJiNsTnIMMgr41e8eY8TpWvmzxTalS8=; b=UZIHl+FvynMquo91lmoV5lbWmLcB+8Iw8tQF+m0vCBO8UCd9CRAQcTeAd+sMHZP4jo B6Xmatc+2rgYJ+34ssDGYNBtJiUINZ7+QB/gQplVjthaNSrMy7CSwwU1ucQLlf6Giaof RmRShwUrp8NUVqYWsha6437Pq0+vhr3TLYELT1yPmV1/KZZmDjeJbQFOq3MaBxRqYQQl SHu6KL9a66DZesCDnoB59cQL5Rh1E/13ZazzHc7ARMdE7lHt6pFFCXdkGHuk2BCh37uM A2hSAc1RcaWOLGy67uLEvZGH2wuKAwZsFzYeDmcmMK3gnM/ALNPxjGQhAOJ1zNSS55O+ yqNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uiVaOYC0AJAeDJiNsTnIMMgr41e8eY8TpWvmzxTalS8=; b=uFylDnKrPaO6Nmgi1tavMINCYDwrQLnlnR83cYpC4RFCQagBui8i6sv2BOMxmAdq57 Mzen7I9hno87+FhNAb3fdlFDzdYfRjhQ+3TABRUUnXPQuoOfQFPXYM3xv5W93KC5PSqT tf632b94GdNW44sRl49/A4iM3rR7ErrCXU8zcUnaP3kFyDP/Fzk88IzkCnOmHN/BhFyi 4rIew1IkO1U7SXG642iOfzo635edMXIJp/+Xa9l0tFYOf0TeQzPhnLai0RgDNptkX+hr XTJoYiSh5XhEip1d/72f4tFXcX807qSfVAQJwhdiR69SrnEfTSpk7NPmQBWTQD4Ke/Sm s2DQ== X-Gm-Message-State: APjAAAU8127VBFfg6nhL17eKFKofTgwNV9D98yOO8qElJV6RemKNJTas 4+4FjnIRqxznQT+ZoIpFqH+YjBeR870= X-Google-Smtp-Source: APXvYqxa+x5Ky0KmnA9MrXJ6wT3QpcqvpcitOx/D7jKeOjTqkBRfuQPdefSpwDVRKgldh3VsRGRMZQ== X-Received: by 2002:aa7:8b1a:: with SMTP id f26mr8162545pfd.81.1574604552956; Sun, 24 Nov 2019 06:09:12 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id a3sm4816326pgh.91.2019.11.24.06.09.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 24 Nov 2019 06:09:12 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Akinobu Mita , Sujith Thomas , Darren Hart , Andy Shevchenko , Zhang Rui , Eduardo Valentin , Daniel Lezcano , Amit Kucheria , Jean Delvare , Guenter Roeck , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg Subject: [PATCH 1/8] add header file for kelvin to/from Celsius conversion helpers Date: Sun, 24 Nov 2019 23:08:43 +0900 Message-Id: <1574604530-9024-2-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574604530-9024-1-git-send-email-akinobu.mita@gmail.com> References: <1574604530-9024-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org There are several helper macros to convert kelvin to/from Celsius in for thermal drivers. These are useful for any other drivers or subsystems, but it's odd to include just for the helpers. This adds a new that provides the equivalent inline functions for any drivers or subsystems. It is intended to replace the helpers in . Cc: Sujith Thomas Cc: Darren Hart Cc: Andy Shevchenko Cc: Zhang Rui Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: Amit Kucheria Cc: Jean Delvare Cc: Guenter Roeck Cc: Keith Busch Cc: Jens Axboe Cc: Christoph Hellwig Cc: Sagi Grimberg Signed-off-by: Akinobu Mita --- include/linux/temperature.h | 39 +++++++++++++++++++++++++++++++++++++++ include/linux/thermal.h | 1 + 2 files changed, 40 insertions(+) create mode 100644 include/linux/temperature.h diff --git a/include/linux/temperature.h b/include/linux/temperature.h new file mode 100644 index 0000000..d7e2aed --- /dev/null +++ b/include/linux/temperature.h @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_TEMPERATURE_H +#define _LINUX_TEMPERATURE_H + +#include + +#define ABSOLUTE_ZERO_MILLICELSIUS -273150 + +static inline long kelvin_to_millicelsius(long t) +{ + return t * 1000 + ABSOLUTE_ZERO_MILLICELSIUS; +} + +static inline long millicelsius_to_kelvin(long t) +{ + return DIV_ROUND_CLOSEST(t - ABSOLUTE_ZERO_MILLICELSIUS, 1000); +} + +static inline long deci_kelvin_to_celsius(long t) +{ + return DIV_ROUND_CLOSEST(t * 100 + ABSOLUTE_ZERO_MILLICELSIUS, 1000); +} + +static inline long celsius_to_deci_kelvin(long t) +{ + return t * 10 - DIV_ROUND_CLOSEST(ABSOLUTE_ZERO_MILLICELSIUS, 100); +} + +static inline long deci_kelvin_to_millicelsius(long t) +{ + return t * 100 + ABSOLUTE_ZERO_MILLICELSIUS; +} + +static inline long millicelsius_to_deci_kelvin(long t) +{ + return DIV_ROUND_CLOSEST(t - ABSOLUTE_ZERO_MILLICELSIUS, 100); +} + +#endif /* _LINUX_TEMPERATURE_H */ diff --git a/include/linux/thermal.h b/include/linux/thermal.h index e45659c..ed549e4 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include From patchwork Sun Nov 24 14:08:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11259183 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9C721138C for ; Sun, 24 Nov 2019 14:09:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7EAA02080D for ; Sun, 24 Nov 2019 14:09:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GtT9zO/t" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727135AbfKXOJU (ORCPT ); Sun, 24 Nov 2019 09:09:20 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:41146 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726767AbfKXOJT (ORCPT ); Sun, 24 Nov 2019 09:09:19 -0500 Received: by mail-pf1-f195.google.com with SMTP id p26so5961006pfq.8; Sun, 24 Nov 2019 06:09:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=czC6nSQ5Mc9CJVDHU8aRwsMtho/ZtmD5fWxjP8fTWFQ=; b=GtT9zO/ttEp5EBxeDarWq2F13mveIYiDxKZ+MRPLPaXmXvU0VbpaI+P7v8Y3ikAyBS TFvreqga/+8htA8ez08lE8xi7POJ9OOpHQ6t6Jcn8oVr+EFKYcfbyS8pp5zB/c0A1Jk9 lvvfUmieleCnquwCneIlKLcCcROA4HGk40h21iUwvZFb00MvAfbxehG4CrGcVENsG7Wq IHWqhzhWmc8k2RT129cEMiNI2xhfxyrP7GzYg3wc5mifpsg+NSpVVZQ8tPFwKBuIveQx amy6ltiZRgfG1VR6PJy6KcADSBkSsUpyDhLEtFAZ2b/EaDg69FUZIXIGyCM5/FZmdN/g hhtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=czC6nSQ5Mc9CJVDHU8aRwsMtho/ZtmD5fWxjP8fTWFQ=; b=mKmab9yq65CL4lCoDxbBgRg0nf5yB1axP53lvgwyzuzHKKNHgkB9lnnHDo+uDVYoM5 e7BVgQJbevDNA5yV6rKtK8xZGC82uEYz1TicgL1QNE11PWcR4wl73DjLCkj2aiDuXBtT +Wx4zzbERHOHc0O+Sbjd+jGlH572uCXysV3p1NsZYUjGdFmFhS6/zKfnrUfk9tKbHbEU S3g9tcwNCnjmE2qZfUUIFlsBgFE6Bfluo5PGNJcJe3liPWGgWoc/k5dNEvR25KXq4Rhn u7FB3cZf7Gla9zqtvw440WtBRZlLSI4uN/cWpT9qlqxnup6IJisNYtQTZmtcyiLBbd/d dsPw== X-Gm-Message-State: APjAAAV7yNkkMJLy9seb0jJRm4elwPJOAV0M4I8ydjGbrS9QNOrBGkmS VGnSCVHceuGm+NC7creJna1qemaVHYI= X-Google-Smtp-Source: APXvYqxcacdLA/j7CmvnEt1MVmIqsOc+mODcqUPaCaS2Ilz2oZL6AlDj6CpF8oRmisR4xhh9U5fpBg== X-Received: by 2002:a63:1718:: with SMTP id x24mr24924884pgl.1.1574604558045; Sun, 24 Nov 2019 06:09:18 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id a3sm4816326pgh.91.2019.11.24.06.09.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 24 Nov 2019 06:09:17 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Akinobu Mita , Sujith Thomas , Darren Hart , Andy Shevchenko , Zhang Rui , Eduardo Valentin , Daniel Lezcano , Amit Kucheria , Jean Delvare , Guenter Roeck , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg Subject: [PATCH 2/8] ACPI: thermal: switch to use helpers Date: Sun, 24 Nov 2019 23:08:44 +0900 Message-Id: <1574604530-9024-3-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574604530-9024-1-git-send-email-akinobu.mita@gmail.com> References: <1574604530-9024-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This switches the ACPI thermal zone driver to use celsius_to_deci_kelvin() and deci_kelvin_to_celsius() in instead of helpers in . This is preparation for centralizing the kelvin to/from Celsius conversion helpers in . Cc: Sujith Thomas Cc: Darren Hart Cc: Andy Shevchenko Cc: Zhang Rui Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: Amit Kucheria Cc: Jean Delvare Cc: Guenter Roeck Cc: Keith Busch Cc: Jens Axboe Cc: Christoph Hellwig Cc: Sagi Grimberg Signed-off-by: Akinobu Mita --- drivers/acpi/thermal.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index d831a61..bd9b6eb 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -297,7 +297,9 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) if (crt == -1) { tz->trips.critical.flags.valid = 0; } else if (crt > 0) { - unsigned long crt_k = CELSIUS_TO_DECI_KELVIN(crt); + unsigned long crt_k = + celsius_to_deci_kelvin(crt); + /* * Allow override critical threshold */ @@ -333,7 +335,7 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) if (psv == -1) { status = AE_SUPPORT; } else if (psv > 0) { - tmp = CELSIUS_TO_DECI_KELVIN(psv); + tmp = celsius_to_deci_kelvin(psv); status = AE_OK; } else { status = acpi_evaluate_integer(tz->device->handle, @@ -413,7 +415,7 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) break; if (i == 1) tz->trips.active[0].temperature = - CELSIUS_TO_DECI_KELVIN(act); + celsius_to_deci_kelvin(act); else /* * Don't allow override higher than @@ -421,9 +423,9 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) */ tz->trips.active[i - 1].temperature = (tz->trips.active[i - 2].temperature < - CELSIUS_TO_DECI_KELVIN(act) ? + celsius_to_deci_kelvin(act) ? tz->trips.active[i - 2].temperature : - CELSIUS_TO_DECI_KELVIN(act)); + celsius_to_deci_kelvin(act)); break; } else { tz->trips.active[i].temperature = tmp; @@ -1087,7 +1089,8 @@ static int acpi_thermal_add(struct acpi_device *device) INIT_WORK(&tz->thermal_check_work, acpi_thermal_check_fn); pr_info(PREFIX "%s [%s] (%ld C)\n", acpi_device_name(device), - acpi_device_bid(device), DECI_KELVIN_TO_CELSIUS(tz->temperature)); + acpi_device_bid(device), + deci_kelvin_to_celsius(tz->temperature)); goto end; free_memory: From patchwork Sun Nov 24 14:08:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11259187 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D140F1593 for ; Sun, 24 Nov 2019 14:09:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B318F207DD for ; Sun, 24 Nov 2019 14:09:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lNhNJTaV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726803AbfKXOJZ (ORCPT ); Sun, 24 Nov 2019 09:09:25 -0500 Received: from mail-pj1-f67.google.com ([209.85.216.67]:33782 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726767AbfKXOJY (ORCPT ); Sun, 24 Nov 2019 09:09:24 -0500 Received: by mail-pj1-f67.google.com with SMTP id o14so5266474pjr.0; Sun, 24 Nov 2019 06:09:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GqKt6zdWfZywezSW3C4ZkPtud9ch/0Uh/6q3QjZGy/0=; b=lNhNJTaVbOYkgvALBg5TYxMoq8zHMyfVOu3sxGp7bmwZFD7wBp4Y1O15pm8Oz3YqTT QHYl3RYDZUBvL4JRBlICIV4t5EAUfVooVi999U9O8IpccoBPzz2Tx6DytcNdG+wYBDh/ 5HqaVGDNHbEEDib3zIf4hSbQmCkO2umeNYEMmqBmKQruaVQIFMyzbfA0zl7tFlQWip9N Hdbm5rsD48oZ64JjDYvAsyVCipezgtYHBNNPi8JLYzwRhdaG4hOzCBR0S5fig4zc4rHD +rdOHy/VgFex1Eqdp9H7p+E4YXM/KtNYUNlHkOnZf81/IPH+SkxfHIXoPV/oUn7WDBTM WjpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GqKt6zdWfZywezSW3C4ZkPtud9ch/0Uh/6q3QjZGy/0=; b=eur/KyBqxq1IO71cF4OVSsuNns8+C579EGkW+AdOAfq0DIPA2r/sr1fGjCMao9AgHq ZguSUWRCHipAexin7PNcQ8ffyZp69NN62Qy32R3GuvtCBZZgmAtMkROSRG4rpL6phaOZ JNsQAPr53tZQV68+9m83Ulo5SN1qiIhGUBkWd9DxfXfgh7KMh8H9/RNzeMIEIcbbyQm7 l3Je9N2UrlgLh3/f2cIZxWv1K3LYVF5jaqusOZMpnmT+JOvaRY+R1ok/J2VQXzNiXyI3 mFAd1r2pYTyDC0EhlVD4m7V0sbN3vtx3Jf4lbZoIcLDTp9vGiC9SkXJys4OOnC5iTusS 08Sg== X-Gm-Message-State: APjAAAXGI4wu6B9mbp+qrImTusOrBCEJoieC5m6QalPfZ2qcgA4LD6lI PBBPbivvCpQ8EKMg2v84f4o= X-Google-Smtp-Source: APXvYqyk+tVzVqLTp1q5GIHaF/zWFrbxTxJ6dlTdJpNb8Ke8+dFQc2bkHdcu0WkqO7ewXlbG9toS4A== X-Received: by 2002:a17:90a:c56:: with SMTP id u22mr31571968pje.24.1574604563465; Sun, 24 Nov 2019 06:09:23 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id a3sm4816326pgh.91.2019.11.24.06.09.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 24 Nov 2019 06:09:22 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Akinobu Mita , Sujith Thomas , Darren Hart , Andy Shevchenko , Zhang Rui , Eduardo Valentin , Daniel Lezcano , Amit Kucheria , Jean Delvare , Guenter Roeck , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg Subject: [PATCH 3/8] platform/x86: asus-wmi: switch to use helpers Date: Sun, 24 Nov 2019 23:08:45 +0900 Message-Id: <1574604530-9024-4-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574604530-9024-1-git-send-email-akinobu.mita@gmail.com> References: <1574604530-9024-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The asus-wmi driver doesn't implement the thermal device functionality directly, so including just for DECI_KELVIN_TO_CELSIUS() is a bit odd. This switches the asus-wmi driver to use deci_kelvin_to_millicelsius() in . Cc: Sujith Thomas Cc: Darren Hart Cc: Andy Shevchenko Cc: Zhang Rui Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: Amit Kucheria Cc: Jean Delvare Cc: Guenter Roeck Cc: Keith Busch Cc: Jens Axboe Cc: Christoph Hellwig Cc: Sagi Grimberg Signed-off-by: Akinobu Mita Acked-by: Andy Shevchenko --- drivers/platform/x86/asus-wmi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 821b08e..6a1a2f9 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include @@ -1512,9 +1512,8 @@ static ssize_t asus_hwmon_temp1(struct device *dev, if (err < 0) return err; - value = DECI_KELVIN_TO_CELSIUS((value & 0xFFFF)) * 1000; - - return sprintf(buf, "%d\n", value); + return sprintf(buf, "%ld\n", + deci_kelvin_to_millicelsius(value & 0xFFFF)); } /* Fan1 */ From patchwork Sun Nov 24 14:08:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11259189 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 449D2138C for ; Sun, 24 Nov 2019 14:09:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 25D00207FD for ; Sun, 24 Nov 2019 14:09:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tOYyBixa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727193AbfKXOJa (ORCPT ); Sun, 24 Nov 2019 09:09:30 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:44560 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726767AbfKXOJ3 (ORCPT ); Sun, 24 Nov 2019 09:09:29 -0500 Received: by mail-pl1-f196.google.com with SMTP id az9so5258883plb.11; Sun, 24 Nov 2019 06:09:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SVtnbt2w8p1WjmEYI/RfZYho5p/l6mhZ+FEaY9XVk9c=; b=tOYyBixaF5cpNMF8ZO7JnE6N1EtCAZ75u7z42W4hABZwe+DAWLHZc634bLtAHRXXHd TB9DxYSIAu9yTKUTxpfIjmdsEfaTAvlElIA2ZC+kC67lmVZBH1R+ncjMNJve5x0kRuwx bFRAB7t+ABuPSvFKh2te4qkm/oIzhUl9d+Z743wlfc+IfcwSZ9bMcRX31RU5XlMejDDQ P7VGrC+t+YIZcgMpIC/bxT0sMiZyAqgKd9fgJ3zSgbdgCCE0F/orDI89ghBjQg6tkij5 BXYQ81S0DWGo9K5+VLrq3Wuy3U1wi2Vjc4A9H2edizEiiWKInP91OPLvd6kM7XlsD3hR 0I0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SVtnbt2w8p1WjmEYI/RfZYho5p/l6mhZ+FEaY9XVk9c=; b=NA3TpaUDXFwGCz+bgVA4RCgaiIzc38ED6qCP9h2UjNWHb5SD0b8S7UBA2lS7FtjuBX Wvfx1wFgIsBKsri2nHN2JEtOHp3ujONMG/z4xGRQ65k55Emh9tp4ICCtRcA+JuZW0iH8 7oR7IZpbF6YkGzMXfhdxrGR3c4Tg2hi+g68AGCBlQcwmjMdgQC48GUpg9SJZkPfMiIK8 ErCPn4EFMtsIyAE5Yb3pypRkLW1AyCSlLau4WJrzk2ltIYF361SIZ+4XBJqA+bYeR7LW xTwDkA72nqYcdnc8XSVm8zc/rRLBFlcD7XxgzX+B8B9a9tkwKFPeV3TGaOE/Crl6i1vq QSYA== X-Gm-Message-State: APjAAAXC+2X9SsI8LWcZq+pUsmxpzWChDRsRhuRLVn4bqAlqkLA+JGiP AFUAcIUYEdisxBwXZw713ME= X-Google-Smtp-Source: APXvYqxhgSSnEyAEssT9mHzY0Xl6B6xR3rhtdCcR/L7wxpVcIjm+OFIVSR2lzjjR7O5c30UgpLP8kw== X-Received: by 2002:a17:90a:9705:: with SMTP id x5mr31569174pjo.37.1574604568908; Sun, 24 Nov 2019 06:09:28 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id a3sm4816326pgh.91.2019.11.24.06.09.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 24 Nov 2019 06:09:28 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Akinobu Mita , Sujith Thomas , Darren Hart , Andy Shevchenko , Zhang Rui , Eduardo Valentin , Daniel Lezcano , Amit Kucheria , Jean Delvare , Guenter Roeck , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg Subject: [PATCH 4/8] platform/x86: intel_menlow: switch to use helpers Date: Sun, 24 Nov 2019 23:08:46 +0900 Message-Id: <1574604530-9024-5-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574604530-9024-1-git-send-email-akinobu.mita@gmail.com> References: <1574604530-9024-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This switches the intel_menlow driver to use deci_kelvin_to_celsius() and celsius_to_deci_kelvin() in instead of helpers in . This is preparation for centralizing the kelvin to/from Celsius conversion helpers in . Cc: Sujith Thomas Cc: Darren Hart Cc: Andy Shevchenko Cc: Zhang Rui Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: Amit Kucheria Cc: Jean Delvare Cc: Guenter Roeck Cc: Keith Busch Cc: Jens Axboe Cc: Christoph Hellwig Cc: Sagi Grimberg Signed-off-by: Akinobu Mita --- drivers/platform/x86/intel_menlow.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/intel_menlow.c b/drivers/platform/x86/intel_menlow.c index b102f6d..6313591 100644 --- a/drivers/platform/x86/intel_menlow.c +++ b/drivers/platform/x86/intel_menlow.c @@ -302,8 +302,10 @@ static ssize_t aux_show(struct device *dev, struct device_attribute *dev_attr, int result; result = sensor_get_auxtrip(attr->handle, idx, &value); + if (result) + return result; - return result ? result : sprintf(buf, "%lu", DECI_KELVIN_TO_CELSIUS(value)); + return sprintf(buf, "%ld", deci_kelvin_to_celsius(value)); } static ssize_t aux0_show(struct device *dev, @@ -332,8 +334,8 @@ static ssize_t aux_store(struct device *dev, struct device_attribute *dev_attr, if (value < 0) return -EINVAL; - result = sensor_set_auxtrip(attr->handle, idx, - CELSIUS_TO_DECI_KELVIN(value)); + result = sensor_set_auxtrip(attr->handle, idx, + celsius_to_deci_kelvin(value)); return result ? result : count; } From patchwork Sun Nov 24 14:08:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11259193 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5FA971390 for ; Sun, 24 Nov 2019 14:09:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 40CE7207FD for ; Sun, 24 Nov 2019 14:09:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AG9JNeOF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727215AbfKXOJf (ORCPT ); Sun, 24 Nov 2019 09:09:35 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:40657 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726767AbfKXOJf (ORCPT ); Sun, 24 Nov 2019 09:09:35 -0500 Received: by mail-pj1-f68.google.com with SMTP id ep1so5255938pjb.7; Sun, 24 Nov 2019 06:09:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=p4GXpFBwRIhrFQe2rae/GEBMEDnMv/ArRbrbnanSG1w=; b=AG9JNeOFbszeO/8b9h/bQ0hRUJwthd4/ubsKqui3xK7gywbStUqgNrrNdEEmL7Tar7 gu5sVIqxXEiiJEJfiiWr0exookUZuvNrXhNg5iUuzt5w/A/c/SOsvqi51ucqkB6GOaUP cOd/1mr/huELIW57Ks0kTXf70cNCp3pYFGWLvENGMt7WViPU7dV52Au+I2yoMo+M4rab pX98IWw9YPeF7LlK/HfjcSTxCK8xcQGMs4SjHC+VMOeuKt45hg59QuWVDMyGZHTfThXB 2jIFLnkZeb40aZ65gQsXv3sirdkLXc032HKFsM+R5p/6ARrIa/6cO9qF4CIG0Q2sXRPh lwOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=p4GXpFBwRIhrFQe2rae/GEBMEDnMv/ArRbrbnanSG1w=; b=szHX88ZI9QUBoTb331AgE4Gfa7jgpLmehnSWhdUe6B0AAVIOdCS9KlY8+sp96DmbCK parteqtKORkVn0kZpeFAiNRYDLZzj3mzoY2rEcOLKLa83QcX05t+mlzCUjagCpcolw+9 dooTMb81Oq6UElaW5YMV1gJEOih9vGS2srFxor7RvzDOy0yO2e5bIDw990JoLIpgMkIJ BzSRT+hdQ6EtHPghOC4TJ0n3a3ed49gmFqixPUvUmieE2DYmUiYTnFSHERh0D7c7lr5T 6rxILWi6eMub+/ZCpYuikbIhi9FtW3LR5wYlot+9GTLU2LLRZxIkmrx+8O6kjB1BV1NN 6BFA== X-Gm-Message-State: APjAAAVYnbAgguF6/7VYQeTdfXxboLD0g6ls6U9uQsB1TqUtVp4xMUni TjKDhdVj/uIi99CwoXh7QyT4LJaUTaw= X-Google-Smtp-Source: APXvYqwtRVmCG1ARmbdLuLN5TLXRWlDXeduPpXKaQqk9x+tN4bppuLQSOjFIMlVZ00QWYUoX3M3URg== X-Received: by 2002:a17:902:7887:: with SMTP id q7mr23881753pll.86.1574604573851; Sun, 24 Nov 2019 06:09:33 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id a3sm4816326pgh.91.2019.11.24.06.09.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 24 Nov 2019 06:09:33 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Akinobu Mita , Sujith Thomas , Darren Hart , Andy Shevchenko , Zhang Rui , Eduardo Valentin , Daniel Lezcano , Amit Kucheria , Jean Delvare , Guenter Roeck , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg Subject: [PATCH 5/8] thermal: int340x: switch to use helpers Date: Sun, 24 Nov 2019 23:08:47 +0900 Message-Id: <1574604530-9024-6-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574604530-9024-1-git-send-email-akinobu.mita@gmail.com> References: <1574604530-9024-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This switches the int340x thermal zone driver to use deci_kelvin_to_millicelsius() and millicelsius_to_deci_kelvin() in instead of helpers in . This is preparation for centralizing the kelvin to/from Celsius conversion helpers in . Cc: Sujith Thomas Cc: Darren Hart Cc: Andy Shevchenko Cc: Zhang Rui Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: Amit Kucheria Cc: Jean Delvare Cc: Guenter Roeck Cc: Keith Busch Cc: Jens Axboe Cc: Christoph Hellwig Cc: Sagi Grimberg Signed-off-by: Akinobu Mita --- drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c index 75484d6..1e653f6 100644 --- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c +++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c @@ -34,7 +34,7 @@ static int int340x_thermal_get_zone_temp(struct thermal_zone_device *zone, *temp = (unsigned long)conv_temp * 10; } else /* _TMP returns the temperature in tenths of degrees Kelvin */ - *temp = DECI_KELVIN_TO_MILLICELSIUS(tmp); + *temp = deci_kelvin_to_millicelsius(tmp); return 0; } @@ -116,7 +116,7 @@ static int int340x_thermal_set_trip_temp(struct thermal_zone_device *zone, snprintf(name, sizeof(name), "PAT%d", trip); status = acpi_execute_simple_method(d->adev->handle, name, - MILLICELSIUS_TO_DECI_KELVIN(temp)); + millicelsius_to_deci_kelvin(temp)); if (ACPI_FAILURE(status)) return -EIO; @@ -163,7 +163,7 @@ static int int340x_thermal_get_trip_config(acpi_handle handle, char *name, if (ACPI_FAILURE(status)) return -EIO; - *temp = DECI_KELVIN_TO_MILLICELSIUS(r); + *temp = deci_kelvin_to_millicelsius(r); return 0; } From patchwork Sun Nov 24 14:08:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11259199 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F326F1390 for ; Sun, 24 Nov 2019 14:09:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D4E022080D for ; Sun, 24 Nov 2019 14:09:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="avJspCbw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727232AbfKXOJk (ORCPT ); Sun, 24 Nov 2019 09:09:40 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:40060 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726767AbfKXOJj (ORCPT ); Sun, 24 Nov 2019 09:09:39 -0500 Received: by mail-pg1-f194.google.com with SMTP id e17so5752403pgd.7; Sun, 24 Nov 2019 06:09:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BIZEOh+2SoolQV+w98xfGiKw61hN8b99t1HqhjHBMcw=; b=avJspCbwxgRf8JRPnfdcCZ4RaMm0FlX+WmFZqgukiH8xG1GXXb0pjfOytH3Yz5n9V/ QFlR7GDaFK4Xln+GbiKZzXwdRLKODx4/eM3hHKE7Jo2naU8Fmh8FOKJH7zIPOr+nJG58 dc2c/en1D0+/FklNhFoL2s0RegFtqkiG9XY8tLsmfEk2FfS9/1fSNi1kUw//VAmxEvaj 3hO9ShGZ20KDz98C+aincxS9/tRnkwBEp1PVmJ8kHfop97MLw3vjAgzyVlnDQYc3K+vM ngEOz6uUXJ4oAGYqyucJlNnEaJUbqn5KIjRj8Ke78K6D4qHICgweSrCQgY8rEaXVIDQF QabQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BIZEOh+2SoolQV+w98xfGiKw61hN8b99t1HqhjHBMcw=; b=FSrtUDAM7IdZBpnWlT88QCUFjNy7awTrUqoB4JU5gw352Kop/0IGBYOMFw25TQS/wa Lm45i56UL2DsbBc/VKbjm2A9bW2+wt42bvVogzqIdZT0PvhUNBkhlCXjI8RZvRYaimQq ZucWnFE4HazlyTKetn4awqDjO+dmIzzJDxLk300jmo+lbtpYcXUzupPuLg6wgnkBiL5d gjp8KYtyBkL6K423/MBVMCEer5Tv3OxWvUzTk1vN5/ex10LUH0xDII3S3e6uWwJQDFvb OpfWph5FyMbJkS0ktkwz8MePKwgy4W26+9PuR6ggp21Lpzc7kHiW9yPQfmqiDoSiIRmI vchw== X-Gm-Message-State: APjAAAUnJMHDEu8eXV6Lc89j77wYnflSCfkhEXeAdfFH7fNhCAyxyNnH luJD8mu8Dyh3pCBDhMkj//A= X-Google-Smtp-Source: APXvYqzV4/N4HOdxJ0cQtjPpcUY8RcPuU/t/SwDDADaMHBYnSSbkvE2bypioZl57w/Aw1BOYLeiOig== X-Received: by 2002:a63:ff0b:: with SMTP id k11mr28003070pgi.274.1574604578685; Sun, 24 Nov 2019 06:09:38 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id a3sm4816326pgh.91.2019.11.24.06.09.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 24 Nov 2019 06:09:37 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Akinobu Mita , Sujith Thomas , Darren Hart , Andy Shevchenko , Zhang Rui , Eduardo Valentin , Daniel Lezcano , Amit Kucheria , Jean Delvare , Guenter Roeck , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg Subject: [PATCH 6/8] thermal: intel_pch: switch to use helpers Date: Sun, 24 Nov 2019 23:08:48 +0900 Message-Id: <1574604530-9024-7-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574604530-9024-1-git-send-email-akinobu.mita@gmail.com> References: <1574604530-9024-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This switches the intel pch thermal driver to use deci_kelvin_to_millicelsius() in instead of helpers in . This is preparation for centralizing the kelvin to/from Celsius conversion helpers in . Cc: Sujith Thomas Cc: Darren Hart Cc: Andy Shevchenko Cc: Zhang Rui Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: Amit Kucheria Cc: Jean Delvare Cc: Guenter Roeck Cc: Keith Busch Cc: Jens Axboe Cc: Christoph Hellwig Cc: Sagi Grimberg Signed-off-by: Akinobu Mita --- drivers/thermal/intel/intel_pch_thermal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/thermal/intel/intel_pch_thermal.c b/drivers/thermal/intel/intel_pch_thermal.c index 4f0bb8f..3cce310 100644 --- a/drivers/thermal/intel/intel_pch_thermal.c +++ b/drivers/thermal/intel/intel_pch_thermal.c @@ -92,7 +92,7 @@ static void pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd, if (ACPI_SUCCESS(status)) { unsigned long trip_temp; - trip_temp = DECI_KELVIN_TO_MILLICELSIUS(r); + trip_temp = deci_kelvin_to_millicelsius(r); if (trip_temp) { ptd->psv_temp = trip_temp; ptd->psv_trip_id = *nr_trips; From patchwork Sun Nov 24 14:08:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11259201 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B522138C for ; Sun, 24 Nov 2019 14:09:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4B5842080D for ; Sun, 24 Nov 2019 14:09:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Kz9sL7W0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727113AbfKXOJp (ORCPT ); Sun, 24 Nov 2019 09:09:45 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:34802 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726767AbfKXOJp (ORCPT ); Sun, 24 Nov 2019 09:09:45 -0500 Received: by mail-pl1-f194.google.com with SMTP id h13so5285254plr.1; Sun, 24 Nov 2019 06:09:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=U1P9v0dgTe+tqKEsZgzPVW6SYco9pFADyOLzbri3i3o=; b=Kz9sL7W0b88wM7v84z7h9smblf5jN9O8ktOA2awNOw8mBpflPc+/KSgNWvJtEN9Ys9 F4f/oAx+sunNNg1ZCGyUoZ0cRahUe7xMkKoBBzzVL83qK04vDVVayv/fI572plwAZAVt QcWAv2kgKRwnNRcmwZej3IE7khJ3gNLjgY3taNMMwSC87PUZMYnLER+H6Ho5WDt2MAX+ Dv5wZ6nj2hqLceXsekhF2bJ5GKXM9524Y2jZeLp6KaQLn9GGF/dsvC9mg7zmdStAiEuH KoZX83cxCGrf+U3VhwMQ1D1ymU6lYc59Kv9iEwZzprN8ENNvO24N0mBR/rvarKRQTg2B 7IVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=U1P9v0dgTe+tqKEsZgzPVW6SYco9pFADyOLzbri3i3o=; b=hQltJdN49mbplScsQ9MY2h+PWouhJp+mNIVSMoc6XmnJLOg9bGzEXY4Ccbc61xv/+M OCP+4tpZ4279Ul1BrIrICIDQaZ7RyaZK3ncu+6Q/nVUpNB0NK1L6PY4oM4K1nsjmh7BA nUZxjI8T6Inx60GPoQo0Ohk9X9CCINzsgTuX2B2+0kEhcHFHxuxz4KPIrNr6LfXJ1EmS zNuzld7DYVHzVficNmPJFDyU8Y5jpBUbhdA5jR4o0e3MwSl+qz+qrUkACqYqAvel8QRz EVEvTwHVcFJAqW1d+P8Oba5Id2WB8A++D59sTb6/mPZsn0i9TyTbTGBLbyPRNn9d2ytT B9dg== X-Gm-Message-State: APjAAAVmbLV27tMM04hW9RKo5jXxOZTUCBISrbol/M0lf3s5845Z7LLJ 9qc3k3r7Y+xPLn6yTzneMdY= X-Google-Smtp-Source: APXvYqxcF5r37Oiwyu5+ys9DsjUH1+Liw6DJ02nCZXdgEGvValZg9tQzOwytoD8owu4j8zGYh/CBlA== X-Received: by 2002:a17:902:7c8f:: with SMTP id y15mr23001423pll.341.1574604584222; Sun, 24 Nov 2019 06:09:44 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id a3sm4816326pgh.91.2019.11.24.06.09.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 24 Nov 2019 06:09:43 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Akinobu Mita , Sujith Thomas , Darren Hart , Andy Shevchenko , Zhang Rui , Eduardo Valentin , Daniel Lezcano , Amit Kucheria , Jean Delvare , Guenter Roeck , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg Subject: [PATCH 7/8] nvme: hwmon: switch to use helpers Date: Sun, 24 Nov 2019 23:08:49 +0900 Message-Id: <1574604530-9024-8-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574604530-9024-1-git-send-email-akinobu.mita@gmail.com> References: <1574604530-9024-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This switches the nvme driver to use kelvin_to_millicelsius() and millicelsius_to_kelvin() in . Cc: Sujith Thomas Cc: Darren Hart Cc: Andy Shevchenko Cc: Zhang Rui Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: Amit Kucheria Cc: Jean Delvare Cc: Guenter Roeck Cc: Keith Busch Cc: Jens Axboe Cc: Christoph Hellwig Cc: Sagi Grimberg Signed-off-by: Akinobu Mita Reviewed-by: Christoph Hellwig --- drivers/nvme/host/hwmon.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/nvme/host/hwmon.c b/drivers/nvme/host/hwmon.c index a5af21f..14720c1 100644 --- a/drivers/nvme/host/hwmon.c +++ b/drivers/nvme/host/hwmon.c @@ -5,14 +5,11 @@ */ #include +#include #include #include "nvme.h" -/* These macros should be moved to linux/temperature.h */ -#define MILLICELSIUS_TO_KELVIN(t) DIV_ROUND_CLOSEST((t) + 273150, 1000) -#define KELVIN_TO_MILLICELSIUS(t) ((t) * 1000L - 273150) - struct nvme_hwmon_data { struct nvme_ctrl *ctrl; struct nvme_smart_log log; @@ -35,7 +32,7 @@ static int nvme_get_temp_thresh(struct nvme_ctrl *ctrl, int sensor, bool under, return -EIO; if (ret < 0) return ret; - *temp = KELVIN_TO_MILLICELSIUS(status & NVME_TEMP_THRESH_MASK); + *temp = kelvin_to_millicelsius(status & NVME_TEMP_THRESH_MASK); return 0; } @@ -46,7 +43,7 @@ static int nvme_set_temp_thresh(struct nvme_ctrl *ctrl, int sensor, bool under, unsigned int threshold = sensor << NVME_TEMP_THRESH_SELECT_SHIFT; int ret; - temp = MILLICELSIUS_TO_KELVIN(temp); + temp = millicelsius_to_kelvin(temp); threshold |= clamp_val(temp, 0, NVME_TEMP_THRESH_MASK); if (under) @@ -88,7 +85,7 @@ static int nvme_hwmon_read(struct device *dev, enum hwmon_sensor_types type, case hwmon_temp_min: return nvme_get_temp_thresh(data->ctrl, channel, true, val); case hwmon_temp_crit: - *val = KELVIN_TO_MILLICELSIUS(data->ctrl->cctemp); + *val = kelvin_to_millicelsius(data->ctrl->cctemp); return 0; default: break; @@ -105,7 +102,7 @@ static int nvme_hwmon_read(struct device *dev, enum hwmon_sensor_types type, temp = get_unaligned_le16(log->temperature); else temp = le16_to_cpu(log->temp_sensor[channel - 1]); - *val = KELVIN_TO_MILLICELSIUS(temp); + *val = kelvin_to_millicelsius(temp); break; case hwmon_temp_alarm: *val = !!(log->critical_warning & NVME_SMART_CRIT_TEMPERATURE); From patchwork Sun Nov 24 14:08:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 11259207 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2FF231593 for ; Sun, 24 Nov 2019 14:09:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 111DA207FD for ; Sun, 24 Nov 2019 14:09:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aF+EL/ua" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727268AbfKXOJu (ORCPT ); Sun, 24 Nov 2019 09:09:50 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:44826 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726767AbfKXOJu (ORCPT ); Sun, 24 Nov 2019 09:09:50 -0500 Received: by mail-pg1-f195.google.com with SMTP id e6so5745617pgi.11; Sun, 24 Nov 2019 06:09:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HlZyESYLe6A5DAq1XkhuEkfPsYgeQ0ev4dh7nFf6DlA=; b=aF+EL/uaBuy3BwpoI2oa5LtqP9+p1sZ6VjixxtI6M70GSLCINBULaM3WNiSvJ1WIrZ xIp52aIi0nJQeAktwdoDbbpWpUGRijeoTLe1MAm4hB4Z4WYl9NAkew4iN56rugjskot4 yt0PkQGxQXJReAVRmTDpxgmvwAEprEGHPYHel8zMm9c4Pbf0nfdxKiEAsstWT0AfLR8r bDsPU9XMtHOa1IO5HUXITzT66ktxxcPF+Z9kAYhRpX5dnnkPp6PRQV0tZTGgJfpG2Hcz Q8Q4/16zkCk9xffjh+a8YQwbn/z/50qSQu4mMZdfby+ch8XiXZOg7GCvCrNQfdl2VLIo mnVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HlZyESYLe6A5DAq1XkhuEkfPsYgeQ0ev4dh7nFf6DlA=; b=iV6zmf0RUu6hsg8v6w0y/b39yhmMlbUsKsvq4E9CQKrm0hRM9iNB2f86trKuP+Q+WA gD6pML8cxJKgQL40qqWn0O/qK3Ew1R2rNuUTKm1t62PbLteA6yTnmY9x8fOtAH1uyexi LkeJO7pvTRgmohvnwo9sHAYbcJp9FjPOL1Mwm8x2a5+QuTAVN0agXp8gYTiBVk2EfCZy iv7hA9zEx23uDwNzWkfxI7X4iQMwAHJ0Ls2YNcWKdeKZrURdCl5u41lV0KtEL/mXgJkc 2j46iSBjibqqJZC6kucAfWR2FJ7CwFRwtkCd8XlzIQJgkVBMCw8TqUc0tzGoD1pqxpir BQDA== X-Gm-Message-State: APjAAAUUtTVlA0IgxxvpbVF5ju3idunD0fLK29OuFE5+ylWVwoEPACXC LrbNAhrQaUBdK8t/MtIde8QYEYl+35g= X-Google-Smtp-Source: APXvYqx7K4Gt18amX+hLKSOMgjI0zyd/A3QfgpeceRkltPJbTjqHafxczzSCZqTAx0AlbO7TqjQWng== X-Received: by 2002:a62:8789:: with SMTP id i131mr28078223pfe.221.1574604589140; Sun, 24 Nov 2019 06:09:49 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:368e:e048:68f1:84e7]) by smtp.gmail.com with ESMTPSA id a3sm4816326pgh.91.2019.11.24.06.09.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 24 Nov 2019 06:09:48 -0800 (PST) From: Akinobu Mita To: linux-nvme@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Akinobu Mita , Sujith Thomas , Darren Hart , Andy Shevchenko , Zhang Rui , Eduardo Valentin , Daniel Lezcano , Amit Kucheria , Jean Delvare , Guenter Roeck , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg Subject: [PATCH 8/8] thermal: remove kelvin to/from Celsius conversion helpers from Date: Sun, 24 Nov 2019 23:08:50 +0900 Message-Id: <1574604530-9024-9-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574604530-9024-1-git-send-email-akinobu.mita@gmail.com> References: <1574604530-9024-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This removes the kelvin to/from Celsius conversion helpers in which were switched to helpers. DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET() is only used by ACPI thermal zone driver and the usage is specific to the driver. So this macro is moved to the ACPI thermal driver rather than generic header. Cc: Sujith Thomas Cc: Darren Hart Cc: Andy Shevchenko Cc: Zhang Rui Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: Amit Kucheria Cc: Jean Delvare Cc: Guenter Roeck Cc: Keith Busch Cc: Jens Axboe Cc: Christoph Hellwig Cc: Sagi Grimberg Signed-off-by: Akinobu Mita --- drivers/acpi/thermal.c | 2 ++ include/linux/thermal.h | 11 ----------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index bd9b6eb..370e114 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -42,6 +42,8 @@ #define ACPI_THERMAL_MAX_ACTIVE 10 #define ACPI_THERMAL_MAX_LIMIT_STR_LEN 65 +#define DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(t, off) (((t) - (off)) * 100) + #define _COMPONENT ACPI_THERMAL_COMPONENT ACPI_MODULE_NAME("thermal"); diff --git a/include/linux/thermal.h b/include/linux/thermal.h index ed549e4..06e1695 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -33,17 +33,6 @@ /* use value, which < 0K, to indicate an invalid/uninitialized temperature */ #define THERMAL_TEMP_INVALID -274000 -/* Unit conversion macros */ -#define DECI_KELVIN_TO_CELSIUS(t) ({ \ - long _t = (t); \ - ((_t-2732 >= 0) ? (_t-2732+5)/10 : (_t-2732-5)/10); \ -}) -#define CELSIUS_TO_DECI_KELVIN(t) ((t)*10+2732) -#define DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(t, off) (((t) - (off)) * 100) -#define DECI_KELVIN_TO_MILLICELSIUS(t) DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(t, 2732) -#define MILLICELSIUS_TO_DECI_KELVIN_WITH_OFFSET(t, off) (((t) / 100) + (off)) -#define MILLICELSIUS_TO_DECI_KELVIN(t) MILLICELSIUS_TO_DECI_KELVIN_WITH_OFFSET(t, 2732) - /* Default Thermal Governor */ #if defined(CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE) #define DEFAULT_THERMAL_GOVERNOR "step_wise"