linux/thermal.h: Rename KELVIN_TO_CELSIUS to DECI_KELVIN_TO_CELSIUS
Subsystems (5)
PATCH 1/1 linux/thermal.h: Rename KELVIN_TO_CELSIUS to DECI_KELVIN_TO_CELSIUS
The macros KELVIN_TO_CELSIUS and CELSIUS_TO_KELVIN actually work on decikelvins, so rename them to reflect their actual semantics.
--- drivers/acpi/thermal.c | 12 ++++++------ drivers/platform/x86/asus-wmi.c | 2 +- drivers/platform/x86/intel_menlow.c | 8 ++++---- include/linux/thermal.h | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-)
drivers/acpi/thermal.c +6 -6
@@ -313,7 +313,7 @@ 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_KELVIN (crt); +unsigned long crt_k =CELSIUS_TO_DECI_KELVIN (crt);/* * Allow override critical threshold */
@@ -349,7 +349,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_KELVIN (psv); + tmp =CELSIUS_TO_DECI_KELVIN (psv); status =AE_OK ; }else { status = acpi_evaluate_integer(tz->device->handle,
@@ -429,7 +429,7 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)break ;if (i ==1 ) tz->trips.active[0 ].temperature = -CELSIUS_TO_KELVIN (act); +CELSIUS_TO_DECI_KELVIN (act);else /* * Don't allow override higher than
@@ -437,9 +437,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_KELVIN (act) ? +CELSIUS_TO_DECI_KELVIN (act) ? tz->trips.active[i -2 ].temperature : -CELSIUS_TO_KELVIN (act)); +CELSIUS_TO_DECI_KELVIN (act));break ; }else { tz->trips.active[i].temperature = tmp;
@@ -1094,7 +1094,7 @@ static int acpi_thermal_add(struct acpi_device *device) goto free_memory;pr_info (PREFIX "%s [%s] (%ld C)\n" ,acpi_device_name (device), -acpi_device_bid (device),KELVIN_TO_CELSIUS (tz->temperature)); +acpi_device_bid (device),DECI_KELVIN_TO_CELSIUS (tz->temperature)); goto end; free_memory:
drivers/platform/x86/asus-wmi.c +1 -1
@@ -1066,7 +1066,7 @@ static ssize_t asus_hwmon_temp1(struct device *dev,if (err <0 )return err; - value =KELVIN_TO_CELSIUS ((value &0xFFFF )) *1000 ; + value =DECI_KELVIN_TO_CELSIUS ((value &0xFFFF )) *1000 ;return sprintf (buf,"%d\n" , value); }
drivers/platform/x86/intel_menlow.c +4 -4
@@ -315,7 +315,7 @@ static ssize_t aux0_show(struct device *dev, result =sensor_get_auxtrip (attr->handle,0 , &value); -return result ? result :sprintf (buf,"%lu" ,KELVIN_TO_CELSIUS (value)); +return result ? result :sprintf (buf,"%lu" ,DECI_KELVIN_TO_CELSIUS (value)); } static ssize_t aux1_show(struct device *dev,
@@ -327,7 +327,7 @@ static ssize_t aux1_show(struct device *dev, result =sensor_get_auxtrip (attr->handle,1 , &value); -return result ? result :sprintf (buf,"%lu" ,KELVIN_TO_CELSIUS (value)); +return result ? result :sprintf (buf,"%lu" ,DECI_KELVIN_TO_CELSIUS (value)); } static ssize_t aux0_store(struct device *dev,
@@ -345,7 +345,7 @@ static ssize_t aux0_store(struct device *dev,if (value <0 )return -EINVAL ; - result =sensor_set_auxtrip (attr->handle,0 ,CELSIUS_TO_KELVIN (value)); + result =sensor_set_auxtrip (attr->handle,0 ,CELSIUS_TO_DECI_KELVIN (value));return result ? result : count; }
@@ -364,7 +364,7 @@ static ssize_t aux1_store(struct device *dev,if (value <0 )return -EINVAL ; - result =sensor_set_auxtrip (attr->handle,1 ,CELSIUS_TO_KELVIN (value)); + result =sensor_set_auxtrip (attr->handle,1 ,CELSIUS_TO_DECI_KELVIN (value));return result ? result : count; }
include/linux/thermal.h +3 -3
@@ -41,9 +41,9 @@#define THERMAL_NO_LIMIT THERMAL_CSTATE_INVALID/* Unit conversion macros */ -#define KELVIN_TO_CELSIUS (t) (long)(((long)t-2732 >= 0) ? \ - ((long)t-2732+5)/10 : ((long)t-2732-5)/10) -#define CELSIUS_TO_KELVIN (t) ((t)*10+2732) +#define DECI_KELVIN_TO_CELSIUS (t) (long)(((long)t-2732 >= 0) ? \ + ((long)t-2732+5)/10 : ((long)t-2732-5)/10) +#define CELSIUS_TO_DECI_KELVIN (t) ((t)*10+2732)/* Adding event notification support elements */ #define THERMAL_GENL_FAMILY_NAME "thermal_event"
Signature · 1 line
1.8.4.rc3.2.g61bff3f
Quoted 10 lines · Rasmus Villemoes
The macros
KELVIN_TO_CELSIUSandCELSIUS_TO_KELVINactually work on decikelvins, so rename them to reflect their actual semantics.Signed-off-by Rasmus Villemoes <[email protected]>--- drivers/acpi/thermal.c | 12 ++++++------ drivers/platform/x86/asus-wmi.c | 2 +- drivers/platform/x86/intel_menlow.c | 8 ++++---- include/linux/thermal.h | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-)
[snip]
Quoted 5 lines
include/linux/thermal.h +0
-0
include/linux/thermal.h line 46
Quoted 9 lines
include/linux/thermal.h +3
-3@@ -41,9 +41,9 @@#define THERMAL_NO_LIMIT THERMAL_CSTATE_INVALID/* Unit conversion macros */ -#define KELVIN_TO_CELSIUS (t) (long)(((long)t-2732 >= 0) ? \ - ((long)t-2732+5)/10 : ((long)t-2732-5)/10) -#define CELSIUS_TO_KELVIN (t) ((t)*10+2732) +#define DECI_KELVIN_TO_CELSIUS (t) (long)(((long)t-2732 >= 0) ? \ + ((long)t-2732+5)/10 : ((long)t-2732-5)/10) +#define CELSIUS_TO_DECI_KELVIN (t) ((t)*10+2732)
While you are at it, you could also make it use a statement expression as Joe Perches suggested earlier:
http://thread.gmane.org/gmane.linux.power-management.general/43978/focus=1671955
Cheers,
Javi
Zhang Rui
reviewerQuoted 4 lines · Rasmus Villemoes
The macros
KELVIN_TO_CELSIUSandCELSIUS_TO_KELVINactually work on decikelvins, so rename them to reflect their actual semantics.Signed-off-by Rasmus Villemoes <[email protected]>
applied on top of Guenter' "Fix KELVIN_TO_CELSIUS macro" patch.
thanks,
rui
Quoted 129 lines
--- drivers/acpi/thermal.c | 12 ++++++------ drivers/platform/x86/asus-wmi.c | 2 +- drivers/platform/x86/intel_menlow.c | 8 ++++---- include/linux/thermal.h | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-)drivers/acpi/thermal.c +6
-6@@ -313,7 +313,7 @@ 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_KELVIN (crt); +unsigned long crt_k =CELSIUS_TO_DECI_KELVIN (crt);/* * Allow override critical threshold */ @@ -349,7 +349,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_KELVIN (psv); + tmp =CELSIUS_TO_DECI_KELVIN (psv); status =AE_OK ; }else { status = acpi_evaluate_integer(tz->device->handle,@@ -429,7 +429,7 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)break ;if (i ==1 ) tz->trips.active[0 ].temperature = -CELSIUS_TO_KELVIN (act); +CELSIUS_TO_DECI_KELVIN (act);else /* * Don't allow override higher than @@ -437,9 +437,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_KELVIN (act) ? +CELSIUS_TO_DECI_KELVIN (act) ? tz->trips.active[i -2 ].temperature : -CELSIUS_TO_KELVIN (act)); +CELSIUS_TO_DECI_KELVIN (act));break ; }else { tz->trips.active[i].temperature = tmp;@@ -1094,7 +1094,7 @@ static int acpi_thermal_add(struct acpi_device *device) goto free_memory;pr_info (PREFIX "%s [%s] (%ld C)\n" ,acpi_device_name (device), -acpi_device_bid (device),KELVIN_TO_CELSIUS (tz->temperature)); +acpi_device_bid (device),DECI_KELVIN_TO_CELSIUS (tz->temperature)); goto end; free_memory:drivers/platform/x86/asus-wmi.c +1
-1@@ -1066,7 +1066,7 @@ static ssize_t asus_hwmon_temp1(struct device *dev,if (err <0 )return err; - value =KELVIN_TO_CELSIUS ((value &0xFFFF )) *1000 ; + value =DECI_KELVIN_TO_CELSIUS ((value &0xFFFF )) *1000 ;return sprintf (buf,"%d\n" , value); }drivers/platform/x86/intel_menlow.c +4
-4@@ -315,7 +315,7 @@ static ssize_t aux0_show(struct device *dev, result =sensor_get_auxtrip (attr->handle,0 , &value); -return result ? result :sprintf (buf,"%lu" ,KELVIN_TO_CELSIUS (value)); +return result ? result :sprintf (buf,"%lu" ,DECI_KELVIN_TO_CELSIUS (value)); } static ssize_t aux1_show(struct device *dev,@@ -327,7 +327,7 @@ static ssize_t aux1_show(struct device *dev, result =sensor_get_auxtrip (attr->handle,1 , &value); -return result ? result :sprintf (buf,"%lu" ,KELVIN_TO_CELSIUS (value)); +return result ? result :sprintf (buf,"%lu" ,DECI_KELVIN_TO_CELSIUS (value)); } static ssize_t aux0_store(struct device *dev,@@ -345,7 +345,7 @@ static ssize_t aux0_store(struct device *dev,if (value <0 )return -EINVAL ; - result =sensor_set_auxtrip (attr->handle,0 ,CELSIUS_TO_KELVIN (value)); + result =sensor_set_auxtrip (attr->handle,0 ,CELSIUS_TO_DECI_KELVIN (value));return result ? result : count; }@@ -364,7 +364,7 @@ static ssize_t aux1_store(struct device *dev,if (value <0 )return -EINVAL ; - result =sensor_set_auxtrip (attr->handle,1 ,CELSIUS_TO_KELVIN (value)); + result =sensor_set_auxtrip (attr->handle,1 ,CELSIUS_TO_DECI_KELVIN (value));return result ? result : count; }include/linux/thermal.h +3
-3@@ -41,9 +41,9 @@#define THERMAL_NO_LIMIT THERMAL_CSTATE_INVALID/* Unit conversion macros */ -#define KELVIN_TO_CELSIUS (t) (long)(((long)t-2732 >= 0) ? \ - ((long)t-2732+5)/10 : ((long)t-2732-5)/10) -#define CELSIUS_TO_KELVIN (t) ((t)*10+2732) +#define DECI_KELVIN_TO_CELSIUS (t) (long)(((long)t-2732 >= 0) ? \ + ((long)t-2732+5)/10 : ((long)t-2732-5)/10) +#define CELSIUS_TO_DECI_KELVIN (t) ((t)*10+2732)/* Adding event notification support elements */ #define THERMAL_GENL_FAMILY_NAME "thermal_event"