Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit d1fbf18

Browse files
committed
thermal: trip: Add conversion macros for thermal trip priv field
Some drivers will need to store integers in the priv field of struct thermal_trip, so add conversion macros for doing this in a consistent way and switch over the int340x_thermal driver that already does it and uses custom conversion functions to using the new macros. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/3297884.aeNJFYEL58@rjwysocki.net
1 parent 463b86f commit d1fbf18

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,6 @@ static void int340x_thermal_critical(struct thermal_zone_device *zone)
6262
thermal_zone_device_type(zone));
6363
}
6464

65-
static inline void *int_to_trip_priv(int i)
66-
{
67-
return (void *)(long)i;
68-
}
69-
70-
static inline int trip_priv_to_int(const struct thermal_trip *trip)
71-
{
72-
return (long)trip->priv;
73-
}
74-
7565
static int int340x_thermal_read_trips(struct acpi_device *zone_adev,
7666
struct thermal_trip *zone_trips,
7767
int trip_cnt)
@@ -106,7 +96,7 @@ static int int340x_thermal_read_trips(struct acpi_device *zone_adev,
10696
break;
10797

10898
zone_trips[trip_cnt].type = THERMAL_TRIP_ACTIVE;
109-
zone_trips[trip_cnt].priv = int_to_trip_priv(i);
99+
zone_trips[trip_cnt].priv = THERMAL_INT_TO_TRIP_PRIV(i);
110100
trip_cnt++;
111101
}
112102

@@ -224,7 +214,7 @@ static int int340x_update_one_trip(struct thermal_trip *trip, void *arg)
224214
break;
225215
case THERMAL_TRIP_ACTIVE:
226216
err = thermal_acpi_active_trip_temp(zone_adev,
227-
trip_priv_to_int(trip),
217+
THERMAL_TRIP_PRIV_TO_INT(trip->priv),
228218
&temp);
229219
break;
230220
default:

include/linux/thermal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ struct thermal_trip {
7979
#define THERMAL_TRIP_FLAG_RW (THERMAL_TRIP_FLAG_RW_TEMP | \
8080
THERMAL_TRIP_FLAG_RW_HYST)
8181

82+
#define THERMAL_TRIP_PRIV_TO_INT(_val_) (uintptr_t)(_val_)
83+
#define THERMAL_INT_TO_TRIP_PRIV(_val_) (void *)(uintptr_t)(_val_)
84+
8285
struct thermal_zone_device;
8386

8487
struct thermal_zone_device_ops {

0 commit comments

Comments
 (0)