2019-11-28 14:56:57

by Akinobu Mita

[permalink] [raw]
Subject: [PATCH v2 4/8] platform/x86: intel_menlow: switch to use <linux/temperature.h> helpers

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/temperature.h>.

This also removes a trailing space, while we're at it.

Cc: Sujith Thomas <[email protected]>
Cc: Darren Hart <[email protected]>
Cc: Andy Shevchenko <[email protected]>
Cc: Zhang Rui <[email protected]>
Cc: Daniel Lezcano <[email protected]>
Cc: Amit Kucheria <[email protected]>
Cc: Jean Delvare <[email protected]>
Cc: Guenter Roeck <[email protected]>
Cc: Keith Busch <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Sagi Grimberg <[email protected]>
Signed-off-by: Akinobu Mita <[email protected]>
---
* v2
- include <linux/temperature.h> explicitly from thermal drivers
- fix s/temprature/temperature/ typo in commit log
- don't mix up another fix (format string for cellsius value)

drivers/platform/x86/intel_menlow.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/intel_menlow.c b/drivers/platform/x86/intel_menlow.c
index b102f6d..12c1094 100644
--- a/drivers/platform/x86/intel_menlow.c
+++ b/drivers/platform/x86/intel_menlow.c
@@ -20,6 +20,7 @@
#include <linux/pci.h>
#include <linux/pm.h>
#include <linux/slab.h>
+#include <linux/temperature.h>
#include <linux/thermal.h>
#include <linux/types.h>

@@ -302,8 +303,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, "%lu", deci_kelvin_to_celsius(value));
}

static ssize_t aux0_show(struct device *dev,
@@ -332,8 +335,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


2019-11-28 15:06:50

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v2 4/8] platform/x86: intel_menlow: switch to use <linux/temperature.h> helpers

On Thu, Nov 28, 2019 at 4:55 PM Akinobu Mita <[email protected]> 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/temperature.h>.
>
> This also removes a trailing space, while we're at it.
>

Reviewed-by: Andy Shevchenko <[email protected]>

> Cc: Sujith Thomas <[email protected]>
> Cc: Darren Hart <[email protected]>
> Cc: Andy Shevchenko <[email protected]>
> Cc: Zhang Rui <[email protected]>
> Cc: Daniel Lezcano <[email protected]>
> Cc: Amit Kucheria <[email protected]>
> Cc: Jean Delvare <[email protected]>
> Cc: Guenter Roeck <[email protected]>
> Cc: Keith Busch <[email protected]>
> Cc: Jens Axboe <[email protected]>
> Cc: Christoph Hellwig <[email protected]>
> Cc: Sagi Grimberg <[email protected]>
> Signed-off-by: Akinobu Mita <[email protected]>
> ---
> * v2
> - include <linux/temperature.h> explicitly from thermal drivers
> - fix s/temprature/temperature/ typo in commit log
> - don't mix up another fix (format string for cellsius value)
>
> drivers/platform/x86/intel_menlow.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/platform/x86/intel_menlow.c b/drivers/platform/x86/intel_menlow.c
> index b102f6d..12c1094 100644
> --- a/drivers/platform/x86/intel_menlow.c
> +++ b/drivers/platform/x86/intel_menlow.c
> @@ -20,6 +20,7 @@
> #include <linux/pci.h>
> #include <linux/pm.h>
> #include <linux/slab.h>
> +#include <linux/temperature.h>
> #include <linux/thermal.h>
> #include <linux/types.h>
>
> @@ -302,8 +303,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, "%lu", deci_kelvin_to_celsius(value));
> }
>
> static ssize_t aux0_show(struct device *dev,
> @@ -332,8 +335,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
>


--
With Best Regards,
Andy Shevchenko