Commit daeeb032 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

thermal: core: Move threshold out of struct thermal_trip

The threshold field in struct thermal_trip is only used internally by
the thermal core and it is better to prevent drivers from misusing it.
It also takes some space unnecessarily in the trip tables passed by
drivers to the core during thermal zone registration.

For this reason, introduce struct thermal_trip_desc as a wrapper around
struct thermal_trip, move the threshold field directly into it and make
the thermal core store struct thermal_trip_desc objects in the internal
thermal zone trip tables.  Adjust all of the code using trip tables in
the thermal core accordingly.

No intentional functional impact.
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: default avatarLukasz Luba <lukasz.luba@arm.com>
parent 053b852c
...@@ -17,10 +17,13 @@ ...@@ -17,10 +17,13 @@
static int get_trip_level(struct thermal_zone_device *tz) static int get_trip_level(struct thermal_zone_device *tz)
{ {
const struct thermal_trip *trip, *level_trip = NULL; const struct thermal_trip *level_trip = NULL;
const struct thermal_trip_desc *td;
int trip_level = -1; int trip_level = -1;
for_each_trip(tz, trip) { for_each_trip_desc(tz, td) {
const struct thermal_trip *trip = &td->trip;
if (trip->temperature >= tz->temperature) if (trip->temperature >= tz->temperature)
continue; continue;
......
...@@ -496,9 +496,11 @@ static void get_governor_trips(struct thermal_zone_device *tz, ...@@ -496,9 +496,11 @@ static void get_governor_trips(struct thermal_zone_device *tz,
const struct thermal_trip *first_passive = NULL; const struct thermal_trip *first_passive = NULL;
const struct thermal_trip *last_passive = NULL; const struct thermal_trip *last_passive = NULL;
const struct thermal_trip *last_active = NULL; const struct thermal_trip *last_active = NULL;
const struct thermal_trip *trip; const struct thermal_trip_desc *td;
for_each_trip_desc(tz, td) {
const struct thermal_trip *trip = &td->trip;
for_each_trip(tz, trip) {
switch (trip->type) { switch (trip->type) {
case THERMAL_TRIP_PASSIVE: case THERMAL_TRIP_PASSIVE:
if (!first_passive) { if (!first_passive) {
......
...@@ -361,17 +361,19 @@ static void handle_critical_trips(struct thermal_zone_device *tz, ...@@ -361,17 +361,19 @@ static void handle_critical_trips(struct thermal_zone_device *tz,
} }
static void handle_thermal_trip(struct thermal_zone_device *tz, static void handle_thermal_trip(struct thermal_zone_device *tz,
struct thermal_trip *trip) struct thermal_trip_desc *td)
{ {
const struct thermal_trip *trip = &td->trip;
if (trip->temperature == THERMAL_TEMP_INVALID) if (trip->temperature == THERMAL_TEMP_INVALID)
return; return;
if (tz->last_temperature == THERMAL_TEMP_INVALID) { if (tz->last_temperature == THERMAL_TEMP_INVALID) {
/* Initialization. */ /* Initialization. */
trip->threshold = trip->temperature; td->threshold = trip->temperature;
if (tz->temperature >= trip->threshold) if (tz->temperature >= td->threshold)
trip->threshold -= trip->hysteresis; td->threshold -= trip->hysteresis;
} else if (tz->last_temperature < trip->threshold) { } else if (tz->last_temperature < td->threshold) {
/* /*
* The trip threshold is equal to the trip temperature, unless * The trip threshold is equal to the trip temperature, unless
* the latter has changed in the meantime. In either case, * the latter has changed in the meantime. In either case,
...@@ -382,9 +384,9 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, ...@@ -382,9 +384,9 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
if (tz->temperature >= trip->temperature) { if (tz->temperature >= trip->temperature) {
thermal_notify_tz_trip_up(tz, trip); thermal_notify_tz_trip_up(tz, trip);
thermal_debug_tz_trip_up(tz, trip); thermal_debug_tz_trip_up(tz, trip);
trip->threshold = trip->temperature - trip->hysteresis; td->threshold = trip->temperature - trip->hysteresis;
} else { } else {
trip->threshold = trip->temperature; td->threshold = trip->temperature;
} }
} else { } else {
/* /*
...@@ -400,9 +402,9 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, ...@@ -400,9 +402,9 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
if (tz->temperature < trip->temperature - trip->hysteresis) { if (tz->temperature < trip->temperature - trip->hysteresis) {
thermal_notify_tz_trip_down(tz, trip); thermal_notify_tz_trip_down(tz, trip);
thermal_debug_tz_trip_down(tz, trip); thermal_debug_tz_trip_down(tz, trip);
trip->threshold = trip->temperature; td->threshold = trip->temperature;
} else { } else {
trip->threshold = trip->temperature - trip->hysteresis; td->threshold = trip->temperature - trip->hysteresis;
} }
} }
...@@ -458,7 +460,7 @@ static void thermal_zone_device_init(struct thermal_zone_device *tz) ...@@ -458,7 +460,7 @@ static void thermal_zone_device_init(struct thermal_zone_device *tz)
void __thermal_zone_device_update(struct thermal_zone_device *tz, void __thermal_zone_device_update(struct thermal_zone_device *tz,
enum thermal_notify_event event) enum thermal_notify_event event)
{ {
struct thermal_trip *trip; struct thermal_trip_desc *td;
if (tz->suspended) if (tz->suspended)
return; return;
...@@ -472,8 +474,8 @@ void __thermal_zone_device_update(struct thermal_zone_device *tz, ...@@ -472,8 +474,8 @@ void __thermal_zone_device_update(struct thermal_zone_device *tz,
tz->notify_event = event; tz->notify_event = event;
for_each_trip(tz, trip) for_each_trip_desc(tz, td)
handle_thermal_trip(tz, trip); handle_thermal_trip(tz, td);
monitor_thermal_zone(tz); monitor_thermal_zone(tz);
} }
...@@ -766,7 +768,7 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz, ...@@ -766,7 +768,7 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
if (trip_index < 0 || trip_index >= tz->num_trips) if (trip_index < 0 || trip_index >= tz->num_trips)
return -EINVAL; return -EINVAL;
return thermal_bind_cdev_to_trip(tz, &tz->trips[trip_index], cdev, return thermal_bind_cdev_to_trip(tz, &tz->trips[trip_index].trip, cdev,
upper, lower, weight); upper, lower, weight);
} }
EXPORT_SYMBOL_GPL(thermal_zone_bind_cooling_device); EXPORT_SYMBOL_GPL(thermal_zone_bind_cooling_device);
...@@ -825,7 +827,7 @@ int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz, ...@@ -825,7 +827,7 @@ int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz,
if (trip_index < 0 || trip_index >= tz->num_trips) if (trip_index < 0 || trip_index >= tz->num_trips)
return -EINVAL; return -EINVAL;
return thermal_unbind_cdev_from_trip(tz, &tz->trips[trip_index], cdev); return thermal_unbind_cdev_from_trip(tz, &tz->trips[trip_index].trip, cdev);
} }
EXPORT_SYMBOL_GPL(thermal_zone_unbind_cooling_device); EXPORT_SYMBOL_GPL(thermal_zone_unbind_cooling_device);
...@@ -1221,16 +1223,19 @@ static void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms ...@@ -1221,16 +1223,19 @@ static void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms
int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp) int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp)
{ {
int i, ret = -EINVAL; const struct thermal_trip_desc *td;
int ret = -EINVAL;
if (tz->ops.get_crit_temp) if (tz->ops.get_crit_temp)
return tz->ops.get_crit_temp(tz, temp); return tz->ops.get_crit_temp(tz, temp);
mutex_lock(&tz->lock); mutex_lock(&tz->lock);
for (i = 0; i < tz->num_trips; i++) { for_each_trip_desc(tz, td) {
if (tz->trips[i].type == THERMAL_TRIP_CRITICAL) { const struct thermal_trip *trip = &td->trip;
*temp = tz->trips[i].temperature;
if (trip->type == THERMAL_TRIP_CRITICAL) {
*temp = trip->temperature;
ret = 0; ret = 0;
break; break;
} }
...@@ -1274,7 +1279,9 @@ thermal_zone_device_register_with_trips(const char *type, ...@@ -1274,7 +1279,9 @@ thermal_zone_device_register_with_trips(const char *type,
const struct thermal_zone_params *tzp, const struct thermal_zone_params *tzp,
int passive_delay, int polling_delay) int passive_delay, int polling_delay)
{ {
const struct thermal_trip *trip = trips;
struct thermal_zone_device *tz; struct thermal_zone_device *tz;
struct thermal_trip_desc *td;
int id; int id;
int result; int result;
struct thermal_governor *governor; struct thermal_governor *governor;
...@@ -1339,7 +1346,8 @@ thermal_zone_device_register_with_trips(const char *type, ...@@ -1339,7 +1346,8 @@ thermal_zone_device_register_with_trips(const char *type,
tz->device.class = thermal_class; tz->device.class = thermal_class;
tz->devdata = devdata; tz->devdata = devdata;
tz->num_trips = num_trips; tz->num_trips = num_trips;
memcpy(tz->trips, trips, num_trips * sizeof(*trips)); for_each_trip_desc(tz, td)
td->trip = *trip++;
thermal_set_delay_jiffies(&tz->passive_delay_jiffies, passive_delay); thermal_set_delay_jiffies(&tz->passive_delay_jiffies, passive_delay);
thermal_set_delay_jiffies(&tz->polling_delay_jiffies, polling_delay); thermal_set_delay_jiffies(&tz->polling_delay_jiffies, polling_delay);
......
...@@ -120,8 +120,11 @@ void thermal_governor_update_tz(struct thermal_zone_device *tz, ...@@ -120,8 +120,11 @@ void thermal_governor_update_tz(struct thermal_zone_device *tz,
enum thermal_notify_event reason); enum thermal_notify_event reason);
/* Helpers */ /* Helpers */
#define for_each_trip(__tz, __trip) \ #define for_each_trip_desc(__tz, __td) \
for (__trip = __tz->trips; __trip - __tz->trips < __tz->num_trips; __trip++) for (__td = __tz->trips; __td - __tz->trips < __tz->num_trips; __td++)
#define trip_to_trip_desc(__trip) \
container_of(__trip, struct thermal_trip_desc, trip)
void __thermal_zone_set_trips(struct thermal_zone_device *tz); void __thermal_zone_set_trips(struct thermal_zone_device *tz);
int thermal_zone_trip_id(const struct thermal_zone_device *tz, int thermal_zone_trip_id(const struct thermal_zone_device *tz,
......
...@@ -744,7 +744,7 @@ static void tze_seq_stop(struct seq_file *s, void *v) ...@@ -744,7 +744,7 @@ static void tze_seq_stop(struct seq_file *s, void *v)
static int tze_seq_show(struct seq_file *s, void *v) static int tze_seq_show(struct seq_file *s, void *v)
{ {
struct thermal_zone_device *tz = s->private; struct thermal_zone_device *tz = s->private;
struct thermal_trip *trip; struct thermal_trip_desc *td;
struct tz_episode *tze; struct tz_episode *tze;
const char *type; const char *type;
int trip_id; int trip_id;
...@@ -757,7 +757,9 @@ static int tze_seq_show(struct seq_file *s, void *v) ...@@ -757,7 +757,9 @@ static int tze_seq_show(struct seq_file *s, void *v)
seq_printf(s, "| trip | type | temp(°mC) | hyst(°mC) | duration | avg(°mC) | min(°mC) | max(°mC) |\n"); seq_printf(s, "| trip | type | temp(°mC) | hyst(°mC) | duration | avg(°mC) | min(°mC) | max(°mC) |\n");
for_each_trip(tz, trip) { for_each_trip_desc(tz, td) {
const struct thermal_trip *trip = &td->trip;
/* /*
* There is no possible mitigation happening at the * There is no possible mitigation happening at the
* critical trip point, so the stats will be always * critical trip point, so the stats will be always
......
...@@ -50,7 +50,7 @@ get_thermal_instance(struct thermal_zone_device *tz, ...@@ -50,7 +50,7 @@ get_thermal_instance(struct thermal_zone_device *tz,
mutex_lock(&tz->lock); mutex_lock(&tz->lock);
mutex_lock(&cdev->lock); mutex_lock(&cdev->lock);
trip = &tz->trips[trip_index]; trip = &tz->trips[trip_index].trip;
list_for_each_entry(pos, &tz->thermal_instances, tz_node) { list_for_each_entry(pos, &tz->thermal_instances, tz_node) {
if (pos->tz == tz && pos->trip == trip && pos->cdev == cdev) { if (pos->tz == tz && pos->trip == trip && pos->cdev == cdev) {
...@@ -82,7 +82,7 @@ EXPORT_SYMBOL(get_thermal_instance); ...@@ -82,7 +82,7 @@ EXPORT_SYMBOL(get_thermal_instance);
*/ */
int __thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp) int __thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
{ {
const struct thermal_trip *trip; const struct thermal_trip_desc *td;
int crit_temp = INT_MAX; int crit_temp = INT_MAX;
int ret = -EINVAL; int ret = -EINVAL;
...@@ -91,7 +91,9 @@ int __thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp) ...@@ -91,7 +91,9 @@ int __thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
ret = tz->ops.get_temp(tz, temp); ret = tz->ops.get_temp(tz, temp);
if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) { if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) {
for_each_trip(tz, trip) { for_each_trip_desc(tz, td) {
const struct thermal_trip *trip = &td->trip;
if (trip->type == THERMAL_TRIP_CRITICAL) { if (trip->type == THERMAL_TRIP_CRITICAL) {
crit_temp = trip->temperature; crit_temp = trip->temperature;
break; break;
......
...@@ -445,7 +445,7 @@ static int thermal_genl_cmd_tz_get_id(struct param *p) ...@@ -445,7 +445,7 @@ static int thermal_genl_cmd_tz_get_id(struct param *p)
static int thermal_genl_cmd_tz_get_trip(struct param *p) static int thermal_genl_cmd_tz_get_trip(struct param *p)
{ {
struct sk_buff *msg = p->msg; struct sk_buff *msg = p->msg;
const struct thermal_trip *trip; const struct thermal_trip_desc *td;
struct thermal_zone_device *tz; struct thermal_zone_device *tz;
struct nlattr *start_trip; struct nlattr *start_trip;
int id; int id;
...@@ -465,7 +465,9 @@ static int thermal_genl_cmd_tz_get_trip(struct param *p) ...@@ -465,7 +465,9 @@ static int thermal_genl_cmd_tz_get_trip(struct param *p)
mutex_lock(&tz->lock); mutex_lock(&tz->lock);
for_each_trip(tz, trip) { for_each_trip_desc(tz, td) {
const struct thermal_trip *trip = &td->trip;
if (nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_ID, if (nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_ID,
thermal_zone_trip_id(tz, trip)) || thermal_zone_trip_id(tz, trip)) ||
nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TYPE, trip->type) || nla_put_u32(msg, THERMAL_GENL_ATTR_TZ_TRIP_TYPE, trip->type) ||
......
...@@ -88,7 +88,7 @@ trip_point_type_show(struct device *dev, struct device_attribute *attr, ...@@ -88,7 +88,7 @@ trip_point_type_show(struct device *dev, struct device_attribute *attr,
if (sscanf(attr->attr.name, "trip_point_%d_type", &trip_id) != 1) if (sscanf(attr->attr.name, "trip_point_%d_type", &trip_id) != 1)
return -EINVAL; return -EINVAL;
switch (tz->trips[trip_id].type) { switch (tz->trips[trip_id].trip.type) {
case THERMAL_TRIP_CRITICAL: case THERMAL_TRIP_CRITICAL:
return sprintf(buf, "critical\n"); return sprintf(buf, "critical\n");
case THERMAL_TRIP_HOT: case THERMAL_TRIP_HOT:
...@@ -120,7 +120,7 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr, ...@@ -120,7 +120,7 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
mutex_lock(&tz->lock); mutex_lock(&tz->lock);
trip = &tz->trips[trip_id]; trip = &tz->trips[trip_id].trip;
if (temp != trip->temperature) { if (temp != trip->temperature) {
if (tz->ops.set_trip_temp) { if (tz->ops.set_trip_temp) {
...@@ -150,7 +150,7 @@ trip_point_temp_show(struct device *dev, struct device_attribute *attr, ...@@ -150,7 +150,7 @@ trip_point_temp_show(struct device *dev, struct device_attribute *attr,
if (sscanf(attr->attr.name, "trip_point_%d_temp", &trip_id) != 1) if (sscanf(attr->attr.name, "trip_point_%d_temp", &trip_id) != 1)
return -EINVAL; return -EINVAL;
return sprintf(buf, "%d\n", tz->trips[trip_id].temperature); return sprintf(buf, "%d\n", tz->trips[trip_id].trip.temperature);
} }
static ssize_t static ssize_t
...@@ -171,7 +171,7 @@ trip_point_hyst_store(struct device *dev, struct device_attribute *attr, ...@@ -171,7 +171,7 @@ trip_point_hyst_store(struct device *dev, struct device_attribute *attr,
mutex_lock(&tz->lock); mutex_lock(&tz->lock);
trip = &tz->trips[trip_id]; trip = &tz->trips[trip_id].trip;
if (hyst != trip->hysteresis) { if (hyst != trip->hysteresis) {
trip->hysteresis = hyst; trip->hysteresis = hyst;
...@@ -194,7 +194,7 @@ trip_point_hyst_show(struct device *dev, struct device_attribute *attr, ...@@ -194,7 +194,7 @@ trip_point_hyst_show(struct device *dev, struct device_attribute *attr,
if (sscanf(attr->attr.name, "trip_point_%d_hyst", &trip_id) != 1) if (sscanf(attr->attr.name, "trip_point_%d_hyst", &trip_id) != 1)
return -EINVAL; return -EINVAL;
return sprintf(buf, "%d\n", tz->trips[trip_id].hysteresis); return sprintf(buf, "%d\n", tz->trips[trip_id].trip.hysteresis);
} }
static ssize_t static ssize_t
...@@ -393,7 +393,7 @@ static const struct attribute_group *thermal_zone_attribute_groups[] = { ...@@ -393,7 +393,7 @@ static const struct attribute_group *thermal_zone_attribute_groups[] = {
*/ */
static int create_trip_attrs(struct thermal_zone_device *tz) static int create_trip_attrs(struct thermal_zone_device *tz)
{ {
const struct thermal_trip *trip; const struct thermal_trip_desc *td;
struct attribute **attrs; struct attribute **attrs;
/* This function works only for zones with at least one trip */ /* This function works only for zones with at least one trip */
...@@ -429,8 +429,8 @@ static int create_trip_attrs(struct thermal_zone_device *tz) ...@@ -429,8 +429,8 @@ static int create_trip_attrs(struct thermal_zone_device *tz)
return -ENOMEM; return -ENOMEM;
} }
for_each_trip(tz, trip) { for_each_trip_desc(tz, td) {
int indx = thermal_zone_trip_id(tz, trip); int indx = thermal_zone_trip_id(tz, &td->trip);
/* create trip type attribute */ /* create trip type attribute */
snprintf(tz->trip_type_attrs[indx].name, THERMAL_NAME_LENGTH, snprintf(tz->trip_type_attrs[indx].name, THERMAL_NAME_LENGTH,
...@@ -452,7 +452,7 @@ static int create_trip_attrs(struct thermal_zone_device *tz) ...@@ -452,7 +452,7 @@ static int create_trip_attrs(struct thermal_zone_device *tz)
tz->trip_temp_attrs[indx].name; tz->trip_temp_attrs[indx].name;
tz->trip_temp_attrs[indx].attr.attr.mode = S_IRUGO; tz->trip_temp_attrs[indx].attr.attr.mode = S_IRUGO;
tz->trip_temp_attrs[indx].attr.show = trip_point_temp_show; tz->trip_temp_attrs[indx].attr.show = trip_point_temp_show;
if (trip->flags & THERMAL_TRIP_FLAG_RW_TEMP) { if (td->trip.flags & THERMAL_TRIP_FLAG_RW_TEMP) {
tz->trip_temp_attrs[indx].attr.attr.mode |= S_IWUSR; tz->trip_temp_attrs[indx].attr.attr.mode |= S_IWUSR;
tz->trip_temp_attrs[indx].attr.store = tz->trip_temp_attrs[indx].attr.store =
trip_point_temp_store; trip_point_temp_store;
...@@ -467,7 +467,7 @@ static int create_trip_attrs(struct thermal_zone_device *tz) ...@@ -467,7 +467,7 @@ static int create_trip_attrs(struct thermal_zone_device *tz)
tz->trip_hyst_attrs[indx].name; tz->trip_hyst_attrs[indx].name;
tz->trip_hyst_attrs[indx].attr.attr.mode = S_IRUGO; tz->trip_hyst_attrs[indx].attr.attr.mode = S_IRUGO;
tz->trip_hyst_attrs[indx].attr.show = trip_point_hyst_show; tz->trip_hyst_attrs[indx].attr.show = trip_point_hyst_show;
if (trip->flags & THERMAL_TRIP_FLAG_RW_HYST) { if (td->trip.flags & THERMAL_TRIP_FLAG_RW_HYST) {
tz->trip_hyst_attrs[indx].attr.attr.mode |= S_IWUSR; tz->trip_hyst_attrs[indx].attr.attr.mode |= S_IWUSR;
tz->trip_hyst_attrs[indx].attr.store = tz->trip_hyst_attrs[indx].attr.store =
trip_point_hyst_store; trip_point_hyst_store;
......
...@@ -13,11 +13,11 @@ int for_each_thermal_trip(struct thermal_zone_device *tz, ...@@ -13,11 +13,11 @@ int for_each_thermal_trip(struct thermal_zone_device *tz,
int (*cb)(struct thermal_trip *, void *), int (*cb)(struct thermal_trip *, void *),
void *data) void *data)
{ {
struct thermal_trip *trip; struct thermal_trip_desc *td;
int ret; int ret;
for_each_trip(tz, trip) { for_each_trip_desc(tz, td) {
ret = cb(trip, data); ret = cb(&td->trip, data);
if (ret) if (ret)
return ret; return ret;
} }
...@@ -63,7 +63,7 @@ EXPORT_SYMBOL_GPL(thermal_zone_get_num_trips); ...@@ -63,7 +63,7 @@ EXPORT_SYMBOL_GPL(thermal_zone_get_num_trips);
*/ */
void __thermal_zone_set_trips(struct thermal_zone_device *tz) void __thermal_zone_set_trips(struct thermal_zone_device *tz)
{ {
const struct thermal_trip *trip; const struct thermal_trip_desc *td;
int low = -INT_MAX, high = INT_MAX; int low = -INT_MAX, high = INT_MAX;
int ret; int ret;
...@@ -72,7 +72,8 @@ void __thermal_zone_set_trips(struct thermal_zone_device *tz) ...@@ -72,7 +72,8 @@ void __thermal_zone_set_trips(struct thermal_zone_device *tz)
if (!tz->ops.set_trips) if (!tz->ops.set_trips)
return; return;
for_each_trip(tz, trip) { for_each_trip_desc(tz, td) {
const struct thermal_trip *trip = &td->trip;
int trip_low; int trip_low;
trip_low = trip->temperature - trip->hysteresis; trip_low = trip->temperature - trip->hysteresis;
...@@ -110,7 +111,7 @@ int __thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id, ...@@ -110,7 +111,7 @@ int __thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id,
if (!tz || trip_id < 0 || trip_id >= tz->num_trips || !trip) if (!tz || trip_id < 0 || trip_id >= tz->num_trips || !trip)
return -EINVAL; return -EINVAL;
*trip = tz->trips[trip_id]; *trip = tz->trips[trip_id].trip;
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(__thermal_zone_get_trip); EXPORT_SYMBOL_GPL(__thermal_zone_get_trip);
...@@ -135,7 +136,7 @@ int thermal_zone_trip_id(const struct thermal_zone_device *tz, ...@@ -135,7 +136,7 @@ int thermal_zone_trip_id(const struct thermal_zone_device *tz,
* Assume the trip to be located within the bounds of the thermal * Assume the trip to be located within the bounds of the thermal
* zone's trips[] table. * zone's trips[] table.
*/ */
return trip - tz->trips; return trip_to_trip_desc(trip) - tz->trips;
} }
void thermal_zone_trip_updated(struct thermal_zone_device *tz, void thermal_zone_trip_updated(struct thermal_zone_device *tz,
const struct thermal_trip *trip) const struct thermal_trip *trip)
......
...@@ -61,7 +61,6 @@ enum thermal_notify_event { ...@@ -61,7 +61,6 @@ enum thermal_notify_event {
* struct thermal_trip - representation of a point in temperature domain * struct thermal_trip - representation of a point in temperature domain
* @temperature: temperature value in miliCelsius * @temperature: temperature value in miliCelsius
* @hysteresis: relative hysteresis in miliCelsius * @hysteresis: relative hysteresis in miliCelsius
* @threshold: trip crossing notification threshold miliCelsius
* @type: trip point type * @type: trip point type
* @priv: pointer to driver data associated with this trip * @priv: pointer to driver data associated with this trip
* @flags: flags representing binary properties of the trip * @flags: flags representing binary properties of the trip
...@@ -69,12 +68,16 @@ enum thermal_notify_event { ...@@ -69,12 +68,16 @@ enum thermal_notify_event {
struct thermal_trip { struct thermal_trip {
int temperature; int temperature;
int hysteresis; int hysteresis;
int threshold;
enum thermal_trip_type type; enum thermal_trip_type type;
u8 flags; u8 flags;
void *priv; void *priv;
}; };
struct thermal_trip_desc {
struct thermal_trip trip;
int threshold;
};
#define THERMAL_TRIP_FLAG_RW_TEMP BIT(0) #define THERMAL_TRIP_FLAG_RW_TEMP BIT(0)
#define THERMAL_TRIP_FLAG_RW_HYST BIT(1) #define THERMAL_TRIP_FLAG_RW_HYST BIT(1)
...@@ -203,7 +206,7 @@ struct thermal_zone_device { ...@@ -203,7 +206,7 @@ struct thermal_zone_device {
#ifdef CONFIG_THERMAL_DEBUGFS #ifdef CONFIG_THERMAL_DEBUGFS
struct thermal_debugfs *debugfs; struct thermal_debugfs *debugfs;
#endif #endif
struct thermal_trip trips[] __counted_by(num_trips); struct thermal_trip_desc trips[] __counted_by(num_trips);
}; };
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment