mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
thermal: core: Rework .get_trend() thermal zone callback
Passing a struct thermal_trip pointer instead of a trip index to the .get_trend() thermal zone callback allows one of its 2 implementations, the thermal_get_trend() function in the ACPI thermal driver, to be simplified quite a bit, and the other implementation of it in the ti-soc-thermal driver does not even use the relevant callback argument. For this reason, change the .get_trend() thermal zone callback definition and adjust the related code accordingly. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
35d8dbbb25
commit
8289d810ea
5 changed files with 38 additions and 41 deletions
|
@ -492,26 +492,22 @@ static int thermal_get_temp(struct thermal_zone_device *thermal, int *temp)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int thermal_get_trend(struct thermal_zone_device *thermal,
|
static int thermal_get_trend(struct thermal_zone_device *thermal,
|
||||||
int trip_index, enum thermal_trend *trend)
|
struct thermal_trip *trip,
|
||||||
|
enum thermal_trend *trend)
|
||||||
{
|
{
|
||||||
struct acpi_thermal *tz = thermal_zone_device_priv(thermal);
|
struct acpi_thermal *tz = thermal_zone_device_priv(thermal);
|
||||||
struct acpi_thermal_trip *acpi_trip;
|
struct acpi_thermal_trip *acpi_trip;
|
||||||
int t, i;
|
int t;
|
||||||
|
|
||||||
if (!tz || trip_index < 0)
|
if (!tz || !trip)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (tz->trips.critical.valid)
|
acpi_trip = trip->priv;
|
||||||
trip_index--;
|
if (!acpi_trip || !acpi_trip->valid)
|
||||||
|
|
||||||
if (tz->trips.hot.valid)
|
|
||||||
trip_index--;
|
|
||||||
|
|
||||||
if (trip_index < 0)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
acpi_trip = &tz->trips.passive.trip;
|
switch (trip->type) {
|
||||||
if (acpi_trip->valid && !trip_index--) {
|
case THERMAL_TRIP_PASSIVE:
|
||||||
t = tz->trips.passive.tc1 * (tz->temperature -
|
t = tz->trips.passive.tc1 * (tz->temperature -
|
||||||
tz->last_temperature) +
|
tz->last_temperature) +
|
||||||
tz->trips.passive.tc2 * (tz->temperature -
|
tz->trips.passive.tc2 * (tz->temperature -
|
||||||
|
@ -524,19 +520,18 @@ static int thermal_get_trend(struct thermal_zone_device *thermal,
|
||||||
*trend = THERMAL_TREND_STABLE;
|
*trend = THERMAL_TREND_STABLE;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
t = acpi_thermal_temp(tz, tz->temperature);
|
case THERMAL_TRIP_ACTIVE:
|
||||||
|
t = acpi_thermal_temp(tz, tz->temperature);
|
||||||
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
|
if (t <= trip->temperature)
|
||||||
acpi_trip = &tz->trips.active[i].trip;
|
|
||||||
if (acpi_trip->valid && !trip_index--) {
|
|
||||||
if (t > acpi_thermal_temp(tz, acpi_trip->temperature)) {
|
|
||||||
*trend = THERMAL_TREND_RAISING;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
*trend = THERMAL_TREND_RAISING;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
|
@ -70,7 +70,7 @@ static inline bool cdev_is_power_actor(struct thermal_cooling_device *cdev)
|
||||||
void thermal_cdev_update(struct thermal_cooling_device *);
|
void thermal_cdev_update(struct thermal_cooling_device *);
|
||||||
void __thermal_cdev_update(struct thermal_cooling_device *cdev);
|
void __thermal_cdev_update(struct thermal_cooling_device *cdev);
|
||||||
|
|
||||||
int get_tz_trend(struct thermal_zone_device *tz, int trip);
|
int get_tz_trend(struct thermal_zone_device *tz, int trip_index);
|
||||||
|
|
||||||
struct thermal_instance *
|
struct thermal_instance *
|
||||||
get_thermal_instance(struct thermal_zone_device *tz,
|
get_thermal_instance(struct thermal_zone_device *tz,
|
||||||
|
|
|
@ -22,8 +22,9 @@
|
||||||
#include "thermal_core.h"
|
#include "thermal_core.h"
|
||||||
#include "thermal_trace.h"
|
#include "thermal_trace.h"
|
||||||
|
|
||||||
int get_tz_trend(struct thermal_zone_device *tz, int trip)
|
int get_tz_trend(struct thermal_zone_device *tz, int trip_index)
|
||||||
{
|
{
|
||||||
|
struct thermal_trip *trip = tz->trips ? &tz->trips[trip_index] : NULL;
|
||||||
enum thermal_trend trend;
|
enum thermal_trend trend;
|
||||||
|
|
||||||
if (tz->emul_temperature || !tz->ops->get_trend ||
|
if (tz->emul_temperature || !tz->ops->get_trend ||
|
||||||
|
|
|
@ -109,7 +109,8 @@ static inline int __ti_thermal_get_temp(struct thermal_zone_device *tz, int *tem
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __ti_thermal_get_trend(struct thermal_zone_device *tz, int trip, enum thermal_trend *trend)
|
static int __ti_thermal_get_trend(struct thermal_zone_device *tz,
|
||||||
|
struct thermal_trip *trip, enum thermal_trend *trend)
|
||||||
{
|
{
|
||||||
struct ti_thermal_data *data = thermal_zone_device_priv(tz);
|
struct ti_thermal_data *data = thermal_zone_device_priv(tz);
|
||||||
struct ti_bandgap *bgp;
|
struct ti_bandgap *bgp;
|
||||||
|
|
|
@ -53,6 +53,20 @@ enum thermal_notify_event {
|
||||||
THERMAL_EVENT_KEEP_ALIVE, /* Request for user space handler to respond */
|
THERMAL_EVENT_KEEP_ALIVE, /* Request for user space handler to respond */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct thermal_trip - representation of a point in temperature domain
|
||||||
|
* @temperature: temperature value in miliCelsius
|
||||||
|
* @hysteresis: relative hysteresis in miliCelsius
|
||||||
|
* @type: trip point type
|
||||||
|
* @priv: pointer to driver data associated with this trip
|
||||||
|
*/
|
||||||
|
struct thermal_trip {
|
||||||
|
int temperature;
|
||||||
|
int hysteresis;
|
||||||
|
enum thermal_trip_type type;
|
||||||
|
void *priv;
|
||||||
|
};
|
||||||
|
|
||||||
struct thermal_zone_device_ops {
|
struct thermal_zone_device_ops {
|
||||||
int (*bind) (struct thermal_zone_device *,
|
int (*bind) (struct thermal_zone_device *,
|
||||||
struct thermal_cooling_device *);
|
struct thermal_cooling_device *);
|
||||||
|
@ -66,26 +80,12 @@ struct thermal_zone_device_ops {
|
||||||
int (*set_trip_hyst) (struct thermal_zone_device *, int, int);
|
int (*set_trip_hyst) (struct thermal_zone_device *, int, int);
|
||||||
int (*get_crit_temp) (struct thermal_zone_device *, int *);
|
int (*get_crit_temp) (struct thermal_zone_device *, int *);
|
||||||
int (*set_emul_temp) (struct thermal_zone_device *, int);
|
int (*set_emul_temp) (struct thermal_zone_device *, int);
|
||||||
int (*get_trend) (struct thermal_zone_device *, int,
|
int (*get_trend) (struct thermal_zone_device *, struct thermal_trip *,
|
||||||
enum thermal_trend *);
|
enum thermal_trend *);
|
||||||
void (*hot)(struct thermal_zone_device *);
|
void (*hot)(struct thermal_zone_device *);
|
||||||
void (*critical)(struct thermal_zone_device *);
|
void (*critical)(struct thermal_zone_device *);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* struct thermal_trip - representation of a point in temperature domain
|
|
||||||
* @temperature: temperature value in miliCelsius
|
|
||||||
* @hysteresis: relative hysteresis in miliCelsius
|
|
||||||
* @type: trip point type
|
|
||||||
* @priv: pointer to driver data associated with this trip
|
|
||||||
*/
|
|
||||||
struct thermal_trip {
|
|
||||||
int temperature;
|
|
||||||
int hysteresis;
|
|
||||||
enum thermal_trip_type type;
|
|
||||||
void *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct thermal_cooling_device_ops {
|
struct thermal_cooling_device_ops {
|
||||||
int (*get_max_state) (struct thermal_cooling_device *, unsigned long *);
|
int (*get_max_state) (struct thermal_cooling_device *, unsigned long *);
|
||||||
int (*get_cur_state) (struct thermal_cooling_device *, unsigned long *);
|
int (*get_cur_state) (struct thermal_cooling_device *, unsigned long *);
|
||||||
|
|
Loading…
Add table
Reference in a new issue