Skip to contentSkip to conversation

thermal: Share THERMAL_NO_LIMIT between kernel and DT bindings

PATCH In review Daniel Lezcano 3 participants 5 messages Oct 21

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thermal: Share THERMAL_NO_LIMIT between kernel and DT bindings

THERMAL_NO_LIMIT is defined separately in the thermal core and the DT bindings, using different expressions for the same no-limit sentinel.

Define it as 0xffffffff in the DT bindings header and include that header from linux/thermal.h. Remove the duplicate kernel definition so both interfaces use the same unsigned 32-bit value while preserving the existing DT encoding.

---
 include/dt-bindings/thermal/thermal.h | 2 +-
 include/linux/thermal.h               | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)
include/dt-bindings/thermal/thermal.h +1 -1
index bc7babb1a67c..018f75febb9f 100644
@@ -10,7 +10,7 @@
 #define _DT_BINDINGS_THERMAL_THERMAL_H
 
 /* On cooling devices upper and lower limits */
-#define THERMAL_NO_LIMIT		(~0)
+#define THERMAL_NO_LIMIT		0xffffffff /* ~0U */
 
 #endif
 
include/linux/thermal.h +2 -3
index 083b4f533933..a6f635f0e1f8 100644
@@ -17,12 +17,11 @@
 #include <linux/workqueue.h>
 #include <uapi/linux/thermal.h>
 
+#include <dt-bindings/thermal/thermal.h>
+
 /* invalid cooling state */
 #define THERMAL_CSTATE_INVALID -1UL
 
-/* No upper/lower limit requirement */
-#define THERMAL_NO_LIMIT	((u32)~0)
-
 /* Default weight of a bound cooling device */
 #define THERMAL_WEIGHT_DEFAULT 0
 
Signature · 1 line
2.53.0
#1 lore raw
Quoted 10 lines · Daniel Lezcano

THERMAL_NO_LIMIT is defined separately in the thermal core and the DT bindings, using different expressions for the same no-limit sentinel.

Define it as 0xffffffff in the DT bindings header and include that header from linux/thermal.h. Remove the duplicate kernel definition so both interfaces use the same unsigned 32-bit value while preserving the existing DT encoding.

But THERMAL_NO_LIMIT is also used by the core on systems without DT, so why is defining it in DT bindings not confusing?

Quoted 40 lines
---
 include/dt-bindings/thermal/thermal.h | 2 +-
 include/linux/thermal.h               | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)
include/dt-bindings/thermal/thermal.h +1 -1
index bc7babb1a67c..018f75febb9f 100644
@@ -10,7 +10,7 @@
 #define _DT_BINDINGS_THERMAL_THERMAL_H
 
 /* On cooling devices upper and lower limits */
-#define THERMAL_NO_LIMIT               (~0)
+#define THERMAL_NO_LIMIT               0xffffffff /* ~0U */
 
 #endif
 
include/linux/thermal.h +2 -4
index 083b4f533933..a6f635f0e1f8 100644
@@ -17,12 +17,11 @@
 #include <linux/workqueue.h>
 #include <uapi/linux/thermal.h>
 
+#include <dt-bindings/thermal/thermal.h>
+
 /* invalid cooling state */
 #define THERMAL_CSTATE_INVALID -1UL
 
-/* No upper/lower limit requirement */
-#define THERMAL_NO_LIMIT       ((u32)~0)
-
 /* Default weight of a bound cooling device */
 #define THERMAL_WEIGHT_DEFAULT 0
 
--

2.53.0

#2 lore raw
Quoted 11 lines · Rafael J. Wysocki (Intel)
Quoted 9 lines · Daniel Lezcano

THERMAL_NO_LIMIT is defined separately in the thermal core and the DT bindings, using different expressions for the same no-limit sentinel.

Define it as 0xffffffff in the DT bindings header and include that header from linux/thermal.h. Remove the duplicate kernel definition so both interfaces use the same unsigned 32-bit value while preserving the existing DT encoding.

Quoted 4 lines
Quoted 1 line

But THERMAL_NO_LIMIT is also used by the core on systems without DT, so why is defining it in DT bindings not confusing?

Yes, you are right. I missed ACPI relies on the THERMAL_NO_LIMIT default for the cooling spec

#3 lore raw
Quoted 13 lines · Daniel Lezcano
Quoted 11 lines · Rafael J. Wysocki (Intel)
Quoted 9 lines · Daniel Lezcano

THERMAL_NO_LIMIT is defined separately in the thermal core and the DT bindings, using different expressions for the same no-limit sentinel.

Define it as 0xffffffff in the DT bindings header and include that header from linux/thermal.h. Remove the duplicate kernel definition so both interfaces use the same unsigned 32-bit value while preserving the existing DT encoding.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

But THERMAL_NO_LIMIT is also used by the core on systems without DT, so why is defining it in DT bindings not confusing?

Yes, you are right. I missed ACPI relies on the THERMAL_NO_LIMIT default for the cooling spec

Well, in principle not just ACPI, but anyone whose .should_bind() leaves the struct cooling_spec as is.

#4 lore raw
In reply to Daniel Lezcano
Quoted 19 lines · Daniel Lezcano

THERMAL_NO_LIMIT is defined separately in the thermal core and the DT bindings, using different expressions for the same no-limit sentinel.

Define it as 0xffffffff in the DT bindings header and include that header from linux/thermal.h. Remove the duplicate kernel definition so both interfaces use the same unsigned 32-bit value while preserving the existing DT encoding.

---
 include/dt-bindings/thermal/thermal.h | 2 +-
 include/linux/thermal.h               | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)
include/dt-bindings/thermal/thermal.h +0 -0
index bc7babb1a67c..018f75febb9f 100644

include/dt-bindings/thermal/thermal.h line 13

Quoted 5 lines
include/dt-bindings/thermal/thermal.h +1 -1
@@ -10,7 +10,7 @@
 #define _DT_BINDINGS_THERMAL_THERMAL_H
 
 /* On cooling devices upper and lower limits */
-#define THERMAL_NO_LIMIT		(~0)
+#define THERMAL_NO_LIMIT		0xffffffff /* ~0U */

This should be actually separate patch, as we expect usually of bindings.

Best regards,
Krzysztof