Skip to content

Commit fae11de

Browse files
Daniel Lezcanodlezcano
authored andcommitted
thermal/core: Add thermal_trip in thermal_zone
The thermal trip points are properties of a thermal zone and the different sub systems should be able to save them in the thermal zone structure instead of having their own definition. Give the opportunity to the drivers to create a thermal zone with thermal trips which will be accessible directly from the thermal core framework. As we added the thermal trip points structure in the thermal zone, let's extend the thermal zone register function to have the thermal trip structures as a parameter and store it in the 'trips' field of the thermal zone structure. The thermal zone contains the trip point, we can store them directly when registering the thermal zone. That will allow another step forward to remove the duplicate thermal zone structure we find in the thermal_of code. Cc: Alexandre Bailon <[email protected]> Cc: Kevin Hilman <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Lezcano <[email protected]>
1 parent e5bfcd3 commit fae11de

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed

drivers/thermal/thermal_core.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,8 +1163,9 @@ static void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms
11631163
}
11641164

11651165
/**
1166-
* thermal_zone_device_register() - register a new thermal zone device
1166+
* thermal_zone_device_register_with_trips() - register a new thermal zone device
11671167
* @type: the thermal zone device type
1168+
* @trips: a pointer to an array of thermal trips
11681169
* @num_trips: the number of trip points the thermal zone support
11691170
* @mask: a bit string indicating the writeablility of trip points
11701171
* @devdata: private device data
@@ -1187,10 +1188,10 @@ static void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms
11871188
* IS_ERR*() helpers.
11881189
*/
11891190
struct thermal_zone_device *
1190-
thermal_zone_device_register(const char *type, int num_trips, int mask,
1191-
void *devdata, struct thermal_zone_device_ops *ops,
1192-
struct thermal_zone_params *tzp, int passive_delay,
1193-
int polling_delay)
1191+
thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *trips, int num_trips, int mask,
1192+
void *devdata, struct thermal_zone_device_ops *ops,
1193+
struct thermal_zone_params *tzp, int passive_delay,
1194+
int polling_delay)
11941195
{
11951196
struct thermal_zone_device *tz;
11961197
enum thermal_trip_type trip_type;
@@ -1251,6 +1252,7 @@ thermal_zone_device_register(const char *type, int num_trips, int mask,
12511252
tz->tzp = tzp;
12521253
tz->device.class = &thermal_class;
12531254
tz->devdata = devdata;
1255+
tz->trips = trips;
12541256
tz->num_trips = num_trips;
12551257

12561258
thermal_set_delay_jiffies(&tz->passive_delay_jiffies, passive_delay);
@@ -1327,6 +1329,16 @@ thermal_zone_device_register(const char *type, int num_trips, int mask,
13271329
kfree(tz);
13281330
return ERR_PTR(result);
13291331
}
1332+
1333+
struct thermal_zone_device *thermal_zone_device_register(const char *type, int ntrips, int mask,
1334+
void *devdata, struct thermal_zone_device_ops *ops,
1335+
struct thermal_zone_params *tzp, int passive_delay,
1336+
int polling_delay)
1337+
{
1338+
return thermal_zone_device_register_with_trips(type, NULL, ntrips, mask,
1339+
devdata, ops, tzp,
1340+
passive_delay, polling_delay);
1341+
}
13301342
EXPORT_SYMBOL_GPL(thermal_zone_device_register);
13311343

13321344
/**

drivers/thermal/thermal_of.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,11 +1119,9 @@ int __init of_parse_thermal_zones(void)
11191119
tzp->slope = tz->slope;
11201120
tzp->offset = tz->offset;
11211121

1122-
zone = thermal_zone_device_register(child->name, tz->ntrips,
1123-
mask, tz,
1124-
ops, tzp,
1125-
tz->passive_delay,
1126-
tz->polling_delay);
1122+
zone = thermal_zone_device_register_with_trips(child->name, tz->trips, tz->ntrips,
1123+
mask, tz, ops, tzp, tz->passive_delay,
1124+
tz->polling_delay);
11271125
if (IS_ERR(zone)) {
11281126
pr_err("Failed to build %pOFn zone %ld\n", child,
11291127
PTR_ERR(zone));

include/linux/thermal.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ struct thermal_cooling_device {
123123
* @trip_hyst_attrs: attributes for trip points for sysfs: trip hysteresis
124124
* @mode: current mode of this thermal zone
125125
* @devdata: private pointer for device private data
126+
* @trips: an array of struct thermal_trip
126127
* @num_trips: number of trip points the thermal zone supports
127128
* @trips_disabled; bitmap for disabled trips
128129
* @passive_delay_jiffies: number of jiffies to wait between polls when
@@ -163,6 +164,7 @@ struct thermal_zone_device {
163164
struct thermal_attr *trip_hyst_attrs;
164165
enum thermal_device_mode mode;
165166
void *devdata;
167+
struct thermal_trip *trips;
166168
int num_trips;
167169
unsigned long trips_disabled; /* bitmap for disabled trips */
168170
unsigned long passive_delay_jiffies;
@@ -376,8 +378,14 @@ void devm_thermal_zone_of_sensor_unregister(struct device *dev,
376378
struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
377379
void *, struct thermal_zone_device_ops *,
378380
struct thermal_zone_params *, int, int);
381+
379382
void thermal_zone_device_unregister(struct thermal_zone_device *);
380383

384+
struct thermal_zone_device *
385+
thermal_zone_device_register_with_trips(const char *, struct thermal_trip *, int, int,
386+
void *, struct thermal_zone_device_ops *,
387+
struct thermal_zone_params *, int, int);
388+
381389
int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int,
382390
struct thermal_cooling_device *,
383391
unsigned long, unsigned long,

0 commit comments

Comments
 (0)