Linux-NVME Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/8] add header file for kelvin to/from Celsius conversion helpers
@ 2019-11-24 14:08 Akinobu Mita
  2019-11-24 14:08 ` [PATCH 1/8] " Akinobu Mita
                   ` (7 more replies)
  0 siblings, 8 replies; 26+ messages in thread
From: Akinobu Mita @ 2019-11-24 14:08 UTC (permalink / raw)
  To: linux-nvme, linux-hwmon, linux-pm, linux-kernel
  Cc: Jens Axboe, Amit Kucheria, Jean Delvare, Sagi Grimberg,
	Sujith Thomas, Daniel Lezcano, Akinobu Mita, Eduardo Valentin,
	Guenter Roeck, Keith Busch, Darren Hart, Zhang Rui,
	Christoph Hellwig, Andy Shevchenko

There are several helper macros to convert kelvin to/from Celsius in
<linux/thermal.h> for thermal drivers.  These are useful for any other
drivers or subsystems, but it's odd to include <linux/thermal.h> just for
the helpers.

This adds a new <linux/temperature.h> that provides the equivalent inline
functions for any drivers or subsystems, and switches all the users of
conversion helpers in <linux/thermal.h> to use <linux/temperature.h>
helpers.

Akinobu Mita (8):
  add header file for kelvin to/from Celsius conversion helpers
  ACPI: thermal: switch to use <linux/temperature.h> helpers
  platform/x86: asus-wmi: switch to use <linux/temperature.h> helpers
  platform/x86: intel_menlow: switch to use <linux/temperature.h>
    helpers
  thermal: int340x: switch to use <linux/temperature.h> helpers
  thermal: intel_pch: switch to use <linux/temperature.h> helpers
  nvme: hwmon: switch to use <linux/temperature.h> helpers
  thermal: remove kelvin to/from Celsius conversion helpers from
    <linux/thermal.h>

 drivers/acpi/thermal.c                             | 17 ++++++----
 drivers/nvme/host/hwmon.c                          | 13 +++-----
 drivers/platform/x86/asus-wmi.c                    |  7 ++--
 drivers/platform/x86/intel_menlow.c                |  8 +++--
 .../intel/int340x_thermal/int340x_thermal_zone.c   |  6 ++--
 drivers/thermal/intel/intel_pch_thermal.c          |  2 +-
 include/linux/temperature.h                        | 39 ++++++++++++++++++++++
 include/linux/thermal.h                            | 12 +------
 8 files changed, 68 insertions(+), 36 deletions(-)
 create mode 100644 include/linux/temperature.h

Cc: Sujith Thomas <sujith.thomas@intel.com>
Cc: Darren Hart <dvhart@infradead.org>
Cc: Andy Shevchenko <andy@infradead.org>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Amit Kucheria <amit.kucheria@verdurent.com>
Cc: Jean Delvare <jdelvare@suse.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Keith Busch <kbusch@kernel.org>
Cc: Jens Axboe <axboe@fb.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>
-- 
2.7.4


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 1/8] add header file for kelvin to/from Celsius conversion helpers
  2019-11-24 14:08 [PATCH 0/8] add header file for kelvin to/from Celsius conversion helpers Akinobu Mita
@ 2019-11-24 14:08 ` " Akinobu Mita
  2019-11-24 14:57   ` Andy Shevchenko
  2019-11-24 14:08 ` [PATCH 2/8] ACPI: thermal: switch to use <linux/temperature.h> helpers Akinobu Mita
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 26+ messages in thread
From: Akinobu Mita @ 2019-11-24 14:08 UTC (permalink / raw)
  To: linux-nvme, linux-hwmon, linux-pm, linux-kernel
  Cc: Jens Axboe, Amit Kucheria, Jean Delvare, Sagi Grimberg,
	Sujith Thomas, Daniel Lezcano, Akinobu Mita, Eduardo Valentin,
	Guenter Roeck, Keith Busch, Darren Hart, Zhang Rui,
	Christoph Hellwig, Andy Shevchenko

There are several helper macros to convert kelvin to/from Celsius in
<linux/thermal.h> for thermal drivers.  These are useful for any other
drivers or subsystems, but it's odd to include <linux/thermal.h> just for
the helpers.

This adds a new <linux/temperature.h> that provides the equivalent inline
functions for any drivers or subsystems.  It is intended to replace the
helpers in <linux/thermal.h>.

Cc: Sujith Thomas <sujith.thomas@intel.com>
Cc: Darren Hart <dvhart@infradead.org>
Cc: Andy Shevchenko <andy@infradead.org>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Amit Kucheria <amit.kucheria@verdurent.com>
Cc: Jean Delvare <jdelvare@suse.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Keith Busch <kbusch@kernel.org>
Cc: Jens Axboe <axboe@fb.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 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 <linux/kernel.h>
+
+#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 <linux/idr.h>
 #include <linux/device.h>
 #include <linux/sysfs.h>
+#include <linux/temperature.h>
 #include <linux/workqueue.h>
 #include <uapi/linux/thermal.h>
 
-- 
2.7.4


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 2/8] ACPI: thermal: switch to use <linux/temperature.h> helpers
  2019-11-24 14:08 [PATCH 0/8] add header file for kelvin to/from Celsius conversion helpers Akinobu Mita
  2019-11-24 14:08 ` [PATCH 1/8] " Akinobu Mita
@ 2019-11-24 14:08 ` Akinobu Mita
  2019-11-24 15:17   ` Guenter Roeck
  2019-11-24 14:08 ` [PATCH 3/8] platform/x86: asus-wmi: " Akinobu Mita
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 26+ messages in thread
From: Akinobu Mita @ 2019-11-24 14:08 UTC (permalink / raw)
  To: linux-nvme, linux-hwmon, linux-pm, linux-kernel
  Cc: Jens Axboe, Amit Kucheria, Jean Delvare, Sagi Grimberg,
	Sujith Thomas, Daniel Lezcano, Akinobu Mita, Eduardo Valentin,
	Guenter Roeck, Keith Busch, Darren Hart, Zhang Rui,
	Christoph Hellwig, Andy Shevchenko

This switches the ACPI thermal zone driver to use celsius_to_deci_kelvin()
and deci_kelvin_to_celsius() in <linux/temperature.h> instead of helpers
in <linux/thermal.h>.

This is preparation for centralizing the kelvin to/from Celsius conversion
helpers in <linux/temprature.h>.

Cc: Sujith Thomas <sujith.thomas@intel.com>
Cc: Darren Hart <dvhart@infradead.org>
Cc: Andy Shevchenko <andy@infradead.org>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Amit Kucheria <amit.kucheria@verdurent.com>
Cc: Jean Delvare <jdelvare@suse.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Keith Busch <kbusch@kernel.org>
Cc: Jens Axboe <axboe@fb.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 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:
-- 
2.7.4


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 3/8] platform/x86: asus-wmi: switch to use <linux/temperature.h> helpers
  2019-11-24 14:08 [PATCH 0/8] add header file for kelvin to/from Celsius conversion helpers Akinobu Mita
  2019-11-24 14:08 ` [PATCH 1/8] " Akinobu Mita
  2019-11-24 14:08 ` [PATCH 2/8] ACPI: thermal: switch to use <linux/temperature.h> helpers Akinobu Mita
@ 2019-11-24 14:08 ` " Akinobu Mita
  2019-11-24 19:54   ` Andy Shevchenko
  2019-11-24 14:08 ` [PATCH 4/8] platform/x86: intel_menlow: " Akinobu Mita
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 26+ messages in thread
From: Akinobu Mita @ 2019-11-24 14:08 UTC (permalink / raw)
  To: linux-nvme, linux-hwmon, linux-pm, linux-kernel
  Cc: Jens Axboe, Amit Kucheria, Jean Delvare, Sagi Grimberg,
	Sujith Thomas, Daniel Lezcano, Akinobu Mita, Eduardo Valentin,
	Guenter Roeck, Keith Busch, Darren Hart, Zhang Rui,
	Christoph Hellwig, Andy Shevchenko

The asus-wmi driver doesn't implement the thermal device functionality
directly, so including <linux/thermal.h> just for DECI_KELVIN_TO_CELSIUS()
is a bit odd.

This switches the asus-wmi driver to use deci_kelvin_to_millicelsius() in
<linux/temperature.h>.

Cc: Sujith Thomas <sujith.thomas@intel.com>
Cc: Darren Hart <dvhart@infradead.org>
Cc: Andy Shevchenko <andy@infradead.org>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Amit Kucheria <amit.kucheria@verdurent.com>
Cc: Jean Delvare <jdelvare@suse.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Keith Busch <kbusch@kernel.org>
Cc: Jens Axboe <axboe@fb.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 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 <linux/seq_file.h>
 #include <linux/platform_data/x86/asus-wmi.h>
 #include <linux/platform_device.h>
-#include <linux/thermal.h>
+#include <linux/temperature.h>
 #include <linux/acpi.h>
 #include <linux/dmi.h>
 
@@ -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 */
-- 
2.7.4


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 4/8] platform/x86: intel_menlow: switch to use <linux/temperature.h> helpers
  2019-11-24 14:08 [PATCH 0/8] add header file for kelvin to/from Celsius conversion helpers Akinobu Mita
                   ` (2 preceding siblings ...)
  2019-11-24 14:08 ` [PATCH 3/8] platform/x86: asus-wmi: " Akinobu Mita
@ 2019-11-24 14:08 ` " Akinobu Mita
  2019-11-24 19:57   ` Andy Shevchenko
  2019-11-24 14:08 ` [PATCH 5/8] thermal: int340x: " Akinobu Mita
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 26+ messages in thread
From: Akinobu Mita @ 2019-11-24 14:08 UTC (permalink / raw)
  To: linux-nvme, linux-hwmon, linux-pm, linux-kernel
  Cc: Jens Axboe, Amit Kucheria, Jean Delvare, Sagi Grimberg,
	Sujith Thomas, Daniel Lezcano, Akinobu Mita, Eduardo Valentin,
	Guenter Roeck, Keith Busch, Darren Hart, Zhang Rui,
	Christoph Hellwig, Andy Shevchenko

This switches the intel_menlow driver to use deci_kelvin_to_celsius() and
celsius_to_deci_kelvin() in <linux/temperature.h> instead of helpers in
<linux/thermal.h>.

This is preparation for centralizing the kelvin to/from Celsius conversion
helpers in <linux/temprature.h>.

Cc: Sujith Thomas <sujith.thomas@intel.com>
Cc: Darren Hart <dvhart@infradead.org>
Cc: Andy Shevchenko <andy@infradead.org>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Amit Kucheria <amit.kucheria@verdurent.com>
Cc: Jean Delvare <jdelvare@suse.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Keith Busch <kbusch@kernel.org>
Cc: Jens Axboe <axboe@fb.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 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;
 }
 
-- 
2.7.4


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 5/8] thermal: int340x: switch to use <linux/temperature.h> helpers
  2019-11-24 14:08 [PATCH 0/8] add header file for kelvin to/from Celsius conversion helpers Akinobu Mita
                   ` (3 preceding siblings ...)
  2019-11-24 14:08 ` [PATCH 4/8] platform/x86: intel_menlow: " Akinobu Mita
@ 2019-11-24 14:08 ` " Akinobu Mita
  2019-11-24 14:08 ` [PATCH 6/8] thermal: intel_pch: " Akinobu Mita
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 26+ messages in thread
From: Akinobu Mita @ 2019-11-24 14:08 UTC (permalink / raw)
  To: linux-nvme, linux-hwmon, linux-pm, linux-kernel
  Cc: Jens Axboe, Amit Kucheria, Jean Delvare, Sagi Grimberg,
	Sujith Thomas, Daniel Lezcano, Akinobu Mita, Eduardo Valentin,
	Guenter Roeck, Keith Busch, Darren Hart, Zhang Rui,
	Christoph Hellwig, Andy Shevchenko

This switches the int340x thermal zone driver to use
deci_kelvin_to_millicelsius() and millicelsius_to_deci_kelvin() in
<linux/temperature.h> instead of helpers in <linux/thermal.h>.

This is preparation for centralizing the kelvin to/from Celsius conversion
helpers in <linux/temprature.h>.

Cc: Sujith Thomas <sujith.thomas@intel.com>
Cc: Darren Hart <dvhart@infradead.org>
Cc: Andy Shevchenko <andy@infradead.org>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Amit Kucheria <amit.kucheria@verdurent.com>
Cc: Jean Delvare <jdelvare@suse.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Keith Busch <kbusch@kernel.org>
Cc: Jens Axboe <axboe@fb.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 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;
 }
-- 
2.7.4


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 6/8] thermal: intel_pch: switch to use <linux/temperature.h> helpers
  2019-11-24 14:08 [PATCH 0/8] add header file for kelvin to/from Celsius conversion helpers Akinobu Mita
                   ` (4 preceding siblings ...)
  2019-11-24 14:08 ` [PATCH 5/8] thermal: int340x: " Akinobu Mita
@ 2019-11-24 14:08 ` " Akinobu Mita
  2019-11-24 15:15   ` Guenter Roeck
  2019-11-24 14:08 ` [PATCH 7/8] nvme: hwmon: " Akinobu Mita
  2019-11-24 14:08 ` [PATCH 8/8] thermal: remove kelvin to/from Celsius conversion helpers from <linux/thermal.h> Akinobu Mita
  7 siblings, 1 reply; 26+ messages in thread
From: Akinobu Mita @ 2019-11-24 14:08 UTC (permalink / raw)
  To: linux-nvme, linux-hwmon, linux-pm, linux-kernel
  Cc: Jens Axboe, Amit Kucheria, Jean Delvare, Sagi Grimberg,
	Sujith Thomas, Daniel Lezcano, Akinobu Mita, Eduardo Valentin,
	Guenter Roeck, Keith Busch, Darren Hart, Zhang Rui,
	Christoph Hellwig, Andy Shevchenko

This switches the intel pch thermal driver to use
deci_kelvin_to_millicelsius() in <linux/temperature.h> instead of helpers
in <linux/thermal.h>.

This is preparation for centralizing the kelvin to/from Celsius conversion
helpers in <linux/temprature.h>.

Cc: Sujith Thomas <sujith.thomas@intel.com>
Cc: Darren Hart <dvhart@infradead.org>
Cc: Andy Shevchenko <andy@infradead.org>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Amit Kucheria <amit.kucheria@verdurent.com>
Cc: Jean Delvare <jdelvare@suse.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Keith Busch <kbusch@kernel.org>
Cc: Jens Axboe <axboe@fb.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 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;
-- 
2.7.4


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 7/8] nvme: hwmon: switch to use <linux/temperature.h> helpers
  2019-11-24 14:08 [PATCH 0/8] add header file for kelvin to/from Celsius conversion helpers Akinobu Mita
                   ` (5 preceding siblings ...)
  2019-11-24 14:08 ` [PATCH 6/8] thermal: intel_pch: " Akinobu Mita
@ 2019-11-24 14:08 ` " Akinobu Mita
  2019-11-25  6:59   ` Christoph Hellwig
  2019-11-24 14:08 ` [PATCH 8/8] thermal: remove kelvin to/from Celsius conversion helpers from <linux/thermal.h> Akinobu Mita
  7 siblings, 1 reply; 26+ messages in thread
From: Akinobu Mita @ 2019-11-24 14:08 UTC (permalink / raw)
  To: linux-nvme, linux-hwmon, linux-pm, linux-kernel
  Cc: Jens Axboe, Amit Kucheria, Jean Delvare, Sagi Grimberg,
	Sujith Thomas, Daniel Lezcano, Akinobu Mita, Eduardo Valentin,
	Guenter Roeck, Keith Busch, Darren Hart, Zhang Rui,
	Christoph Hellwig, Andy Shevchenko

This switches the nvme driver to use kelvin_to_millicelsius() and
millicelsius_to_kelvin() in <linux/temperature.h>.

Cc: Sujith Thomas <sujith.thomas@intel.com>
Cc: Darren Hart <dvhart@infradead.org>
Cc: Andy Shevchenko <andy@infradead.org>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Amit Kucheria <amit.kucheria@verdurent.com>
Cc: Jean Delvare <jdelvare@suse.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Keith Busch <kbusch@kernel.org>
Cc: Jens Axboe <axboe@fb.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 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 <linux/hwmon.h>
+#include <linux/temperature.h>
 #include <asm/unaligned.h>
 
 #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);
-- 
2.7.4


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 8/8] thermal: remove kelvin to/from Celsius conversion helpers from <linux/thermal.h>
  2019-11-24 14:08 [PATCH 0/8] add header file for kelvin to/from Celsius conversion helpers Akinobu Mita
                   ` (6 preceding siblings ...)
  2019-11-24 14:08 ` [PATCH 7/8] nvme: hwmon: " Akinobu Mita
@ 2019-11-24 14:08 ` Akinobu Mita
  2019-11-24 20:00   ` Andy Shevchenko
  7 siblings, 1 reply; 26+ messages in thread
From: Akinobu Mita @ 2019-11-24 14:08 UTC (permalink / raw)
  To: linux-nvme, linux-hwmon, linux-pm, linux-kernel
  Cc: Jens Axboe, Amit Kucheria, Jean Delvare, Sagi Grimberg,
	Sujith Thomas, Daniel Lezcano, Akinobu Mita, Eduardo Valentin,
	Guenter Roeck, Keith Busch, Darren Hart, Zhang Rui,
	Christoph Hellwig, Andy Shevchenko

This removes the kelvin to/from Celsius conversion helpers in
<linux/thermal.h> which were switched to <linux/temperature.h> 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 <sujith.thomas@intel.com>
Cc: Darren Hart <dvhart@infradead.org>
Cc: Andy Shevchenko <andy@infradead.org>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Amit Kucheria <amit.kucheria@verdurent.com>
Cc: Jean Delvare <jdelvare@suse.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Keith Busch <kbusch@kernel.org>
Cc: Jens Axboe <axboe@fb.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 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"
-- 
2.7.4


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 1/8] add header file for kelvin to/from Celsius conversion helpers
  2019-11-24 14:08 ` [PATCH 1/8] " Akinobu Mita
@ 2019-11-24 14:57   ` Andy Shevchenko
  2019-11-25 14:29     ` Akinobu Mita
  0 siblings, 1 reply; 26+ messages in thread
From: Andy Shevchenko @ 2019-11-24 14:57 UTC (permalink / raw)
  To: Akinobu Mita
  Cc: linux-hwmon, Jens Axboe, Amit Kucheria, Jean Delvare,
	Sagi Grimberg, Linux PM, Sujith Thomas, Daniel Lezcano,
	Linux Kernel Mailing List, Linux NVMe Mailinglist,
	Eduardo Valentin, Guenter Roeck, Keith Busch, Darren Hart,
	Zhang Rui, Christoph Hellwig, Andy Shevchenko

On Sun, Nov 24, 2019 at 4:09 PM Akinobu Mita <akinobu.mita@gmail.com> wrote:
>
> There are several helper macros to convert kelvin to/from Celsius in
> <linux/thermal.h> for thermal drivers.  These are useful for any other
> drivers or subsystems, but it's odd to include <linux/thermal.h> just for
> the helpers.
>
> This adds a new <linux/temperature.h> that provides the equivalent inline
> functions for any drivers or subsystems.  It is intended to replace the
> helpers in <linux/thermal.h>.
>
> Cc: Sujith Thomas <sujith.thomas@intel.com>
> Cc: Darren Hart <dvhart@infradead.org>
> Cc: Andy Shevchenko <andy@infradead.org>
> Cc: Zhang Rui <rui.zhang@intel.com>
> Cc: Eduardo Valentin <edubezval@gmail.com>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: Amit Kucheria <amit.kucheria@verdurent.com>
> Cc: Jean Delvare <jdelvare@suse.com>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: Keith Busch <kbusch@kernel.org>
> Cc: Jens Axboe <axboe@fb.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Sagi Grimberg <sagi@grimberg.me>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> ---
>  include/linux/temperature.h | 39 +++++++++++++++++++++++++++++++++++++++

>  include/linux/thermal.h     |  1 +


> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -14,6 +14,7 @@
>  #include <linux/idr.h>
>  #include <linux/device.h>
>  #include <linux/sysfs.h>
> +#include <linux/temperature.h>
>  #include <linux/workqueue.h>
>  #include <uapi/linux/thermal.h>

I don't see any users of it. Why did you include?

-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 6/8] thermal: intel_pch: switch to use <linux/temperature.h> helpers
  2019-11-24 14:08 ` [PATCH 6/8] thermal: intel_pch: " Akinobu Mita
@ 2019-11-24 15:15   ` Guenter Roeck
  0 siblings, 0 replies; 26+ messages in thread
From: Guenter Roeck @ 2019-11-24 15:15 UTC (permalink / raw)
  To: Akinobu Mita, linux-nvme, linux-hwmon, linux-pm, linux-kernel
  Cc: Jens Axboe, Amit Kucheria, Jean Delvare, Sagi Grimberg,
	Sujith Thomas, Daniel Lezcano, Eduardo Valentin, Keith Busch,
	Darren Hart, Zhang Rui, Christoph Hellwig, Andy Shevchenko

On 11/24/19 6:08 AM, Akinobu Mita wrote:
> This switches the intel pch thermal driver to use
> deci_kelvin_to_millicelsius() in <linux/temperature.h> instead of helpers
> in <linux/thermal.h>.
> 
> This is preparation for centralizing the kelvin to/from Celsius conversion
> helpers in <linux/temprature.h>.
> 
s/temprature/temperature/

> Cc: Sujith Thomas <sujith.thomas@intel.com>
> Cc: Darren Hart <dvhart@infradead.org>
> Cc: Andy Shevchenko <andy@infradead.org>
> Cc: Zhang Rui <rui.zhang@intel.com>
> Cc: Eduardo Valentin <edubezval@gmail.com>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: Amit Kucheria <amit.kucheria@verdurent.com>
> Cc: Jean Delvare <jdelvare@suse.com>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: Keith Busch <kbusch@kernel.org>
> Cc: Jens Axboe <axboe@fb.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Sagi Grimberg <sagi@grimberg.me>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> ---
>   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;
> 


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 2/8] ACPI: thermal: switch to use <linux/temperature.h> helpers
  2019-11-24 14:08 ` [PATCH 2/8] ACPI: thermal: switch to use <linux/temperature.h> helpers Akinobu Mita
@ 2019-11-24 15:17   ` Guenter Roeck
  2019-11-25 14:31     ` Akinobu Mita
  0 siblings, 1 reply; 26+ messages in thread
From: Guenter Roeck @ 2019-11-24 15:17 UTC (permalink / raw)
  To: Akinobu Mita, linux-nvme, linux-hwmon, linux-pm, linux-kernel
  Cc: Jens Axboe, Amit Kucheria, Jean Delvare, Sagi Grimberg,
	Sujith Thomas, Daniel Lezcano, Eduardo Valentin, Keith Busch,
	Darren Hart, Zhang Rui, Christoph Hellwig, Andy Shevchenko

On 11/24/19 6:08 AM, Akinobu Mita wrote:
> This switches the ACPI thermal zone driver to use celsius_to_deci_kelvin()
> and deci_kelvin_to_celsius() in <linux/temperature.h> instead of helpers
> in <linux/thermal.h>.
> 
> This is preparation for centralizing the kelvin to/from Celsius conversion
> helpers in <linux/temprature.h>.
> 
s/temprature/temperature/

Looks like this applies to all patches.

> Cc: Sujith Thomas <sujith.thomas@intel.com>
> Cc: Darren Hart <dvhart@infradead.org>
> Cc: Andy Shevchenko <andy@infradead.org>
> Cc: Zhang Rui <rui.zhang@intel.com>
> Cc: Eduardo Valentin <edubezval@gmail.com>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: Amit Kucheria <amit.kucheria@verdurent.com>
> Cc: Jean Delvare <jdelvare@suse.com>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: Keith Busch <kbusch@kernel.org>
> Cc: Jens Axboe <axboe@fb.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Sagi Grimberg <sagi@grimberg.me>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> ---
>   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:
> 


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 3/8] platform/x86: asus-wmi: switch to use <linux/temperature.h> helpers
  2019-11-24 14:08 ` [PATCH 3/8] platform/x86: asus-wmi: " Akinobu Mita
@ 2019-11-24 19:54   ` Andy Shevchenko
  2019-11-25 14:31     ` Akinobu Mita
  0 siblings, 1 reply; 26+ messages in thread
From: Andy Shevchenko @ 2019-11-24 19:54 UTC (permalink / raw)
  To: Akinobu Mita
  Cc: linux-hwmon, Jens Axboe, Amit Kucheria, Jean Delvare,
	Sagi Grimberg, Linux PM, Sujith Thomas, Daniel Lezcano,
	Linux Kernel Mailing List, Linux NVMe Mailinglist,
	Eduardo Valentin, Guenter Roeck, Keith Busch, Darren Hart,
	Zhang Rui, Christoph Hellwig, Andy Shevchenko

On Sun, Nov 24, 2019 at 4:09 PM Akinobu Mita <akinobu.mita@gmail.com> wrote:
>
> The asus-wmi driver doesn't implement the thermal device functionality
> directly, so including <linux/thermal.h> just for DECI_KELVIN_TO_CELSIUS()
> is a bit odd.
>
> This switches the asus-wmi driver to use deci_kelvin_to_millicelsius() in
> <linux/temperature.h>.
>
> Cc: Sujith Thomas <sujith.thomas@intel.com>
> Cc: Darren Hart <dvhart@infradead.org>
> Cc: Andy Shevchenko <andy@infradead.org>
> Cc: Zhang Rui <rui.zhang@intel.com>
> Cc: Eduardo Valentin <edubezval@gmail.com>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: Amit Kucheria <amit.kucheria@verdurent.com>
> Cc: Jean Delvare <jdelvare@suse.com>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: Keith Busch <kbusch@kernel.org>
> Cc: Jens Axboe <axboe@fb.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Sagi Grimberg <sagi@grimberg.me>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> ---
>  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 <linux/seq_file.h>
>  #include <linux/platform_data/x86/asus-wmi.h>
>  #include <linux/platform_device.h>
> -#include <linux/thermal.h>
> +#include <linux/temperature.h>
>  #include <linux/acpi.h>
>  #include <linux/dmi.h>
>
> @@ -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));

Leave it in one line.

With above,
Acked-by: Andy Shevchenko <andy.shevchenko@gmail.com>

>  }
>
>  /* Fan1 */
> --
> 2.7.4
>


-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 4/8] platform/x86: intel_menlow: switch to use <linux/temperature.h> helpers
  2019-11-24 14:08 ` [PATCH 4/8] platform/x86: intel_menlow: " Akinobu Mita
@ 2019-11-24 19:57   ` Andy Shevchenko
  2019-11-25 14:34     ` Akinobu Mita
  0 siblings, 1 reply; 26+ messages in thread
From: Andy Shevchenko @ 2019-11-24 19:57 UTC (permalink / raw)
  To: Akinobu Mita
  Cc: linux-hwmon, Jens Axboe, Amit Kucheria, Jean Delvare,
	Sagi Grimberg, Linux PM, Sujith Thomas, Daniel Lezcano,
	Linux Kernel Mailing List, Linux NVMe Mailinglist,
	Eduardo Valentin, Guenter Roeck, Keith Busch, Darren Hart,
	Zhang Rui, Christoph Hellwig, Andy Shevchenko

On Sun, Nov 24, 2019 at 4:09 PM Akinobu Mita <akinobu.mita@gmail.com> wrote:
>
> This switches the intel_menlow driver to use deci_kelvin_to_celsius() and
> celsius_to_deci_kelvin() in <linux/temperature.h> instead of helpers in
> <linux/thermal.h>.
>
> This is preparation for centralizing the kelvin to/from Celsius conversion
> helpers in <linux/temprature.h>.
>
> Cc: Sujith Thomas <sujith.thomas@intel.com>
> Cc: Darren Hart <dvhart@infradead.org>
> Cc: Andy Shevchenko <andy@infradead.org>
> Cc: Zhang Rui <rui.zhang@intel.com>
> Cc: Eduardo Valentin <edubezval@gmail.com>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: Amit Kucheria <amit.kucheria@verdurent.com>
> Cc: Jean Delvare <jdelvare@suse.com>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: Keith Busch <kbusch@kernel.org>
> Cc: Jens Axboe <axboe@fb.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Sagi Grimberg <sagi@grimberg.me>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> ---
>  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));

Can you explain the change %lu to %ld?

>  }
>
>  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));

How come the first line has been changed?

>         return result ? result : count;
>  }
>
> --
> 2.7.4
>


-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 8/8] thermal: remove kelvin to/from Celsius conversion helpers from <linux/thermal.h>
  2019-11-24 14:08 ` [PATCH 8/8] thermal: remove kelvin to/from Celsius conversion helpers from <linux/thermal.h> Akinobu Mita
@ 2019-11-24 20:00   ` Andy Shevchenko
  2019-11-25 14:39     ` Akinobu Mita
  0 siblings, 1 reply; 26+ messages in thread
From: Andy Shevchenko @ 2019-11-24 20:00 UTC (permalink / raw)
  To: Akinobu Mita
  Cc: linux-hwmon, Jens Axboe, Amit Kucheria, Jean Delvare,
	Sagi Grimberg, Linux PM, Sujith Thomas, Daniel Lezcano,
	Linux Kernel Mailing List, Linux NVMe Mailinglist,
	Eduardo Valentin, Guenter Roeck, Keith Busch, Darren Hart,
	Zhang Rui, Christoph Hellwig, Andy Shevchenko

On Sun, Nov 24, 2019 at 4:09 PM Akinobu Mita <akinobu.mita@gmail.com> wrote:
>
> This removes the kelvin to/from Celsius conversion helpers in
> <linux/thermal.h> which were switched to <linux/temperature.h> 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.

I didn't get this point. If we split all helpers, let's do it for all,
and not spreading macro per driver.

-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 7/8] nvme: hwmon: switch to use <linux/temperature.h> helpers
  2019-11-24 14:08 ` [PATCH 7/8] nvme: hwmon: " Akinobu Mita
@ 2019-11-25  6:59   ` Christoph Hellwig
  0 siblings, 0 replies; 26+ messages in thread
From: Christoph Hellwig @ 2019-11-25  6:59 UTC (permalink / raw)
  To: Akinobu Mita
  Cc: linux-hwmon, Jens Axboe, Amit Kucheria, Jean Delvare,
	Sagi Grimberg, linux-pm, Sujith Thomas, Daniel Lezcano,
	linux-kernel, linux-nvme, Eduardo Valentin, Guenter Roeck,
	Keith Busch, Darren Hart, Zhang Rui, Christoph Hellwig,
	Andy Shevchenko

On Sun, Nov 24, 2019 at 11:08:49PM +0900, Akinobu Mita wrote:
> This switches the nvme driver to use kelvin_to_millicelsius() and
> millicelsius_to_kelvin() in <linux/temperature.h>.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 1/8] add header file for kelvin to/from Celsius conversion helpers
  2019-11-24 14:57   ` Andy Shevchenko
@ 2019-11-25 14:29     ` Akinobu Mita
  2019-11-25 19:05       ` Andy Shevchenko
  0 siblings, 1 reply; 26+ messages in thread
From: Akinobu Mita @ 2019-11-25 14:29 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-hwmon, Jens Axboe, Amit Kucheria, Jean Delvare,
	Sagi Grimberg, Linux PM, Sujith Thomas, Daniel Lezcano,
	Linux Kernel Mailing List, Linux NVMe Mailinglist,
	Eduardo Valentin, Guenter Roeck, Keith Busch, Darren Hart,
	Zhang Rui, Christoph Hellwig, Andy Shevchenko

2019年11月24日(日) 23:57 Andy Shevchenko <andy.shevchenko@gmail.com>:
>
> On Sun, Nov 24, 2019 at 4:09 PM Akinobu Mita <akinobu.mita@gmail.com> wrote:
> >
> > There are several helper macros to convert kelvin to/from Celsius in
> > <linux/thermal.h> for thermal drivers.  These are useful for any other
> > drivers or subsystems, but it's odd to include <linux/thermal.h> just for
> > the helpers.
> >
> > This adds a new <linux/temperature.h> that provides the equivalent inline
> > functions for any drivers or subsystems.  It is intended to replace the
> > helpers in <linux/thermal.h>.
> >
> > Cc: Sujith Thomas <sujith.thomas@intel.com>
> > Cc: Darren Hart <dvhart@infradead.org>
> > Cc: Andy Shevchenko <andy@infradead.org>
> > Cc: Zhang Rui <rui.zhang@intel.com>
> > Cc: Eduardo Valentin <edubezval@gmail.com>
> > Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> > Cc: Amit Kucheria <amit.kucheria@verdurent.com>
> > Cc: Jean Delvare <jdelvare@suse.com>
> > Cc: Guenter Roeck <linux@roeck-us.net>
> > Cc: Keith Busch <kbusch@kernel.org>
> > Cc: Jens Axboe <axboe@fb.com>
> > Cc: Christoph Hellwig <hch@lst.de>
> > Cc: Sagi Grimberg <sagi@grimberg.me>
> > Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> > ---
> >  include/linux/temperature.h | 39 +++++++++++++++++++++++++++++++++++++++
>
> >  include/linux/thermal.h     |  1 +
>
>
> > --- a/include/linux/thermal.h
> > +++ b/include/linux/thermal.h
> > @@ -14,6 +14,7 @@
> >  #include <linux/idr.h>
> >  #include <linux/device.h>
> >  #include <linux/sysfs.h>
> > +#include <linux/temperature.h>
> >  #include <linux/workqueue.h>
> >  #include <uapi/linux/thermal.h>
>
> I don't see any users of it. Why did you include?

The rest of this patch series starts using it.

I decided to include <linux/temperature.h> from <linux/thermal.h> because
the existing <linux/thermal.h> provides the conversion helpers.

However, not all of the thermal drivers require these conversion helpers,
so we can change to include <linux/temperature.h> from each thermal driver
instead of including it from <linux/thermal.h>.

Which way do you prefer?

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 2/8] ACPI: thermal: switch to use <linux/temperature.h> helpers
  2019-11-24 15:17   ` Guenter Roeck
@ 2019-11-25 14:31     ` Akinobu Mita
  0 siblings, 0 replies; 26+ messages in thread
From: Akinobu Mita @ 2019-11-25 14:31 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: linux-hwmon, Jens Axboe, Amit Kucheria, Jean Delvare,
	Sagi Grimberg, Linux PM, Sujith Thomas, Daniel Lezcano, LKML,
	Linux NVMe Mailinglist, Eduardo Valentin, Keith Busch,
	Darren Hart, Zhang Rui, Christoph Hellwig, Andy Shevchenko

2019年11月25日(月) 0:17 Guenter Roeck <linux@roeck-us.net>:
>
> On 11/24/19 6:08 AM, Akinobu Mita wrote:
> > This switches the ACPI thermal zone driver to use celsius_to_deci_kelvin()
> > and deci_kelvin_to_celsius() in <linux/temperature.h> instead of helpers
> > in <linux/thermal.h>.
> >
> > This is preparation for centralizing the kelvin to/from Celsius conversion
> > helpers in <linux/temprature.h>.
> >
> s/temprature/temperature/
>
> Looks like this applies to all patches.

Oops.  I'll fix in the next version.

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 3/8] platform/x86: asus-wmi: switch to use <linux/temperature.h> helpers
  2019-11-24 19:54   ` Andy Shevchenko
@ 2019-11-25 14:31     ` Akinobu Mita
  2019-11-25 19:06       ` Andy Shevchenko
  0 siblings, 1 reply; 26+ messages in thread
From: Akinobu Mita @ 2019-11-25 14:31 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-hwmon, Jens Axboe, Amit Kucheria, Jean Delvare,
	Sagi Grimberg, Linux PM, Sujith Thomas, Daniel Lezcano,
	Linux Kernel Mailing List, Linux NVMe Mailinglist,
	Eduardo Valentin, Guenter Roeck, Keith Busch, Darren Hart,
	Zhang Rui, Christoph Hellwig, Andy Shevchenko

2019年11月25日(月) 4:54 Andy Shevchenko <andy.shevchenko@gmail.com>:
>
> On Sun, Nov 24, 2019 at 4:09 PM Akinobu Mita <akinobu.mita@gmail.com> wrote:
> >
> > The asus-wmi driver doesn't implement the thermal device functionality
> > directly, so including <linux/thermal.h> just for DECI_KELVIN_TO_CELSIUS()
> > is a bit odd.
> >
> > This switches the asus-wmi driver to use deci_kelvin_to_millicelsius() in
> > <linux/temperature.h>.
> >
> > Cc: Sujith Thomas <sujith.thomas@intel.com>
> > Cc: Darren Hart <dvhart@infradead.org>
> > Cc: Andy Shevchenko <andy@infradead.org>
> > Cc: Zhang Rui <rui.zhang@intel.com>
> > Cc: Eduardo Valentin <edubezval@gmail.com>
> > Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> > Cc: Amit Kucheria <amit.kucheria@verdurent.com>
> > Cc: Jean Delvare <jdelvare@suse.com>
> > Cc: Guenter Roeck <linux@roeck-us.net>
> > Cc: Keith Busch <kbusch@kernel.org>
> > Cc: Jens Axboe <axboe@fb.com>
> > Cc: Christoph Hellwig <hch@lst.de>
> > Cc: Sagi Grimberg <sagi@grimberg.me>
> > Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> > ---
> >  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 <linux/seq_file.h>
> >  #include <linux/platform_data/x86/asus-wmi.h>
> >  #include <linux/platform_device.h>
> > -#include <linux/thermal.h>
> > +#include <linux/temperature.h>
> >  #include <linux/acpi.h>
> >  #include <linux/dmi.h>
> >
> > @@ -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));
>
> Leave it in one line.

It causes this line over 80 characters.  Or do you prefer to save the
conversion result in 'value' temporarily as before?

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 4/8] platform/x86: intel_menlow: switch to use <linux/temperature.h> helpers
  2019-11-24 19:57   ` Andy Shevchenko
@ 2019-11-25 14:34     ` Akinobu Mita
  2019-11-25 19:07       ` Andy Shevchenko
  0 siblings, 1 reply; 26+ messages in thread
From: Akinobu Mita @ 2019-11-25 14:34 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-hwmon, Jens Axboe, Amit Kucheria, Jean Delvare,
	Sagi Grimberg, Linux PM, Sujith Thomas, Daniel Lezcano,
	Linux Kernel Mailing List, Linux NVMe Mailinglist,
	Eduardo Valentin, Guenter Roeck, Keith Busch, Darren Hart,
	Zhang Rui, Christoph Hellwig, Andy Shevchenko

2019年11月25日(月) 4:58 Andy Shevchenko <andy.shevchenko@gmail.com>:
>
> On Sun, Nov 24, 2019 at 4:09 PM Akinobu Mita <akinobu.mita@gmail.com> wrote:
> >
> > This switches the intel_menlow driver to use deci_kelvin_to_celsius() and
> > celsius_to_deci_kelvin() in <linux/temperature.h> instead of helpers in
> > <linux/thermal.h>.
> >
> > This is preparation for centralizing the kelvin to/from Celsius conversion
> > helpers in <linux/temprature.h>.
> >
> > Cc: Sujith Thomas <sujith.thomas@intel.com>
> > Cc: Darren Hart <dvhart@infradead.org>
> > Cc: Andy Shevchenko <andy@infradead.org>
> > Cc: Zhang Rui <rui.zhang@intel.com>
> > Cc: Eduardo Valentin <edubezval@gmail.com>
> > Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> > Cc: Amit Kucheria <amit.kucheria@verdurent.com>
> > Cc: Jean Delvare <jdelvare@suse.com>
> > Cc: Guenter Roeck <linux@roeck-us.net>
> > Cc: Keith Busch <kbusch@kernel.org>
> > Cc: Jens Axboe <axboe@fb.com>
> > Cc: Christoph Hellwig <hch@lst.de>
> > Cc: Sagi Grimberg <sagi@grimberg.me>
> > Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> > ---
> >  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));
>
> Can you explain the change %lu to %ld?

Isn't it possible for aux values to be lower than 0 degrees Celsius?

> >  }
> >
> >  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));
>
> How come the first line has been changed?

Because the trailing space is removed.  I'll mention it in the commit log.

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 8/8] thermal: remove kelvin to/from Celsius conversion helpers from <linux/thermal.h>
  2019-11-24 20:00   ` Andy Shevchenko
@ 2019-11-25 14:39     ` Akinobu Mita
  2019-11-25 19:08       ` Andy Shevchenko
  0 siblings, 1 reply; 26+ messages in thread
From: Akinobu Mita @ 2019-11-25 14:39 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-hwmon, Jens Axboe, Amit Kucheria, Jean Delvare,
	Sagi Grimberg, Linux PM, Sujith Thomas, Daniel Lezcano,
	Linux Kernel Mailing List, Linux NVMe Mailinglist,
	Eduardo Valentin, Guenter Roeck, Keith Busch, Darren Hart,
	Zhang Rui, Christoph Hellwig, Andy Shevchenko

2019年11月25日(月) 5:00 Andy Shevchenko <andy.shevchenko@gmail.com>:
>
> On Sun, Nov 24, 2019 at 4:09 PM Akinobu Mita <akinobu.mita@gmail.com> wrote:
> >
> > This removes the kelvin to/from Celsius conversion helpers in
> > <linux/thermal.h> which were switched to <linux/temperature.h> 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.
>
> I didn't get this point. If we split all helpers, let's do it for all,
> and not spreading macro per driver.

OK, I'll add deci_kelvin_to_millicelsius_with_offset() in the header.
But the unit of 'offset' argument will be in millidegree instead of
decidegree, because it's a bit more generic.

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 1/8] add header file for kelvin to/from Celsius conversion helpers
  2019-11-25 14:29     ` Akinobu Mita
@ 2019-11-25 19:05       ` Andy Shevchenko
  0 siblings, 0 replies; 26+ messages in thread
From: Andy Shevchenko @ 2019-11-25 19:05 UTC (permalink / raw)
  To: Akinobu Mita, edubezval
  Cc: linux-hwmon, Amit Kucheria, Jean Delvare, Sagi Grimberg,
	Linux PM, Sujith Thomas, Daniel Lezcano,
	Linux Kernel Mailing List, Linux NVMe Mailinglist, Jens Axboe,
	Guenter Roeck, Keith Busch, Darren Hart, Zhang Rui,
	Christoph Hellwig, Andy Shevchenko

On Mon, Nov 25, 2019 at 4:30 PM Akinobu Mita <akinobu.mita@gmail.com> wrote:
> 2019年11月24日(日) 23:57 Andy Shevchenko <andy.shevchenko@gmail.com>:
> > On Sun, Nov 24, 2019 at 4:09 PM Akinobu Mita <akinobu.mita@gmail.com> wrote:

> > >  include/linux/thermal.h     |  1 +

> > > --- a/include/linux/thermal.h
> > > +++ b/include/linux/thermal.h
> > > @@ -14,6 +14,7 @@
> > >  #include <linux/idr.h>
> > >  #include <linux/device.h>
> > >  #include <linux/sysfs.h>
> > > +#include <linux/temperature.h>
> > >  #include <linux/workqueue.h>
> > >  #include <uapi/linux/thermal.h>
> >
> > I don't see any users of it. Why did you include?
>
> The rest of this patch series starts using it.
>
> I decided to include <linux/temperature.h> from <linux/thermal.h> because
> the existing <linux/thermal.h> provides the conversion helpers.
>
> However, not all of the thermal drivers require these conversion helpers,
> so we can change to include <linux/temperature.h> from each thermal driver
> instead of including it from <linux/thermal.h>.
>
> Which way do you prefer?

I think users should include new header explicitly.

-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 3/8] platform/x86: asus-wmi: switch to use <linux/temperature.h> helpers
  2019-11-25 14:31     ` Akinobu Mita
@ 2019-11-25 19:06       ` Andy Shevchenko
  0 siblings, 0 replies; 26+ messages in thread
From: Andy Shevchenko @ 2019-11-25 19:06 UTC (permalink / raw)
  To: Akinobu Mita
  Cc: linux-hwmon, Jens Axboe, Amit Kucheria, Jean Delvare,
	Sagi Grimberg, Linux PM, Sujith Thomas, Daniel Lezcano,
	Linux Kernel Mailing List, Linux NVMe Mailinglist,
	Eduardo Valentin, Guenter Roeck, Keith Busch, Darren Hart,
	Zhang Rui, Christoph Hellwig, Andy Shevchenko

On Mon, Nov 25, 2019 at 4:32 PM Akinobu Mita <akinobu.mita@gmail.com> wrote:
> 2019年11月25日(月) 4:54 Andy Shevchenko <andy.shevchenko@gmail.com>:
> > On Sun, Nov 24, 2019 at 4:09 PM Akinobu Mita <akinobu.mita@gmail.com> wrote:

> > > -       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));
> >
> > Leave it in one line.
>
> It causes this line over 80 characters.

And I don't care.

>  Or do you prefer to save the
> conversion result in 'value' temporarily as before?

No.

-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 4/8] platform/x86: intel_menlow: switch to use <linux/temperature.h> helpers
  2019-11-25 14:34     ` Akinobu Mita
@ 2019-11-25 19:07       ` Andy Shevchenko
  2019-11-26 14:34         ` Akinobu Mita
  0 siblings, 1 reply; 26+ messages in thread
From: Andy Shevchenko @ 2019-11-25 19:07 UTC (permalink / raw)
  To: Akinobu Mita
  Cc: linux-hwmon, Jens Axboe, Amit Kucheria, Jean Delvare,
	Sagi Grimberg, Linux PM, Sujith Thomas, Daniel Lezcano,
	Linux Kernel Mailing List, Linux NVMe Mailinglist,
	Eduardo Valentin, Guenter Roeck, Keith Busch, Darren Hart,
	Zhang Rui, Christoph Hellwig, Andy Shevchenko

On Mon, Nov 25, 2019 at 4:35 PM Akinobu Mita <akinobu.mita@gmail.com> wrote:
> 2019年11月25日(月) 4:58 Andy Shevchenko <andy.shevchenko@gmail.com>:
> > On Sun, Nov 24, 2019 at 4:09 PM Akinobu Mita <akinobu.mita@gmail.com> wrote:

> > > -       return result ? result : sprintf(buf, "%lu", DECI_KELVIN_TO_CELSIUS(value));
> > > +       return sprintf(buf, "%ld", deci_kelvin_to_celsius(value));
> >
> > Can you explain the change %lu to %ld?
>
> Isn't it possible for aux values to be lower than 0 degrees Celsius?

If it's a change due to requirement of new helpers, put it in the
commit message, otherwise leave as is.

-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 8/8] thermal: remove kelvin to/from Celsius conversion helpers from <linux/thermal.h>
  2019-11-25 14:39     ` Akinobu Mita
@ 2019-11-25 19:08       ` Andy Shevchenko
  0 siblings, 0 replies; 26+ messages in thread
From: Andy Shevchenko @ 2019-11-25 19:08 UTC (permalink / raw)
  To: Akinobu Mita
  Cc: linux-hwmon, Jens Axboe, Amit Kucheria, Jean Delvare,
	Sagi Grimberg, Linux PM, Sujith Thomas, Daniel Lezcano,
	Linux Kernel Mailing List, Linux NVMe Mailinglist,
	Eduardo Valentin, Guenter Roeck, Keith Busch, Darren Hart,
	Zhang Rui, Christoph Hellwig, Andy Shevchenko

On Mon, Nov 25, 2019 at 4:40 PM Akinobu Mita <akinobu.mita@gmail.com> wrote:
> 2019年11月25日(月) 5:00 Andy Shevchenko <andy.shevchenko@gmail.com>:
> > On Sun, Nov 24, 2019 at 4:09 PM Akinobu Mita <akinobu.mita@gmail.com> wrote:

> > > 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.
> >
> > I didn't get this point. If we split all helpers, let's do it for all,
> > and not spreading macro per driver.
>
> OK, I'll add deci_kelvin_to_millicelsius_with_offset() in the header.

Thank you.

> But the unit of 'offset' argument will be in millidegree instead of
> decidegree, because it's a bit more generic.

It's fine as long as the helpers are consolidated and consistent.

-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 4/8] platform/x86: intel_menlow: switch to use <linux/temperature.h> helpers
  2019-11-25 19:07       ` Andy Shevchenko
@ 2019-11-26 14:34         ` Akinobu Mita
  0 siblings, 0 replies; 26+ messages in thread
From: Akinobu Mita @ 2019-11-26 14:34 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-hwmon, Jens Axboe, Amit Kucheria, Jean Delvare,
	Sagi Grimberg, Linux PM, Sujith Thomas, Daniel Lezcano,
	Linux Kernel Mailing List, Linux NVMe Mailinglist,
	Eduardo Valentin, Guenter Roeck, Keith Busch, Darren Hart,
	Zhang Rui, Christoph Hellwig, Andy Shevchenko

2019年11月26日(火) 4:07 Andy Shevchenko <andy.shevchenko@gmail.com>:
>
> On Mon, Nov 25, 2019 at 4:35 PM Akinobu Mita <akinobu.mita@gmail.com> wrote:
> > 2019年11月25日(月) 4:58 Andy Shevchenko <andy.shevchenko@gmail.com>:
> > > On Sun, Nov 24, 2019 at 4:09 PM Akinobu Mita <akinobu.mita@gmail.com> wrote:
>
> > > > -       return result ? result : sprintf(buf, "%lu", DECI_KELVIN_TO_CELSIUS(value));
> > > > +       return sprintf(buf, "%ld", deci_kelvin_to_celsius(value));
> > >
> > > Can you explain the change %lu to %ld?
> >
> > Isn't it possible for aux values to be lower than 0 degrees Celsius?
>
> If it's a change due to requirement of new helpers, put it in the
> commit message, otherwise leave as is.

OK, I'll leave it as is.
The format string will be fixed by a separate patch.

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, back to index

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-24 14:08 [PATCH 0/8] add header file for kelvin to/from Celsius conversion helpers Akinobu Mita
2019-11-24 14:08 ` [PATCH 1/8] " Akinobu Mita
2019-11-24 14:57   ` Andy Shevchenko
2019-11-25 14:29     ` Akinobu Mita
2019-11-25 19:05       ` Andy Shevchenko
2019-11-24 14:08 ` [PATCH 2/8] ACPI: thermal: switch to use <linux/temperature.h> helpers Akinobu Mita
2019-11-24 15:17   ` Guenter Roeck
2019-11-25 14:31     ` Akinobu Mita
2019-11-24 14:08 ` [PATCH 3/8] platform/x86: asus-wmi: " Akinobu Mita
2019-11-24 19:54   ` Andy Shevchenko
2019-11-25 14:31     ` Akinobu Mita
2019-11-25 19:06       ` Andy Shevchenko
2019-11-24 14:08 ` [PATCH 4/8] platform/x86: intel_menlow: " Akinobu Mita
2019-11-24 19:57   ` Andy Shevchenko
2019-11-25 14:34     ` Akinobu Mita
2019-11-25 19:07       ` Andy Shevchenko
2019-11-26 14:34         ` Akinobu Mita
2019-11-24 14:08 ` [PATCH 5/8] thermal: int340x: " Akinobu Mita
2019-11-24 14:08 ` [PATCH 6/8] thermal: intel_pch: " Akinobu Mita
2019-11-24 15:15   ` Guenter Roeck
2019-11-24 14:08 ` [PATCH 7/8] nvme: hwmon: " Akinobu Mita
2019-11-25  6:59   ` Christoph Hellwig
2019-11-24 14:08 ` [PATCH 8/8] thermal: remove kelvin to/from Celsius conversion helpers from <linux/thermal.h> Akinobu Mita
2019-11-24 20:00   ` Andy Shevchenko
2019-11-25 14:39     ` Akinobu Mita
2019-11-25 19:08       ` Andy Shevchenko

Linux-NVME Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-nvme/0 linux-nvme/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-nvme linux-nvme/ https://lore.kernel.org/linux-nvme \
		linux-nvme@lists.infradead.org
	public-inbox-index linux-nvme

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-nvme


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git