diff mbox series

[3/8] platform/x86: asus-wmi: switch to use <linux/temperature.h> helpers

Message ID 1574604530-9024-4-git-send-email-akinobu.mita@gmail.com (mailing list archive)
State Not Applicable
Headers show
Series add header file for kelvin to/from Celsius conversion helpers | expand

Commit Message

Akinobu Mita Nov. 24, 2019, 2:08 p.m. UTC
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(-)

Comments

Andy Shevchenko Nov. 24, 2019, 7:54 p.m. UTC | #1
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
>
Akinobu Mita Nov. 25, 2019, 2:31 p.m. UTC | #2
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?
Andy Shevchenko Nov. 25, 2019, 7:06 p.m. UTC | #3
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.
diff mbox series

Patch

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 */