Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

thermal: Fix cdev registration with THERMAL_NO_LIMIT on 64bit

The size of unsigned long varies between 32 and 64 bit systems while
the size of phandle arguments is always 32 bits per parameter.

On 64-bit systems, cooling devices registered via of-thermal apis fail
to bind when the min/max cooling state is specified as
THERMAL_NO_LIMIT (-1UL) as there is a mis-match between the value read
from the device tree (32bit) and the pre-processor define (64bit).

As we're unlikely to need cooling states larger than 32 bits, and for
consistency with the size of phandle arguments, explicitly limit
THERMAL_NO_LIMIT to 32 bits.

Reported-by: Hyungwoo Yang <hwoo.yang@gmail.com>
Acked-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>

authored by

Punit Agrawal and committed by
Eduardo Valentin
a940cb34 fcbb1e02

+2 -2
+1 -1
include/dt-bindings/thermal/thermal.h
··· 11 11 #define _DT_BINDINGS_THERMAL_THERMAL_H 12 12 13 13 /* On cooling devices upper and lower limits */ 14 - #define THERMAL_NO_LIMIT (-1UL) 14 + #define THERMAL_NO_LIMIT (~0) 15 15 16 16 #endif 17 17
+1 -1
include/linux/thermal.h
··· 38 38 #define THERMAL_CSTATE_INVALID -1UL 39 39 40 40 /* No upper/lower limit requirement */ 41 - #define THERMAL_NO_LIMIT THERMAL_CSTATE_INVALID 41 + #define THERMAL_NO_LIMIT ((u32)~0) 42 42 43 43 /* Unit conversion macros */ 44 44 #define KELVIN_TO_CELSIUS(t) (long)(((long)t-2732 >= 0) ? \