Commit 166d017d authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

Merge thermal core changes for 6.9 to satisfy a dependency.

parents f1f0c445 32abd250
...@@ -228,7 +228,6 @@ CONFIG_SENSORS_IIO_HWMON=y ...@@ -228,7 +228,6 @@ CONFIG_SENSORS_IIO_HWMON=y
CONFIG_SENSORS_PWM_FAN=y CONFIG_SENSORS_PWM_FAN=y
CONFIG_SENSORS_SY7636A=y CONFIG_SENSORS_SY7636A=y
CONFIG_THERMAL_STATISTICS=y CONFIG_THERMAL_STATISTICS=y
CONFIG_THERMAL_WRITABLE_TRIPS=y
CONFIG_CPU_THERMAL=y CONFIG_CPU_THERMAL=y
CONFIG_IMX_THERMAL=y CONFIG_IMX_THERMAL=y
CONFIG_WATCHDOG=y CONFIG_WATCHDOG=y
......
...@@ -47,6 +47,8 @@ ...@@ -47,6 +47,8 @@
#define ACPI_THERMAL_TRIP_PASSIVE (-1) #define ACPI_THERMAL_TRIP_PASSIVE (-1)
#define ACPI_THERMAL_MAX_NR_TRIPS (ACPI_THERMAL_MAX_ACTIVE + 3)
/* /*
* This exception is thrown out in two cases: * This exception is thrown out in two cases:
* 1.An invalid trip point becomes invalid or a valid trip point becomes invalid * 1.An invalid trip point becomes invalid or a valid trip point becomes invalid
...@@ -112,7 +114,6 @@ struct acpi_thermal { ...@@ -112,7 +114,6 @@ struct acpi_thermal {
unsigned long polling_frequency; unsigned long polling_frequency;
volatile u8 zombie; volatile u8 zombie;
struct acpi_thermal_trips trips; struct acpi_thermal_trips trips;
struct thermal_trip *trip_table;
struct thermal_zone_device *thermal_zone; struct thermal_zone_device *thermal_zone;
int kelvin_offset; /* in millidegrees */ int kelvin_offset; /* in millidegrees */
struct work_struct thermal_check_work; struct work_struct thermal_check_work;
...@@ -451,26 +452,19 @@ static bool acpi_thermal_init_trip(struct acpi_thermal *tz, int index) ...@@ -451,26 +452,19 @@ static bool acpi_thermal_init_trip(struct acpi_thermal *tz, int index)
return false; return false;
} }
static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) static void acpi_thermal_get_trip_points(struct acpi_thermal *tz)
{ {
unsigned int count = 0;
int i; int i;
if (acpi_thermal_init_trip(tz, ACPI_THERMAL_TRIP_PASSIVE)) acpi_thermal_init_trip(tz, ACPI_THERMAL_TRIP_PASSIVE);
count++;
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
if (acpi_thermal_init_trip(tz, i)) if (!acpi_thermal_init_trip(tz, i))
count++;
else
break; break;
} }
while (++i < ACPI_THERMAL_MAX_ACTIVE) while (++i < ACPI_THERMAL_MAX_ACTIVE)
tz->trips.active[i].trip.temp_dk = THERMAL_TEMP_INVALID; tz->trips.active[i].trip.temp_dk = THERMAL_TEMP_INVALID;
return count;
} }
/* sys I/F for generic thermal sysfs support */ /* sys I/F for generic thermal sysfs support */
...@@ -626,7 +620,7 @@ acpi_thermal_unbind_cooling_device(struct thermal_zone_device *thermal, ...@@ -626,7 +620,7 @@ acpi_thermal_unbind_cooling_device(struct thermal_zone_device *thermal,
return acpi_thermal_bind_unbind_cdev(thermal, cdev, false); return acpi_thermal_bind_unbind_cdev(thermal, cdev, false);
} }
static struct thermal_zone_device_ops acpi_thermal_zone_ops = { static const struct thermal_zone_device_ops acpi_thermal_zone_ops = {
.bind = acpi_thermal_bind_cooling_device, .bind = acpi_thermal_bind_cooling_device,
.unbind = acpi_thermal_unbind_cooling_device, .unbind = acpi_thermal_unbind_cooling_device,
.get_temp = thermal_get_temp, .get_temp = thermal_get_temp,
...@@ -662,15 +656,16 @@ static void acpi_thermal_zone_sysfs_remove(struct acpi_thermal *tz) ...@@ -662,15 +656,16 @@ static void acpi_thermal_zone_sysfs_remove(struct acpi_thermal *tz)
} }
static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz, static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz,
const struct thermal_trip *trip_table,
unsigned int trip_count, unsigned int trip_count,
int passive_delay) int passive_delay)
{ {
int result; int result;
tz->thermal_zone = thermal_zone_device_register_with_trips("acpitz", tz->thermal_zone = thermal_zone_device_register_with_trips("acpitz",
tz->trip_table, trip_table,
trip_count, trip_count,
0, tz, tz,
&acpi_thermal_zone_ops, &acpi_thermal_zone_ops,
NULL, NULL,
passive_delay, passive_delay,
...@@ -823,10 +818,10 @@ static void acpi_thermal_free_thermal_zone(struct acpi_thermal *tz) ...@@ -823,10 +818,10 @@ static void acpi_thermal_free_thermal_zone(struct acpi_thermal *tz)
static int acpi_thermal_add(struct acpi_device *device) static int acpi_thermal_add(struct acpi_device *device)
{ {
struct thermal_trip trip_table[ACPI_THERMAL_MAX_NR_TRIPS] = { 0 };
struct acpi_thermal_trip *acpi_trip; struct acpi_thermal_trip *acpi_trip;
struct thermal_trip *trip; struct thermal_trip *trip;
struct acpi_thermal *tz; struct acpi_thermal *tz;
unsigned int trip_count;
int crit_temp, hot_temp; int crit_temp, hot_temp;
int passive_delay = 0; int passive_delay = 0;
int result; int result;
...@@ -848,21 +843,10 @@ static int acpi_thermal_add(struct acpi_device *device) ...@@ -848,21 +843,10 @@ static int acpi_thermal_add(struct acpi_device *device)
acpi_thermal_aml_dependency_fix(tz); acpi_thermal_aml_dependency_fix(tz);
/* Get trip points [_CRT, _PSV, etc.] (required). */ /* Get trip points [_CRT, _PSV, etc.] (required). */
trip_count = acpi_thermal_get_trip_points(tz); acpi_thermal_get_trip_points(tz);
crit_temp = acpi_thermal_get_critical_trip(tz); crit_temp = acpi_thermal_get_critical_trip(tz);
if (crit_temp != THERMAL_TEMP_INVALID)
trip_count++;
hot_temp = acpi_thermal_get_hot_trip(tz); hot_temp = acpi_thermal_get_hot_trip(tz);
if (hot_temp != THERMAL_TEMP_INVALID)
trip_count++;
if (!trip_count) {
pr_warn(FW_BUG "No valid trip points!\n");
result = -ENODEV;
goto free_memory;
}
/* Get temperature [_TMP] (required). */ /* Get temperature [_TMP] (required). */
result = acpi_thermal_get_temperature(tz); result = acpi_thermal_get_temperature(tz);
...@@ -881,13 +865,7 @@ static int acpi_thermal_add(struct acpi_device *device) ...@@ -881,13 +865,7 @@ static int acpi_thermal_add(struct acpi_device *device)
acpi_thermal_guess_offset(tz, crit_temp); acpi_thermal_guess_offset(tz, crit_temp);
trip = kcalloc(trip_count, sizeof(*trip), GFP_KERNEL); trip = trip_table;
if (!trip) {
result = -ENOMEM;
goto free_memory;
}
tz->trip_table = trip;
if (crit_temp != THERMAL_TEMP_INVALID) { if (crit_temp != THERMAL_TEMP_INVALID) {
trip->type = THERMAL_TRIP_CRITICAL; trip->type = THERMAL_TRIP_CRITICAL;
...@@ -923,9 +901,17 @@ static int acpi_thermal_add(struct acpi_device *device) ...@@ -923,9 +901,17 @@ static int acpi_thermal_add(struct acpi_device *device)
trip++; trip++;
} }
result = acpi_thermal_register_thermal_zone(tz, trip_count, passive_delay); if (trip == trip_table) {
pr_warn(FW_BUG "No valid trip points!\n");
result = -ENODEV;
goto free_memory;
}
result = acpi_thermal_register_thermal_zone(tz, trip_table,
trip - trip_table,
passive_delay);
if (result) if (result)
goto free_trips; goto free_memory;
refcount_set(&tz->thermal_check_count, 3); refcount_set(&tz->thermal_check_count, 3);
mutex_init(&tz->thermal_check_lock); mutex_init(&tz->thermal_check_lock);
...@@ -944,8 +930,6 @@ static int acpi_thermal_add(struct acpi_device *device) ...@@ -944,8 +930,6 @@ static int acpi_thermal_add(struct acpi_device *device)
flush_wq: flush_wq:
flush_workqueue(acpi_thermal_pm_queue); flush_workqueue(acpi_thermal_pm_queue);
acpi_thermal_unregister_thermal_zone(tz); acpi_thermal_unregister_thermal_zone(tz);
free_trips:
kfree(tz->trip_table);
free_memory: free_memory:
acpi_thermal_free_thermal_zone(tz); acpi_thermal_free_thermal_zone(tz);
...@@ -966,7 +950,6 @@ static void acpi_thermal_remove(struct acpi_device *device) ...@@ -966,7 +950,6 @@ static void acpi_thermal_remove(struct acpi_device *device)
flush_workqueue(acpi_thermal_pm_queue); flush_workqueue(acpi_thermal_pm_queue);
acpi_thermal_unregister_thermal_zone(tz); acpi_thermal_unregister_thermal_zone(tz);
kfree(tz->trip_table);
acpi_thermal_free_thermal_zone(tz); acpi_thermal_free_thermal_zone(tz);
} }
......
...@@ -60,7 +60,7 @@ int cxgb4_thermal_init(struct adapter *adap) ...@@ -60,7 +60,7 @@ int cxgb4_thermal_init(struct adapter *adap)
snprintf(ch_tz_name, sizeof(ch_tz_name), "cxgb4_%s", adap->name); snprintf(ch_tz_name, sizeof(ch_tz_name), "cxgb4_%s", adap->name);
ch_thermal->tzdev = thermal_zone_device_register_with_trips(ch_tz_name, &trip, num_trip, ch_thermal->tzdev = thermal_zone_device_register_with_trips(ch_tz_name, &trip, num_trip,
0, adap, adap,
&cxgb4_thermal_ops, &cxgb4_thermal_ops,
NULL, 0, 0); NULL, 0, 0);
if (IS_ERR(ch_thermal->tzdev)) { if (IS_ERR(ch_thermal->tzdev)) {
......
...@@ -44,16 +44,19 @@ static const struct thermal_trip default_thermal_trips[] = { ...@@ -44,16 +44,19 @@ static const struct thermal_trip default_thermal_trips[] = {
.type = THERMAL_TRIP_ACTIVE, .type = THERMAL_TRIP_ACTIVE,
.temperature = MLXSW_THERMAL_ASIC_TEMP_NORM, .temperature = MLXSW_THERMAL_ASIC_TEMP_NORM,
.hysteresis = MLXSW_THERMAL_HYSTERESIS_TEMP, .hysteresis = MLXSW_THERMAL_HYSTERESIS_TEMP,
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
}, },
{ {
/* In range - 40-100% PWM */ /* In range - 40-100% PWM */
.type = THERMAL_TRIP_ACTIVE, .type = THERMAL_TRIP_ACTIVE,
.temperature = MLXSW_THERMAL_ASIC_TEMP_HIGH, .temperature = MLXSW_THERMAL_ASIC_TEMP_HIGH,
.hysteresis = MLXSW_THERMAL_HYSTERESIS_TEMP, .hysteresis = MLXSW_THERMAL_HYSTERESIS_TEMP,
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
}, },
{ /* Warning */ { /* Warning */
.type = THERMAL_TRIP_HOT, .type = THERMAL_TRIP_HOT,
.temperature = MLXSW_THERMAL_ASIC_TEMP_HOT, .temperature = MLXSW_THERMAL_ASIC_TEMP_HOT,
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
}, },
}; };
...@@ -62,16 +65,19 @@ static const struct thermal_trip default_thermal_module_trips[] = { ...@@ -62,16 +65,19 @@ static const struct thermal_trip default_thermal_module_trips[] = {
.type = THERMAL_TRIP_ACTIVE, .type = THERMAL_TRIP_ACTIVE,
.temperature = MLXSW_THERMAL_MODULE_TEMP_NORM, .temperature = MLXSW_THERMAL_MODULE_TEMP_NORM,
.hysteresis = MLXSW_THERMAL_HYSTERESIS_TEMP, .hysteresis = MLXSW_THERMAL_HYSTERESIS_TEMP,
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
}, },
{ {
/* In range - 40-100% PWM */ /* In range - 40-100% PWM */
.type = THERMAL_TRIP_ACTIVE, .type = THERMAL_TRIP_ACTIVE,
.temperature = MLXSW_THERMAL_MODULE_TEMP_HIGH, .temperature = MLXSW_THERMAL_MODULE_TEMP_HIGH,
.hysteresis = MLXSW_THERMAL_HYSTERESIS_TEMP, .hysteresis = MLXSW_THERMAL_HYSTERESIS_TEMP,
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
}, },
{ /* Warning */ { /* Warning */
.type = THERMAL_TRIP_HOT, .type = THERMAL_TRIP_HOT,
.temperature = MLXSW_THERMAL_MODULE_TEMP_HOT, .temperature = MLXSW_THERMAL_MODULE_TEMP_HOT,
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
}, },
}; };
...@@ -92,9 +98,6 @@ static const struct mlxsw_cooling_states default_cooling_states[] = { ...@@ -92,9 +98,6 @@ static const struct mlxsw_cooling_states default_cooling_states[] = {
#define MLXSW_THERMAL_NUM_TRIPS ARRAY_SIZE(default_thermal_trips) #define MLXSW_THERMAL_NUM_TRIPS ARRAY_SIZE(default_thermal_trips)
/* Make sure all trips are writable */
#define MLXSW_THERMAL_TRIP_MASK (BIT(MLXSW_THERMAL_NUM_TRIPS) - 1)
struct mlxsw_thermal; struct mlxsw_thermal;
struct mlxsw_thermal_module { struct mlxsw_thermal_module {
...@@ -420,7 +423,6 @@ mlxsw_thermal_module_tz_init(struct mlxsw_thermal_module *module_tz) ...@@ -420,7 +423,6 @@ mlxsw_thermal_module_tz_init(struct mlxsw_thermal_module *module_tz)
module_tz->tzdev = thermal_zone_device_register_with_trips(tz_name, module_tz->tzdev = thermal_zone_device_register_with_trips(tz_name,
module_tz->trips, module_tz->trips,
MLXSW_THERMAL_NUM_TRIPS, MLXSW_THERMAL_NUM_TRIPS,
MLXSW_THERMAL_TRIP_MASK,
module_tz, module_tz,
&mlxsw_thermal_module_ops, &mlxsw_thermal_module_ops,
&mlxsw_thermal_params, &mlxsw_thermal_params,
...@@ -548,7 +550,6 @@ mlxsw_thermal_gearbox_tz_init(struct mlxsw_thermal_module *gearbox_tz) ...@@ -548,7 +550,6 @@ mlxsw_thermal_gearbox_tz_init(struct mlxsw_thermal_module *gearbox_tz)
gearbox_tz->tzdev = thermal_zone_device_register_with_trips(tz_name, gearbox_tz->tzdev = thermal_zone_device_register_with_trips(tz_name,
gearbox_tz->trips, gearbox_tz->trips,
MLXSW_THERMAL_NUM_TRIPS, MLXSW_THERMAL_NUM_TRIPS,
MLXSW_THERMAL_TRIP_MASK,
gearbox_tz, gearbox_tz,
&mlxsw_thermal_gearbox_ops, &mlxsw_thermal_gearbox_ops,
&mlxsw_thermal_params, 0, &mlxsw_thermal_params, 0,
...@@ -773,7 +774,6 @@ int mlxsw_thermal_init(struct mlxsw_core *core, ...@@ -773,7 +774,6 @@ int mlxsw_thermal_init(struct mlxsw_core *core,
thermal->tzdev = thermal_zone_device_register_with_trips("mlxsw", thermal->tzdev = thermal_zone_device_register_with_trips("mlxsw",
thermal->trips, thermal->trips,
MLXSW_THERMAL_NUM_TRIPS, MLXSW_THERMAL_NUM_TRIPS,
MLXSW_THERMAL_TRIP_MASK,
thermal, thermal,
&mlxsw_thermal_ops, &mlxsw_thermal_ops,
&mlxsw_thermal_params, 0, &mlxsw_thermal_params, 0,
......
...@@ -667,9 +667,6 @@ static struct thermal_zone_device_ops tzone_ops = { ...@@ -667,9 +667,6 @@ static struct thermal_zone_device_ops tzone_ops = {
.set_trip_temp = iwl_mvm_tzone_set_trip_temp, .set_trip_temp = iwl_mvm_tzone_set_trip_temp,
}; };
/* make all trips writable */
#define IWL_WRITABLE_TRIPS_MSK (BIT(IWL_MAX_DTS_TRIPS) - 1)
static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm) static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
{ {
int i, ret; int i, ret;
...@@ -692,11 +689,11 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm) ...@@ -692,11 +689,11 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
for (i = 0 ; i < IWL_MAX_DTS_TRIPS; i++) { for (i = 0 ; i < IWL_MAX_DTS_TRIPS; i++) {
mvm->tz_device.trips[i].temperature = THERMAL_TEMP_INVALID; mvm->tz_device.trips[i].temperature = THERMAL_TEMP_INVALID;
mvm->tz_device.trips[i].type = THERMAL_TRIP_PASSIVE; mvm->tz_device.trips[i].type = THERMAL_TRIP_PASSIVE;
mvm->tz_device.trips[i].flags = THERMAL_TRIP_FLAG_RW_TEMP;
} }
mvm->tz_device.tzone = thermal_zone_device_register_with_trips(name, mvm->tz_device.tzone = thermal_zone_device_register_with_trips(name,
mvm->tz_device.trips, mvm->tz_device.trips,
IWL_MAX_DTS_TRIPS, IWL_MAX_DTS_TRIPS,
IWL_WRITABLE_TRIPS_MSK,
mvm, &tzone_ops, mvm, &tzone_ops,
NULL, 0, 0); NULL, 0, 0);
if (IS_ERR(mvm->tz_device.tzone)) { if (IS_ERR(mvm->tz_device.tzone)) {
......
...@@ -678,7 +678,7 @@ static int __init acerhdf_register_thermal(void) ...@@ -678,7 +678,7 @@ static int __init acerhdf_register_thermal(void)
return -EINVAL; return -EINVAL;
thz_dev = thermal_zone_device_register_with_trips("acerhdf", trips, ARRAY_SIZE(trips), thz_dev = thermal_zone_device_register_with_trips("acerhdf", trips, ARRAY_SIZE(trips),
0, NULL, &acerhdf_dev_ops, NULL, &acerhdf_dev_ops,
&acerhdf_zone_params, 0, &acerhdf_zone_params, 0,
(kernelmode) ? interval*1000 : 0); (kernelmode) ? interval*1000 : 0);
if (IS_ERR(thz_dev)) if (IS_ERR(thz_dev))
......
...@@ -83,17 +83,6 @@ config THERMAL_OF ...@@ -83,17 +83,6 @@ config THERMAL_OF
Say 'Y' here if you need to build thermal infrastructure Say 'Y' here if you need to build thermal infrastructure
based on device tree. based on device tree.
config THERMAL_WRITABLE_TRIPS
bool "Enable writable trip points"
help
This option allows the system integrator to choose whether
trip temperatures can be changed from userspace. The
writable trips need to be specified when setting up the
thermal zone but the choice here takes precedence.
Say 'Y' here if you would like to allow userspace tools to
change trip temperatures.
choice choice
prompt "Default Thermal governor" prompt "Default Thermal governor"
default THERMAL_DEFAULT_GOV_STEP_WISE default THERMAL_DEFAULT_GOV_STEP_WISE
......
...@@ -197,7 +197,7 @@ static int da9062_thermal_probe(struct platform_device *pdev) ...@@ -197,7 +197,7 @@ static int da9062_thermal_probe(struct platform_device *pdev)
mutex_init(&thermal->lock); mutex_init(&thermal->lock);
thermal->zone = thermal_zone_device_register_with_trips(thermal->config->name, thermal->zone = thermal_zone_device_register_with_trips(thermal->config->name,
trips, ARRAY_SIZE(trips), 0, thermal, trips, ARRAY_SIZE(trips), thermal,
&da9062_thermal_ops, NULL, pp_tmp, &da9062_thermal_ops, NULL, pp_tmp,
0); 0);
if (IS_ERR(thermal->zone)) { if (IS_ERR(thermal->zone)) {
......
...@@ -115,7 +115,8 @@ struct thermal_soc_data { ...@@ -115,7 +115,8 @@ struct thermal_soc_data {
}; };
static struct thermal_trip trips[] = { static struct thermal_trip trips[] = {
[IMX_TRIP_PASSIVE] = { .type = THERMAL_TRIP_PASSIVE }, [IMX_TRIP_PASSIVE] = { .type = THERMAL_TRIP_PASSIVE,
.flags = THERMAL_TRIP_FLAG_RW_TEMP },
[IMX_TRIP_CRITICAL] = { .type = THERMAL_TRIP_CRITICAL }, [IMX_TRIP_CRITICAL] = { .type = THERMAL_TRIP_CRITICAL },
}; };
...@@ -354,6 +355,7 @@ static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip_id, ...@@ -354,6 +355,7 @@ static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip_id,
return -EINVAL; return -EINVAL;
imx_set_alarm_temp(data, temp); imx_set_alarm_temp(data, temp);
trips[IMX_TRIP_PASSIVE].temperature = temp;
pm_runtime_put(data->dev); pm_runtime_put(data->dev);
...@@ -699,7 +701,7 @@ static int imx_thermal_probe(struct platform_device *pdev) ...@@ -699,7 +701,7 @@ static int imx_thermal_probe(struct platform_device *pdev)
data->tz = thermal_zone_device_register_with_trips("imx_thermal_zone", data->tz = thermal_zone_device_register_with_trips("imx_thermal_zone",
trips, trips,
ARRAY_SIZE(trips), ARRAY_SIZE(trips),
BIT(IMX_TRIP_PASSIVE), data, data,
&imx_tz_ops, NULL, &imx_tz_ops, NULL,
IMX_PASSIVE_DELAY, IMX_PASSIVE_DELAY,
IMX_POLLING_DELAY); IMX_POLLING_DELAY);
......
...@@ -23,7 +23,6 @@ config X86_PKG_TEMP_THERMAL ...@@ -23,7 +23,6 @@ config X86_PKG_TEMP_THERMAL
tristate "X86 package temperature thermal driver" tristate "X86 package temperature thermal driver"
depends on X86_THERMAL_VECTOR depends on X86_THERMAL_VECTOR
select THERMAL_GOV_USER_SPACE select THERMAL_GOV_USER_SPACE
select THERMAL_WRITABLE_TRIPS
select INTEL_TCC select INTEL_TCC
default m default m
help help
...@@ -47,7 +46,6 @@ config INTEL_SOC_DTS_THERMAL ...@@ -47,7 +46,6 @@ config INTEL_SOC_DTS_THERMAL
tristate "Intel SoCs DTS thermal driver" tristate "Intel SoCs DTS thermal driver"
depends on X86 && PCI && ACPI depends on X86 && PCI && ACPI
select INTEL_SOC_DTS_IOSF_CORE select INTEL_SOC_DTS_IOSF_CORE
select THERMAL_WRITABLE_TRIPS
help help
Enable this to register Intel SoCs (e.g. Bay Trail) platform digital Enable this to register Intel SoCs (e.g. Bay Trail) platform digital
temperature sensor (DTS). These SoCs have two additional DTSs in temperature sensor (DTS). These SoCs have two additional DTSs in
......
...@@ -61,12 +61,6 @@ static void int340x_thermal_critical(struct thermal_zone_device *zone) ...@@ -61,12 +61,6 @@ static void int340x_thermal_critical(struct thermal_zone_device *zone)
dev_dbg(&zone->device, "%s: critical temperature reached\n", zone->type); dev_dbg(&zone->device, "%s: critical temperature reached\n", zone->type);
} }
static struct thermal_zone_device_ops int340x_thermal_zone_ops = {
.get_temp = int340x_thermal_get_zone_temp,
.set_trip_temp = int340x_thermal_set_trip_temp,
.critical = int340x_thermal_critical,
};
static inline void *int_to_trip_priv(int i) static inline void *int_to_trip_priv(int i)
{ {
return (void *)(long)i; return (void *)(long)i;
...@@ -126,11 +120,15 @@ static struct thermal_zone_params int340x_thermal_params = { ...@@ -126,11 +120,15 @@ static struct thermal_zone_params int340x_thermal_params = {
struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev, struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev,
int (*get_temp) (struct thermal_zone_device *, int *)) int (*get_temp) (struct thermal_zone_device *, int *))
{ {
const struct thermal_zone_device_ops zone_ops = {
.set_trip_temp = int340x_thermal_set_trip_temp,
.critical = int340x_thermal_critical,
.get_temp = get_temp ? get_temp : int340x_thermal_get_zone_temp,
};
struct int34x_thermal_zone *int34x_zone; struct int34x_thermal_zone *int34x_zone;
struct thermal_trip *zone_trips; struct thermal_trip *zone_trips;
unsigned long long trip_cnt = 0; unsigned long long trip_cnt = 0;
unsigned long long hyst; unsigned long long hyst;
int trip_mask = 0;
acpi_status status; acpi_status status;
int i, ret; int i, ret;
...@@ -140,21 +138,9 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev, ...@@ -140,21 +138,9 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev,
int34x_zone->adev = adev; int34x_zone->adev = adev;
int34x_zone->ops = kmemdup(&int340x_thermal_zone_ops,
sizeof(int340x_thermal_zone_ops), GFP_KERNEL);
if (!int34x_zone->ops) {
ret = -ENOMEM;
goto err_ops_alloc;
}
if (get_temp)
int34x_zone->ops->get_temp = get_temp;
status = acpi_evaluate_integer(adev->handle, "PATC", NULL, &trip_cnt); status = acpi_evaluate_integer(adev->handle, "PATC", NULL, &trip_cnt);
if (ACPI_SUCCESS(status)) { if (ACPI_SUCCESS(status))
int34x_zone->aux_trip_nr = trip_cnt; int34x_zone->aux_trip_nr = trip_cnt;
trip_mask = BIT(trip_cnt) - 1;
}
zone_trips = kzalloc(sizeof(*zone_trips) * (trip_cnt + INT340X_THERMAL_MAX_TRIP_COUNT), zone_trips = kzalloc(sizeof(*zone_trips) * (trip_cnt + INT340X_THERMAL_MAX_TRIP_COUNT),
GFP_KERNEL); GFP_KERNEL);
...@@ -166,6 +152,7 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev, ...@@ -166,6 +152,7 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev,
for (i = 0; i < trip_cnt; i++) { for (i = 0; i < trip_cnt; i++) {
zone_trips[i].type = THERMAL_TRIP_PASSIVE; zone_trips[i].type = THERMAL_TRIP_PASSIVE;
zone_trips[i].temperature = THERMAL_TEMP_INVALID; zone_trips[i].temperature = THERMAL_TEMP_INVALID;
zone_trips[i].flags |= THERMAL_TRIP_FLAG_RW_TEMP;
} }
trip_cnt = int340x_thermal_read_trips(adev, zone_trips, trip_cnt); trip_cnt = int340x_thermal_read_trips(adev, zone_trips, trip_cnt);
...@@ -179,17 +166,17 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev, ...@@ -179,17 +166,17 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev,
for (i = 0; i < trip_cnt; ++i) for (i = 0; i < trip_cnt; ++i)
zone_trips[i].hysteresis = hyst; zone_trips[i].hysteresis = hyst;
int34x_zone->trips = zone_trips;
int34x_zone->lpat_table = acpi_lpat_get_conversion_table(adev->handle); int34x_zone->lpat_table = acpi_lpat_get_conversion_table(adev->handle);
int34x_zone->zone = thermal_zone_device_register_with_trips( int34x_zone->zone = thermal_zone_device_register_with_trips(
acpi_device_bid(adev), acpi_device_bid(adev),
zone_trips, trip_cnt, zone_trips, trip_cnt,
trip_mask, int34x_zone, int34x_zone,
int34x_zone->ops, &zone_ops,
&int340x_thermal_params, &int340x_thermal_params,
0, 0); 0, 0);
kfree(zone_trips);
if (IS_ERR(int34x_zone->zone)) { if (IS_ERR(int34x_zone->zone)) {
ret = PTR_ERR(int34x_zone->zone); ret = PTR_ERR(int34x_zone->zone);
goto err_thermal_zone; goto err_thermal_zone;
...@@ -203,11 +190,8 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev, ...@@ -203,11 +190,8 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev,
err_enable: err_enable:
thermal_zone_device_unregister(int34x_zone->zone); thermal_zone_device_unregister(int34x_zone->zone);
err_thermal_zone: err_thermal_zone:
kfree(int34x_zone->trips);
acpi_lpat_free_conversion_table(int34x_zone->lpat_table); acpi_lpat_free_conversion_table(int34x_zone->lpat_table);
err_trips_alloc: err_trips_alloc:
kfree(int34x_zone->ops);
err_ops_alloc:
kfree(int34x_zone); kfree(int34x_zone);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
...@@ -217,8 +201,6 @@ void int340x_thermal_zone_remove(struct int34x_thermal_zone *int34x_zone) ...@@ -217,8 +201,6 @@ void int340x_thermal_zone_remove(struct int34x_thermal_zone *int34x_zone)
{ {
thermal_zone_device_unregister(int34x_zone->zone); thermal_zone_device_unregister(int34x_zone->zone);
acpi_lpat_free_conversion_table(int34x_zone->lpat_table); acpi_lpat_free_conversion_table(int34x_zone->lpat_table);
kfree(int34x_zone->trips);
kfree(int34x_zone->ops);
kfree(int34x_zone); kfree(int34x_zone);
} }
EXPORT_SYMBOL_GPL(int340x_thermal_zone_remove); EXPORT_SYMBOL_GPL(int340x_thermal_zone_remove);
......
...@@ -20,10 +20,8 @@ struct active_trip { ...@@ -20,10 +20,8 @@ struct active_trip {
struct int34x_thermal_zone { struct int34x_thermal_zone {
struct acpi_device *adev; struct acpi_device *adev;
struct thermal_trip *trips;
int aux_trip_nr; int aux_trip_nr;
struct thermal_zone_device *zone; struct thermal_zone_device *zone;
struct thermal_zone_device_ops *ops;
void *priv_data; void *priv_data;
struct acpi_lpat_conversion_table *lpat_table; struct acpi_lpat_conversion_table *lpat_table;
}; };
......
...@@ -233,11 +233,7 @@ static int get_trip_temp(struct proc_thermal_pci *pci_info) ...@@ -233,11 +233,7 @@ static int get_trip_temp(struct proc_thermal_pci *pci_info)
return temp; return temp;
} }
static struct thermal_trip psv_trip = { static const struct thermal_zone_device_ops tzone_ops = {
.type = THERMAL_TRIP_PASSIVE,
};
static struct thermal_zone_device_ops tzone_ops = {
.get_temp = sys_get_curr_temp, .get_temp = sys_get_curr_temp,
.set_trip_temp = sys_set_trip_temp, .set_trip_temp = sys_set_trip_temp,
}; };
...@@ -251,6 +247,10 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, const struct pci_device_ ...@@ -251,6 +247,10 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, const struct pci_device_
{ {
struct proc_thermal_device *proc_priv; struct proc_thermal_device *proc_priv;
struct proc_thermal_pci *pci_info; struct proc_thermal_pci *pci_info;
struct thermal_trip psv_trip = {
.type = THERMAL_TRIP_PASSIVE,
.flags = THERMAL_TRIP_FLAG_RW_TEMP,
};
int irq_flag = 0, irq, ret; int irq_flag = 0, irq, ret;
bool msi_irq = false; bool msi_irq = false;
...@@ -290,7 +290,7 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, const struct pci_device_ ...@@ -290,7 +290,7 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, const struct pci_device_
psv_trip.temperature = get_trip_temp(pci_info); psv_trip.temperature = get_trip_temp(pci_info);
pci_info->tzone = thermal_zone_device_register_with_trips("TCPU_PCI", &psv_trip, pci_info->tzone = thermal_zone_device_register_with_trips("TCPU_PCI", &psv_trip,
1, 1, pci_info, 1, pci_info,
&tzone_ops, &tzone_ops,
&tzone_params, 0, 0); &tzone_params, 0, 0);
if (IS_ERR(pci_info->tzone)) { if (IS_ERR(pci_info->tzone)) {
......
...@@ -84,7 +84,6 @@ struct pch_thermal_device { ...@@ -84,7 +84,6 @@ struct pch_thermal_device {
void __iomem *hw_base; void __iomem *hw_base;
struct pci_dev *pdev; struct pci_dev *pdev;
struct thermal_zone_device *tzd; struct thermal_zone_device *tzd;
struct thermal_trip trips[PCH_MAX_TRIPS];
bool bios_enabled; bool bios_enabled;
}; };
...@@ -94,7 +93,8 @@ struct pch_thermal_device { ...@@ -94,7 +93,8 @@ struct pch_thermal_device {
* passive trip temperature using _PSV method. There is no specific * passive trip temperature using _PSV method. There is no specific
* passive temperature setting in MMIO interface of this PCI device. * passive temperature setting in MMIO interface of this PCI device.
*/ */
static int pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd, int trip) static int pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd,
struct thermal_trip *trip)
{ {
struct acpi_device *adev; struct acpi_device *adev;
int temp; int temp;
...@@ -106,12 +106,13 @@ static int pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd, int trip) ...@@ -106,12 +106,13 @@ static int pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd, int trip)
if (thermal_acpi_passive_trip_temp(adev, &temp) || temp <= 0) if (thermal_acpi_passive_trip_temp(adev, &temp) || temp <= 0)
return 0; return 0;
ptd->trips[trip].type = THERMAL_TRIP_PASSIVE; trip->type = THERMAL_TRIP_PASSIVE;
ptd->trips[trip].temperature = temp; trip->temperature = temp;
return 1; return 1;
} }
#else #else
static int pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd, int trip) static int pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd,
struct thermal_trip *trip)
{ {
return 0; return 0;
} }
...@@ -131,7 +132,7 @@ static void pch_critical(struct thermal_zone_device *tzd) ...@@ -131,7 +132,7 @@ static void pch_critical(struct thermal_zone_device *tzd)
thermal_zone_device_type(tzd)); thermal_zone_device_type(tzd));
} }
static struct thermal_zone_device_ops tzd_ops = { static const struct thermal_zone_device_ops tzd_ops = {
.get_temp = pch_thermal_get_temp, .get_temp = pch_thermal_get_temp,
.critical = pch_critical, .critical = pch_critical,
}; };
...@@ -159,6 +160,7 @@ static const char *board_names[] = { ...@@ -159,6 +160,7 @@ static const char *board_names[] = {
static int intel_pch_thermal_probe(struct pci_dev *pdev, static int intel_pch_thermal_probe(struct pci_dev *pdev,
const struct pci_device_id *id) const struct pci_device_id *id)
{ {
struct thermal_trip ptd_trips[PCH_MAX_TRIPS] = { 0 };
enum pch_board_ids board_id = id->driver_data; enum pch_board_ids board_id = id->driver_data;
struct pch_thermal_device *ptd; struct pch_thermal_device *ptd;
int nr_trips = 0; int nr_trips = 0;
...@@ -220,22 +222,22 @@ static int intel_pch_thermal_probe(struct pci_dev *pdev, ...@@ -220,22 +222,22 @@ static int intel_pch_thermal_probe(struct pci_dev *pdev,
trip_temp = readw(ptd->hw_base + WPT_CTT); trip_temp = readw(ptd->hw_base + WPT_CTT);
trip_temp &= 0x1FF; trip_temp &= 0x1FF;
if (trip_temp) { if (trip_temp) {
ptd->trips[nr_trips].temperature = GET_WPT_TEMP(trip_temp); ptd_trips[nr_trips].temperature = GET_WPT_TEMP(trip_temp);
ptd->trips[nr_trips++].type = THERMAL_TRIP_CRITICAL; ptd_trips[nr_trips++].type = THERMAL_TRIP_CRITICAL;
} }
trip_temp = readw(ptd->hw_base + WPT_PHL); trip_temp = readw(ptd->hw_base + WPT_PHL);
trip_temp &= 0x1FF; trip_temp &= 0x1FF;
if (trip_temp) { if (trip_temp) {
ptd->trips[nr_trips].temperature = GET_WPT_TEMP(trip_temp); ptd_trips[nr_trips].temperature = GET_WPT_TEMP(trip_temp);
ptd->trips[nr_trips++].type = THERMAL_TRIP_HOT; ptd_trips[nr_trips++].type = THERMAL_TRIP_HOT;
} }
nr_trips += pch_wpt_add_acpi_psv_trip(ptd, nr_trips); nr_trips += pch_wpt_add_acpi_psv_trip(ptd, &ptd_trips[nr_trips]);
ptd->tzd = thermal_zone_device_register_with_trips(board_names[board_id], ptd->tzd = thermal_zone_device_register_with_trips(board_names[board_id],
ptd->trips, nr_trips, ptd_trips, nr_trips,
0, ptd, &tzd_ops, ptd, &tzd_ops,
NULL, 0, 0); NULL, 0, 0);
if (IS_ERR(ptd->tzd)) { if (IS_ERR(ptd->tzd)) {
dev_err(&pdev->dev, "Failed to register thermal zone %s\n", dev_err(&pdev->dev, "Failed to register thermal zone %s\n",
......
...@@ -93,10 +93,6 @@ ...@@ -93,10 +93,6 @@
/* Quark DTS has 2 trip points: hot & catastrophic */ /* Quark DTS has 2 trip points: hot & catastrophic */
#define QRK_MAX_DTS_TRIPS 2 #define QRK_MAX_DTS_TRIPS 2
/* If DTS not locked, all trip points are configurable */
#define QRK_DTS_WR_MASK_SET 0x3
/* If DTS locked, all trip points are not configurable */
#define QRK_DTS_WR_MASK_CLR 0
#define DEFAULT_POLL_DELAY 2000 #define DEFAULT_POLL_DELAY 2000
...@@ -105,7 +101,6 @@ struct soc_sensor_entry { ...@@ -105,7 +101,6 @@ struct soc_sensor_entry {
u32 store_ptps; u32 store_ptps;
u32 store_dts_enable; u32 store_dts_enable;
struct thermal_zone_device *tzone; struct thermal_zone_device *tzone;
struct thermal_trip trips[QRK_MAX_DTS_TRIPS];
}; };
static struct soc_sensor_entry *soc_dts; static struct soc_sensor_entry *soc_dts;
...@@ -293,7 +288,7 @@ static int sys_change_mode(struct thermal_zone_device *tzd, ...@@ -293,7 +288,7 @@ static int sys_change_mode(struct thermal_zone_device *tzd,
return ret; return ret;
} }
static struct thermal_zone_device_ops tzone_ops = { static const struct thermal_zone_device_ops tzone_ops = {
.get_temp = sys_get_curr_temp, .get_temp = sys_get_curr_temp,
.set_trip_temp = sys_set_trip_temp, .set_trip_temp = sys_set_trip_temp,
.change_mode = sys_change_mode, .change_mode = sys_change_mode,
...@@ -320,10 +315,10 @@ static void free_soc_dts(struct soc_sensor_entry *aux_entry) ...@@ -320,10 +315,10 @@ static void free_soc_dts(struct soc_sensor_entry *aux_entry)
static struct soc_sensor_entry *alloc_soc_dts(void) static struct soc_sensor_entry *alloc_soc_dts(void)
{ {
struct thermal_trip trips[QRK_MAX_DTS_TRIPS] = { 0 };
struct soc_sensor_entry *aux_entry; struct soc_sensor_entry *aux_entry;
int err; int err;
u32 out; u32 out;
int wr_mask;
aux_entry = kzalloc(sizeof(*aux_entry), GFP_KERNEL); aux_entry = kzalloc(sizeof(*aux_entry), GFP_KERNEL);
if (!aux_entry) { if (!aux_entry) {
...@@ -337,13 +332,7 @@ static struct soc_sensor_entry *alloc_soc_dts(void) ...@@ -337,13 +332,7 @@ static struct soc_sensor_entry *alloc_soc_dts(void)
if (err) if (err)
goto err_ret; goto err_ret;
if (out & QRK_DTS_LOCK_BIT) { aux_entry->locked = !!(out & QRK_DTS_LOCK_BIT);
aux_entry->locked = true;
wr_mask = QRK_DTS_WR_MASK_CLR;
} else {
aux_entry->locked = false;
wr_mask = QRK_DTS_WR_MASK_SET;
}
/* Store DTS default state if DTS registers are not locked */ /* Store DTS default state if DTS registers are not locked */
if (!aux_entry->locked) { if (!aux_entry->locked) {
...@@ -360,19 +349,22 @@ static struct soc_sensor_entry *alloc_soc_dts(void) ...@@ -360,19 +349,22 @@ static struct soc_sensor_entry *alloc_soc_dts(void)
&aux_entry->store_ptps); &aux_entry->store_ptps);
if (err) if (err)
goto err_ret; goto err_ret;
trips[QRK_DTS_ID_TP_CRITICAL].flags |= THERMAL_TRIP_FLAG_RW_TEMP;
trips[QRK_DTS_ID_TP_HOT].flags |= THERMAL_TRIP_FLAG_RW_TEMP;
} }
aux_entry->trips[QRK_DTS_ID_TP_CRITICAL].temperature = get_trip_temp(QRK_DTS_ID_TP_CRITICAL); trips[QRK_DTS_ID_TP_CRITICAL].temperature = get_trip_temp(QRK_DTS_ID_TP_CRITICAL);
aux_entry->trips[QRK_DTS_ID_TP_CRITICAL].type = THERMAL_TRIP_CRITICAL; trips[QRK_DTS_ID_TP_CRITICAL].type = THERMAL_TRIP_CRITICAL;
aux_entry->trips[QRK_DTS_ID_TP_HOT].temperature = get_trip_temp(QRK_DTS_ID_TP_HOT); trips[QRK_DTS_ID_TP_HOT].temperature = get_trip_temp(QRK_DTS_ID_TP_HOT);
aux_entry->trips[QRK_DTS_ID_TP_HOT].type = THERMAL_TRIP_HOT; trips[QRK_DTS_ID_TP_HOT].type = THERMAL_TRIP_HOT;
aux_entry->tzone = thermal_zone_device_register_with_trips("quark_dts", aux_entry->tzone = thermal_zone_device_register_with_trips("quark_dts",
aux_entry->trips, trips,
QRK_MAX_DTS_TRIPS, QRK_MAX_DTS_TRIPS,
wr_mask, aux_entry,
aux_entry, &tzone_ops, &tzone_ops,
NULL, 0, polling_delay); NULL, 0, polling_delay);
if (IS_ERR(aux_entry->tzone)) { if (IS_ERR(aux_entry->tzone)) {
err = PTR_ERR(aux_entry->tzone); err = PTR_ERR(aux_entry->tzone);
......
...@@ -129,22 +129,6 @@ static int update_trip_temp(struct intel_soc_dts_sensors *sensors, ...@@ -129,22 +129,6 @@ static int update_trip_temp(struct intel_soc_dts_sensors *sensors,
return status; return status;
} }
static int configure_trip(struct intel_soc_dts_sensor_entry *dts,
int thres_index, enum thermal_trip_type trip_type,
int temp)
{
int ret;
ret = update_trip_temp(dts->sensors, thres_index, temp);
if (ret)
return ret;
dts->trips[thres_index].temperature = temp;
dts->trips[thres_index].type = trip_type;
return 0;
}
static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip,
int temp) int temp)
{ {
...@@ -184,7 +168,7 @@ static int sys_get_curr_temp(struct thermal_zone_device *tzd, ...@@ -184,7 +168,7 @@ static int sys_get_curr_temp(struct thermal_zone_device *tzd,
return 0; return 0;
} }
static struct thermal_zone_device_ops tzone_ops = { static const struct thermal_zone_device_ops tzone_ops = {
.get_temp = sys_get_curr_temp, .get_temp = sys_get_curr_temp,
.set_trip_temp = sys_set_trip_temp, .set_trip_temp = sys_set_trip_temp,
}; };
...@@ -218,15 +202,10 @@ static void remove_dts_thermal_zone(struct intel_soc_dts_sensor_entry *dts) ...@@ -218,15 +202,10 @@ static void remove_dts_thermal_zone(struct intel_soc_dts_sensor_entry *dts)
} }
static int add_dts_thermal_zone(int id, struct intel_soc_dts_sensor_entry *dts, static int add_dts_thermal_zone(int id, struct intel_soc_dts_sensor_entry *dts,
bool critical_trip) struct thermal_trip *trips)
{ {
int writable_trip_cnt = SOC_MAX_DTS_TRIPS;
char name[10]; char name[10];
unsigned long trip;
int trip_mask;
unsigned long ptps;
u32 store_ptps; u32 store_ptps;
unsigned long i;
int ret; int ret;
/* Store status to restor on exit */ /* Store status to restor on exit */
...@@ -237,26 +216,20 @@ static int add_dts_thermal_zone(int id, struct intel_soc_dts_sensor_entry *dts, ...@@ -237,26 +216,20 @@ static int add_dts_thermal_zone(int id, struct intel_soc_dts_sensor_entry *dts,
dts->id = id; dts->id = id;
if (critical_trip)
writable_trip_cnt--;
trip_mask = GENMASK(writable_trip_cnt - 1, 0);
/* Check if the writable trip we provide is not used by BIOS */ /* Check if the writable trip we provide is not used by BIOS */
ret = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, ret = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ,
SOC_DTS_OFFSET_PTPS, &store_ptps); SOC_DTS_OFFSET_PTPS, &store_ptps);
if (ret) if (!ret) {
trip_mask = 0; int i;
else {
ptps = store_ptps; for (i = 0; i <= 1; i++) {
for_each_set_clump8(i, trip, &ptps, writable_trip_cnt * 8) if (store_ptps & (0xFFU << i * 8))
trip_mask &= ~BIT(i / 8); trips[i].flags &= ~THERMAL_TRIP_FLAG_RW_TEMP;
}
} }
dts->trip_mask = trip_mask;
snprintf(name, sizeof(name), "soc_dts%d", id); snprintf(name, sizeof(name), "soc_dts%d", id);
dts->tzone = thermal_zone_device_register_with_trips(name, dts->trips, dts->tzone = thermal_zone_device_register_with_trips(name, trips,
SOC_MAX_DTS_TRIPS, SOC_MAX_DTS_TRIPS,
trip_mask,
dts, &tzone_ops, dts, &tzone_ops,
NULL, 0, 0); NULL, 0, 0);
if (IS_ERR(dts->tzone)) { if (IS_ERR(dts->tzone)) {
...@@ -315,14 +288,23 @@ EXPORT_SYMBOL_GPL(intel_soc_dts_iosf_interrupt_handler); ...@@ -315,14 +288,23 @@ EXPORT_SYMBOL_GPL(intel_soc_dts_iosf_interrupt_handler);
static void dts_trips_reset(struct intel_soc_dts_sensors *sensors, int dts_index) static void dts_trips_reset(struct intel_soc_dts_sensors *sensors, int dts_index)
{ {
configure_trip(&sensors->soc_dts[dts_index], 0, 0, 0); update_trip_temp(sensors, 0, 0);
configure_trip(&sensors->soc_dts[dts_index], 1, 0, 0); update_trip_temp(sensors, 1, 0);
}
static void set_trip(struct thermal_trip *trip, enum thermal_trip_type type,
u8 flags, int temp)
{
trip->type = type;
trip->flags = flags;
trip->temperature = temp;
} }
struct intel_soc_dts_sensors * struct intel_soc_dts_sensors *
intel_soc_dts_iosf_init(enum intel_soc_dts_interrupt_type intr_type, intel_soc_dts_iosf_init(enum intel_soc_dts_interrupt_type intr_type,
bool critical_trip, int crit_offset) bool critical_trip, int crit_offset)
{ {
struct thermal_trip trips[SOC_MAX_DTS_SENSORS][SOC_MAX_DTS_TRIPS] = { 0 };
struct intel_soc_dts_sensors *sensors; struct intel_soc_dts_sensors *sensors;
int tj_max; int tj_max;
int ret; int ret;
...@@ -345,30 +327,33 @@ intel_soc_dts_iosf_init(enum intel_soc_dts_interrupt_type intr_type, ...@@ -345,30 +327,33 @@ intel_soc_dts_iosf_init(enum intel_soc_dts_interrupt_type intr_type,
sensors->tj_max = tj_max * 1000; sensors->tj_max = tj_max * 1000;
for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) { for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) {
enum thermal_trip_type trip_type;
int temp; int temp;
sensors->soc_dts[i].sensors = sensors; sensors->soc_dts[i].sensors = sensors;
ret = configure_trip(&sensors->soc_dts[i], 0, set_trip(&trips[i][0], THERMAL_TRIP_PASSIVE,
THERMAL_TRIP_PASSIVE, 0); THERMAL_TRIP_FLAG_RW_TEMP, 0);
ret = update_trip_temp(sensors, 0, 0);
if (ret) if (ret)
goto err_reset_trips; goto err_reset_trips;
if (critical_trip) { if (critical_trip) {
trip_type = THERMAL_TRIP_CRITICAL;
temp = sensors->tj_max - crit_offset; temp = sensors->tj_max - crit_offset;
set_trip(&trips[i][1], THERMAL_TRIP_CRITICAL, 0, temp);
} else { } else {
trip_type = THERMAL_TRIP_PASSIVE; set_trip(&trips[i][1], THERMAL_TRIP_PASSIVE,
THERMAL_TRIP_FLAG_RW_TEMP, 0);
temp = 0; temp = 0;
} }
ret = configure_trip(&sensors->soc_dts[i], 1, trip_type, temp);
ret = update_trip_temp(sensors, 1, temp);
if (ret) if (ret)
goto err_reset_trips; goto err_reset_trips;
} }
for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) { for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) {
ret = add_dts_thermal_zone(i, &sensors->soc_dts[i], critical_trip); ret = add_dts_thermal_zone(i, &sensors->soc_dts[i], trips[i]);
if (ret) if (ret)
goto err_remove_zone; goto err_remove_zone;
} }
......
...@@ -28,8 +28,6 @@ struct intel_soc_dts_sensors; ...@@ -28,8 +28,6 @@ struct intel_soc_dts_sensors;
struct intel_soc_dts_sensor_entry { struct intel_soc_dts_sensor_entry {
int id; int id;
u32 store_status; u32 store_status;
u32 trip_mask;
struct thermal_trip trips[SOC_MAX_DTS_TRIPS];
struct thermal_zone_device *tzone; struct thermal_zone_device *tzone;
struct intel_soc_dts_sensors *sensors; struct intel_soc_dts_sensors *sensors;
}; };
......
...@@ -53,7 +53,6 @@ struct zone_device { ...@@ -53,7 +53,6 @@ struct zone_device {
u32 msr_pkg_therm_high; u32 msr_pkg_therm_high;
struct delayed_work work; struct delayed_work work;
struct thermal_zone_device *tzone; struct thermal_zone_device *tzone;
struct thermal_trip *trips;
struct cpumask cpumask; struct cpumask cpumask;
}; };
...@@ -167,7 +166,7 @@ sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp) ...@@ -167,7 +166,7 @@ sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp)
} }
/* Thermal zone callback registry */ /* Thermal zone callback registry */
static struct thermal_zone_device_ops tzone_ops = { static const struct thermal_zone_device_ops tzone_ops = {
.get_temp = sys_get_curr_temp, .get_temp = sys_get_curr_temp,
.set_trip_temp = sys_set_trip_temp, .set_trip_temp = sys_set_trip_temp,
}; };
...@@ -268,17 +267,13 @@ static int pkg_thermal_notify(u64 msr_val) ...@@ -268,17 +267,13 @@ static int pkg_thermal_notify(u64 msr_val)
return 0; return 0;
} }
static struct thermal_trip *pkg_temp_thermal_trips_init(int cpu, int tj_max, int num_trips) static int pkg_temp_thermal_trips_init(int cpu, int tj_max,
struct thermal_trip *trips, int num_trips)
{ {
struct thermal_trip *trips;
unsigned long thres_reg_value; unsigned long thres_reg_value;
u32 mask, shift, eax, edx; u32 mask, shift, eax, edx;
int ret, i; int ret, i;
trips = kzalloc(sizeof(*trips) * num_trips, GFP_KERNEL);
if (!trips)
return ERR_PTR(-ENOMEM);
for (i = 0; i < num_trips; i++) { for (i = 0; i < num_trips; i++) {
if (i) { if (i) {
...@@ -291,10 +286,8 @@ static struct thermal_trip *pkg_temp_thermal_trips_init(int cpu, int tj_max, int ...@@ -291,10 +286,8 @@ static struct thermal_trip *pkg_temp_thermal_trips_init(int cpu, int tj_max, int
ret = rdmsr_on_cpu(cpu, MSR_IA32_PACKAGE_THERM_INTERRUPT, ret = rdmsr_on_cpu(cpu, MSR_IA32_PACKAGE_THERM_INTERRUPT,
&eax, &edx); &eax, &edx);
if (ret < 0) { if (ret < 0)
kfree(trips); return ret;
return ERR_PTR(ret);
}
thres_reg_value = (eax & mask) >> shift; thres_reg_value = (eax & mask) >> shift;
...@@ -302,16 +295,18 @@ static struct thermal_trip *pkg_temp_thermal_trips_init(int cpu, int tj_max, int ...@@ -302,16 +295,18 @@ static struct thermal_trip *pkg_temp_thermal_trips_init(int cpu, int tj_max, int
tj_max - thres_reg_value * 1000 : THERMAL_TEMP_INVALID; tj_max - thres_reg_value * 1000 : THERMAL_TEMP_INVALID;
trips[i].type = THERMAL_TRIP_PASSIVE; trips[i].type = THERMAL_TRIP_PASSIVE;
trips[i].flags |= THERMAL_TRIP_FLAG_RW_TEMP;
pr_debug("%s: cpu=%d, trip=%d, temp=%d\n", pr_debug("%s: cpu=%d, trip=%d, temp=%d\n",
__func__, cpu, i, trips[i].temperature); __func__, cpu, i, trips[i].temperature);
} }
return trips; return 0;
} }
static int pkg_temp_thermal_device_add(unsigned int cpu) static int pkg_temp_thermal_device_add(unsigned int cpu)
{ {
struct thermal_trip trips[MAX_NUMBER_OF_TRIPS] = { 0 };
int id = topology_logical_die_id(cpu); int id = topology_logical_die_id(cpu);
u32 eax, ebx, ecx, edx; u32 eax, ebx, ecx, edx;
struct zone_device *zonedev; struct zone_device *zonedev;
...@@ -336,21 +331,18 @@ static int pkg_temp_thermal_device_add(unsigned int cpu) ...@@ -336,21 +331,18 @@ static int pkg_temp_thermal_device_add(unsigned int cpu)
if (!zonedev) if (!zonedev)
return -ENOMEM; return -ENOMEM;
zonedev->trips = pkg_temp_thermal_trips_init(cpu, tj_max, thres_count); err = pkg_temp_thermal_trips_init(cpu, tj_max, trips, thres_count);
if (IS_ERR(zonedev->trips)) { if (err)
err = PTR_ERR(zonedev->trips);
goto out_kfree_zonedev; goto out_kfree_zonedev;
}
INIT_DELAYED_WORK(&zonedev->work, pkg_temp_thermal_threshold_work_fn); INIT_DELAYED_WORK(&zonedev->work, pkg_temp_thermal_threshold_work_fn);
zonedev->cpu = cpu; zonedev->cpu = cpu;
zonedev->tzone = thermal_zone_device_register_with_trips("x86_pkg_temp", zonedev->tzone = thermal_zone_device_register_with_trips("x86_pkg_temp",
zonedev->trips, thres_count, trips, thres_count,
(thres_count == MAX_NUMBER_OF_TRIPS) ? 0x03 : 0x01,
zonedev, &tzone_ops, &pkg_temp_tz_params, 0, 0); zonedev, &tzone_ops, &pkg_temp_tz_params, 0, 0);
if (IS_ERR(zonedev->tzone)) { if (IS_ERR(zonedev->tzone)) {
err = PTR_ERR(zonedev->tzone); err = PTR_ERR(zonedev->tzone);
goto out_kfree_trips; goto out_kfree_zonedev;
} }
err = thermal_zone_device_enable(zonedev->tzone); err = thermal_zone_device_enable(zonedev->tzone);
if (err) if (err)
...@@ -369,8 +361,6 @@ static int pkg_temp_thermal_device_add(unsigned int cpu) ...@@ -369,8 +361,6 @@ static int pkg_temp_thermal_device_add(unsigned int cpu)
out_unregister_tz: out_unregister_tz:
thermal_zone_device_unregister(zonedev->tzone); thermal_zone_device_unregister(zonedev->tzone);
out_kfree_trips:
kfree(zonedev->trips);
out_kfree_zonedev: out_kfree_zonedev:
kfree(zonedev); kfree(zonedev);
return err; return err;
...@@ -457,10 +447,9 @@ static int pkg_thermal_cpu_offline(unsigned int cpu) ...@@ -457,10 +447,9 @@ static int pkg_thermal_cpu_offline(unsigned int cpu)
raw_spin_unlock_irq(&pkg_temp_lock); raw_spin_unlock_irq(&pkg_temp_lock);
/* Final cleanup if this is the last cpu */ /* Final cleanup if this is the last cpu */
if (lastcpu) { if (lastcpu)
kfree(zonedev->trips);
kfree(zonedev); kfree(zonedev);
}
return 0; return 0;
} }
......
...@@ -489,7 +489,7 @@ static int rcar_thermal_probe(struct platform_device *pdev) ...@@ -489,7 +489,7 @@ static int rcar_thermal_probe(struct platform_device *pdev)
&rcar_thermal_zone_ops); &rcar_thermal_zone_ops);
} else { } else {
priv->zone = thermal_zone_device_register_with_trips( priv->zone = thermal_zone_device_register_with_trips(
"rcar_thermal", trips, ARRAY_SIZE(trips), 0, priv, "rcar_thermal", trips, ARRAY_SIZE(trips), priv,
&rcar_thermal_zone_ops, NULL, 0, &rcar_thermal_zone_ops, NULL, 0,
idle); idle);
......
...@@ -203,7 +203,7 @@ int st_thermal_register(struct platform_device *pdev, ...@@ -203,7 +203,7 @@ int st_thermal_register(struct platform_device *pdev,
trip.type = THERMAL_TRIP_CRITICAL; trip.type = THERMAL_TRIP_CRITICAL;
sensor->thermal_dev = sensor->thermal_dev =
thermal_zone_device_register_with_trips(dev_name(dev), &trip, 1, 0, sensor, thermal_zone_device_register_with_trips(dev_name(dev), &trip, 1, sensor,
&st_tz_ops, NULL, 0, polling_delay); &st_tz_ops, NULL, 0, polling_delay);
if (IS_ERR(sensor->thermal_dev)) { if (IS_ERR(sensor->thermal_dev)) {
dev_err(dev, "failed to register thermal zone device\n"); dev_err(dev, "failed to register thermal zone device\n");
......
...@@ -273,7 +273,6 @@ static int __init thermal_register_governors(void) ...@@ -273,7 +273,6 @@ static int __init thermal_register_governors(void)
/* /*
* Zone update section: main control loop applied to each zone while monitoring * Zone update section: main control loop applied to each zone while monitoring
*
* in polling mode. The monitoring is done using a workqueue. * in polling mode. The monitoring is done using a workqueue.
* Same update may be done on a zone by calling thermal_zone_device_update(). * Same update may be done on a zone by calling thermal_zone_device_update().
* *
...@@ -356,9 +355,9 @@ static void handle_critical_trips(struct thermal_zone_device *tz, ...@@ -356,9 +355,9 @@ static void handle_critical_trips(struct thermal_zone_device *tz,
trace_thermal_zone_trip(tz, thermal_zone_trip_id(tz, trip), trip->type); trace_thermal_zone_trip(tz, thermal_zone_trip_id(tz, trip), trip->type);
if (trip->type == THERMAL_TRIP_CRITICAL) if (trip->type == THERMAL_TRIP_CRITICAL)
tz->ops->critical(tz); tz->ops.critical(tz);
else if (tz->ops->hot) else if (tz->ops.hot)
tz->ops->hot(tz); tz->ops.hot(tz);
} }
static void handle_thermal_trip(struct thermal_zone_device *tz, static void handle_thermal_trip(struct thermal_zone_device *tz,
...@@ -493,8 +492,8 @@ static int thermal_zone_device_set_mode(struct thermal_zone_device *tz, ...@@ -493,8 +492,8 @@ static int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
return ret; return ret;
} }
if (tz->ops->change_mode) if (tz->ops.change_mode)
ret = tz->ops->change_mode(tz, mode); ret = tz->ops.change_mode(tz, mode);
if (!ret) if (!ret)
tz->mode = mode; tz->mode = mode;
...@@ -867,8 +866,8 @@ static void bind_cdev(struct thermal_cooling_device *cdev) ...@@ -867,8 +866,8 @@ static void bind_cdev(struct thermal_cooling_device *cdev)
struct thermal_zone_device *pos = NULL; struct thermal_zone_device *pos = NULL;
list_for_each_entry(pos, &thermal_tz_list, node) { list_for_each_entry(pos, &thermal_tz_list, node) {
if (pos->ops->bind) { if (pos->ops.bind) {
ret = pos->ops->bind(pos, cdev); ret = pos->ops.bind(pos, cdev);
if (ret) if (ret)
print_bind_err_msg(pos, cdev, ret); print_bind_err_msg(pos, cdev, ret);
} }
...@@ -1184,8 +1183,8 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev) ...@@ -1184,8 +1183,8 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev)
/* Unbind all thermal zones associated with 'this' cdev */ /* Unbind all thermal zones associated with 'this' cdev */
list_for_each_entry(tz, &thermal_tz_list, node) { list_for_each_entry(tz, &thermal_tz_list, node) {
if (tz->ops->unbind) if (tz->ops.unbind)
tz->ops->unbind(tz, cdev); tz->ops.unbind(tz, cdev);
} }
mutex_unlock(&thermal_list_lock); mutex_unlock(&thermal_list_lock);
...@@ -1199,13 +1198,13 @@ static void bind_tz(struct thermal_zone_device *tz) ...@@ -1199,13 +1198,13 @@ static void bind_tz(struct thermal_zone_device *tz)
int ret; int ret;
struct thermal_cooling_device *pos = NULL; struct thermal_cooling_device *pos = NULL;
if (!tz->ops->bind) if (!tz->ops.bind)
return; return;
mutex_lock(&thermal_list_lock); mutex_lock(&thermal_list_lock);
list_for_each_entry(pos, &thermal_cdev_list, node) { list_for_each_entry(pos, &thermal_cdev_list, node) {
ret = tz->ops->bind(tz, pos); ret = tz->ops.bind(tz, pos);
if (ret) if (ret)
print_bind_err_msg(tz, pos, ret); print_bind_err_msg(tz, pos, ret);
} }
...@@ -1224,11 +1223,8 @@ int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp) ...@@ -1224,11 +1223,8 @@ int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp)
{ {
int i, ret = -EINVAL; int i, 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);
if (!tz->trips)
return -EINVAL;
mutex_lock(&tz->lock); mutex_lock(&tz->lock);
...@@ -1251,7 +1247,6 @@ EXPORT_SYMBOL_GPL(thermal_zone_get_crit_temp); ...@@ -1251,7 +1247,6 @@ EXPORT_SYMBOL_GPL(thermal_zone_get_crit_temp);
* @type: the thermal zone device type * @type: the thermal zone device type
* @trips: a pointer to an array of thermal trips * @trips: a pointer to an array of thermal trips
* @num_trips: the number of trip points the thermal zone support * @num_trips: the number of trip points the thermal zone support
* @mask: a bit string indicating the writeablility of trip points
* @devdata: private device data * @devdata: private device data
* @ops: standard thermal zone device callbacks * @ops: standard thermal zone device callbacks
* @tzp: thermal zone platform parameters * @tzp: thermal zone platform parameters
...@@ -1272,10 +1267,12 @@ EXPORT_SYMBOL_GPL(thermal_zone_get_crit_temp); ...@@ -1272,10 +1267,12 @@ EXPORT_SYMBOL_GPL(thermal_zone_get_crit_temp);
* IS_ERR*() helpers. * IS_ERR*() helpers.
*/ */
struct thermal_zone_device * struct thermal_zone_device *
thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *trips, int num_trips, int mask, thermal_zone_device_register_with_trips(const char *type,
void *devdata, struct thermal_zone_device_ops *ops, const struct thermal_trip *trips,
const struct thermal_zone_params *tzp, int passive_delay, int num_trips, void *devdata,
int polling_delay) const struct thermal_zone_device_ops *ops,
const struct thermal_zone_params *tzp,
int passive_delay, int polling_delay)
{ {
struct thermal_zone_device *tz; struct thermal_zone_device *tz;
int id; int id;
...@@ -1293,20 +1290,7 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t ...@@ -1293,20 +1290,7 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
/* if (num_trips < 0) {
* Max trip count can't exceed 31 as the "mask >> num_trips" condition.
* For example, shifting by 32 will result in compiler warning:
* warning: right shift count >= width of type [-Wshift-count- overflow]
*
* Also "mask >> num_trips" will always be true with 32 bit shift.
* E.g. mask = 0x80000000 for trip id 31 to be RW. Then
* mask >> 32 = 0x80000000
* This will result in failure for the below condition.
*
* Check will be true when the bit 31 of the mask is set.
* 32 bit shift will cause overflow of 4 byte integer.
*/
if (num_trips > (BITS_PER_TYPE(int) - 1) || num_trips < 0 || mask >> num_trips) {
pr_err("Incorrect number of thermal trips\n"); pr_err("Incorrect number of thermal trips\n");
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
...@@ -1322,7 +1306,7 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t ...@@ -1322,7 +1306,7 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t
if (!thermal_class) if (!thermal_class)
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
tz = kzalloc(sizeof(*tz), GFP_KERNEL); tz = kzalloc(struct_size(tz, trips, num_trips), GFP_KERNEL);
if (!tz) if (!tz)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -1348,21 +1332,21 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t ...@@ -1348,21 +1332,21 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t
tz->id = id; tz->id = id;
strscpy(tz->type, type, sizeof(tz->type)); strscpy(tz->type, type, sizeof(tz->type));
if (!ops->critical) tz->ops = *ops;
ops->critical = thermal_zone_device_critical; if (!tz->ops.critical)
tz->ops.critical = thermal_zone_device_critical;
tz->ops = ops;
tz->device.class = thermal_class; tz->device.class = thermal_class;
tz->devdata = devdata; tz->devdata = devdata;
tz->trips = trips;
tz->num_trips = num_trips; tz->num_trips = num_trips;
memcpy(tz->trips, trips, num_trips * sizeof(*trips));
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);
/* sys I/F */ /* sys I/F */
/* Add nodes that are always present via .groups */ /* Add nodes that are always present via .groups */
result = thermal_zone_create_device_groups(tz, mask); result = thermal_zone_create_device_groups(tz);
if (result) if (result)
goto remove_id; goto remove_id;
...@@ -1437,10 +1421,10 @@ EXPORT_SYMBOL_GPL(thermal_zone_device_register_with_trips); ...@@ -1437,10 +1421,10 @@ EXPORT_SYMBOL_GPL(thermal_zone_device_register_with_trips);
struct thermal_zone_device *thermal_tripless_zone_device_register( struct thermal_zone_device *thermal_tripless_zone_device_register(
const char *type, const char *type,
void *devdata, void *devdata,
struct thermal_zone_device_ops *ops, const struct thermal_zone_device_ops *ops,
const struct thermal_zone_params *tzp) const struct thermal_zone_params *tzp)
{ {
return thermal_zone_device_register_with_trips(type, NULL, 0, 0, devdata, return thermal_zone_device_register_with_trips(type, NULL, 0, devdata,
ops, tzp, 0, 0); ops, tzp, 0, 0);
} }
EXPORT_SYMBOL_GPL(thermal_tripless_zone_device_register); EXPORT_SYMBOL_GPL(thermal_tripless_zone_device_register);
...@@ -1499,8 +1483,8 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz) ...@@ -1499,8 +1483,8 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
/* Unbind all cdevs associated with 'this' thermal zone */ /* Unbind all cdevs associated with 'this' thermal zone */
list_for_each_entry(cdev, &thermal_cdev_list, node) list_for_each_entry(cdev, &thermal_cdev_list, node)
if (tz->ops->unbind) if (tz->ops.unbind)
tz->ops->unbind(tz, cdev); tz->ops.unbind(tz, cdev);
mutex_unlock(&thermal_list_lock); mutex_unlock(&thermal_list_lock);
......
...@@ -131,7 +131,7 @@ void thermal_zone_trip_updated(struct thermal_zone_device *tz, ...@@ -131,7 +131,7 @@ void thermal_zone_trip_updated(struct thermal_zone_device *tz,
int __thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp); int __thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp);
/* sysfs I/F */ /* sysfs I/F */
int thermal_zone_create_device_groups(struct thermal_zone_device *, int); int thermal_zone_create_device_groups(struct thermal_zone_device *tz);
void thermal_zone_destroy_device_groups(struct thermal_zone_device *); void thermal_zone_destroy_device_groups(struct thermal_zone_device *);
void thermal_cooling_device_setup_sysfs(struct thermal_cooling_device *); void thermal_cooling_device_setup_sysfs(struct thermal_cooling_device *);
void thermal_cooling_device_destroy_sysfs(struct thermal_cooling_device *cdev); void thermal_cooling_device_destroy_sysfs(struct thermal_cooling_device *cdev);
......
...@@ -26,8 +26,8 @@ int get_tz_trend(struct thermal_zone_device *tz, const struct thermal_trip *trip ...@@ -26,8 +26,8 @@ int get_tz_trend(struct thermal_zone_device *tz, const struct thermal_trip *trip
{ {
enum thermal_trend trend; enum thermal_trend trend;
if (tz->emul_temperature || !tz->ops->get_trend || if (tz->emul_temperature || !tz->ops.get_trend ||
tz->ops->get_trend(tz, trip, &trend)) { tz->ops.get_trend(tz, trip, &trend)) {
if (tz->temperature > tz->last_temperature) if (tz->temperature > tz->last_temperature)
trend = THERMAL_TREND_RAISING; trend = THERMAL_TREND_RAISING;
else if (tz->temperature < tz->last_temperature) else if (tz->temperature < tz->last_temperature)
...@@ -75,7 +75,7 @@ EXPORT_SYMBOL(get_thermal_instance); ...@@ -75,7 +75,7 @@ EXPORT_SYMBOL(get_thermal_instance);
* temperature and fill @temp. * temperature and fill @temp.
* *
* Both tz and tz->ops must be valid pointers when calling this function, * Both tz and tz->ops must be valid pointers when calling this function,
* and the tz->ops->get_temp callback must be provided. * and the tz->ops.get_temp callback must be provided.
* The function must be called under tz->lock. * The function must be called under tz->lock.
* *
* Return: On success returns 0, an error code otherwise * Return: On success returns 0, an error code otherwise
...@@ -88,7 +88,7 @@ int __thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp) ...@@ -88,7 +88,7 @@ int __thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
lockdep_assert_held(&tz->lock); lockdep_assert_held(&tz->lock);
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(tz, trip) {
...@@ -132,7 +132,7 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp) ...@@ -132,7 +132,7 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
mutex_lock(&tz->lock); mutex_lock(&tz->lock);
if (!tz->ops->get_temp) { if (!tz->ops.get_temp) {
ret = -EINVAL; ret = -EINVAL;
goto unlock; goto unlock;
} }
......
...@@ -80,7 +80,7 @@ temp_crit_show(struct device *dev, struct device_attribute *attr, char *buf) ...@@ -80,7 +80,7 @@ temp_crit_show(struct device *dev, struct device_attribute *attr, char *buf)
mutex_lock(&tz->lock); mutex_lock(&tz->lock);
ret = tz->ops->get_crit_temp(tz, &temperature); ret = tz->ops.get_crit_temp(tz, &temperature);
mutex_unlock(&tz->lock); mutex_unlock(&tz->lock);
...@@ -132,7 +132,7 @@ thermal_hwmon_lookup_temp(const struct thermal_hwmon_device *hwmon, ...@@ -132,7 +132,7 @@ thermal_hwmon_lookup_temp(const struct thermal_hwmon_device *hwmon,
static bool thermal_zone_crit_temp_valid(struct thermal_zone_device *tz) static bool thermal_zone_crit_temp_valid(struct thermal_zone_device *tz)
{ {
int temp; int temp;
return tz->ops->get_crit_temp && !tz->ops->get_crit_temp(tz, &temp); return tz->ops.get_crit_temp && !tz->ops.get_crit_temp(tz, &temp);
} }
int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz) int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
......
...@@ -117,6 +117,8 @@ static int thermal_of_populate_trip(struct device_node *np, ...@@ -117,6 +117,8 @@ static int thermal_of_populate_trip(struct device_node *np,
return ret; return ret;
} }
trip->flags = THERMAL_TRIP_FLAG_RW_TEMP;
return 0; return 0;
} }
...@@ -438,13 +440,8 @@ static int thermal_of_unbind(struct thermal_zone_device *tz, ...@@ -438,13 +440,8 @@ static int thermal_of_unbind(struct thermal_zone_device *tz,
*/ */
static void thermal_of_zone_unregister(struct thermal_zone_device *tz) static void thermal_of_zone_unregister(struct thermal_zone_device *tz)
{ {
struct thermal_trip *trips = tz->trips;
struct thermal_zone_device_ops *ops = tz->ops;
thermal_zone_device_disable(tz); thermal_zone_device_disable(tz);
thermal_zone_device_unregister(tz); thermal_zone_device_unregister(tz);
kfree(trips);
kfree(ops);
} }
/** /**
...@@ -470,33 +467,27 @@ static void thermal_of_zone_unregister(struct thermal_zone_device *tz) ...@@ -470,33 +467,27 @@ static void thermal_of_zone_unregister(struct thermal_zone_device *tz)
static struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, int id, void *data, static struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, int id, void *data,
const struct thermal_zone_device_ops *ops) const struct thermal_zone_device_ops *ops)
{ {
struct thermal_zone_device_ops of_ops = *ops;
struct thermal_zone_device *tz; struct thermal_zone_device *tz;
struct thermal_trip *trips; struct thermal_trip *trips;
struct thermal_zone_params tzp = {}; struct thermal_zone_params tzp = {};
struct thermal_zone_device_ops *of_ops;
struct device_node *np; struct device_node *np;
const char *action; const char *action;
int delay, pdelay; int delay, pdelay;
int ntrips, mask; int ntrips;
int ret; int ret;
of_ops = kmemdup(ops, sizeof(*ops), GFP_KERNEL);
if (!of_ops)
return ERR_PTR(-ENOMEM);
np = of_thermal_zone_find(sensor, id); np = of_thermal_zone_find(sensor, id);
if (IS_ERR(np)) { if (IS_ERR(np)) {
if (PTR_ERR(np) != -ENODEV) if (PTR_ERR(np) != -ENODEV)
pr_err("Failed to find thermal zone for %pOFn id=%d\n", sensor, id); pr_err("Failed to find thermal zone for %pOFn id=%d\n", sensor, id);
ret = PTR_ERR(np); return ERR_CAST(np);
goto out_kfree_of_ops;
} }
trips = thermal_of_trips_init(np, &ntrips); trips = thermal_of_trips_init(np, &ntrips);
if (IS_ERR(trips)) { if (IS_ERR(trips)) {
pr_err("Failed to find trip points for %pOFn id=%d\n", sensor, id); pr_err("Failed to find trip points for %pOFn id=%d\n", sensor, id);
ret = PTR_ERR(trips); return ERR_CAST(trips);
goto out_kfree_of_ops;
} }
ret = thermal_of_monitor_init(np, &delay, &pdelay); ret = thermal_of_monitor_init(np, &delay, &pdelay);
...@@ -507,18 +498,16 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node * ...@@ -507,18 +498,16 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node *
thermal_of_parameters_init(np, &tzp); thermal_of_parameters_init(np, &tzp);
of_ops->bind = thermal_of_bind; of_ops.bind = thermal_of_bind;
of_ops->unbind = thermal_of_unbind; of_ops.unbind = thermal_of_unbind;
mask = GENMASK_ULL((ntrips) - 1, 0);
ret = of_property_read_string(np, "critical-action", &action); ret = of_property_read_string(np, "critical-action", &action);
if (!ret) if (!ret)
if (!of_ops->critical && !strcasecmp(action, "reboot")) if (!of_ops.critical && !strcasecmp(action, "reboot"))
of_ops->critical = thermal_zone_device_critical_reboot; of_ops.critical = thermal_zone_device_critical_reboot;
tz = thermal_zone_device_register_with_trips(np->name, trips, ntrips, tz = thermal_zone_device_register_with_trips(np->name, trips, ntrips,
mask, data, of_ops, &tzp, data, &of_ops, &tzp,
pdelay, delay); pdelay, delay);
if (IS_ERR(tz)) { if (IS_ERR(tz)) {
ret = PTR_ERR(tz); ret = PTR_ERR(tz);
...@@ -526,6 +515,8 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node * ...@@ -526,6 +515,8 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node *
goto out_kfree_trips; goto out_kfree_trips;
} }
kfree(trips);
ret = thermal_zone_device_enable(tz); ret = thermal_zone_device_enable(tz);
if (ret) { if (ret) {
pr_err("Failed to enabled thermal zone '%s', id=%d: %d\n", pr_err("Failed to enabled thermal zone '%s', id=%d: %d\n",
...@@ -538,8 +529,6 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node * ...@@ -538,8 +529,6 @@ static struct thermal_zone_device *thermal_of_zone_register(struct device_node *
out_kfree_trips: out_kfree_trips:
kfree(trips); kfree(trips);
out_kfree_of_ops:
kfree(of_ops);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
......
...@@ -123,8 +123,8 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr, ...@@ -123,8 +123,8 @@ trip_point_temp_store(struct device *dev, struct device_attribute *attr,
trip = &tz->trips[trip_id]; trip = &tz->trips[trip_id];
if (temp != trip->temperature) { if (temp != trip->temperature) {
if (tz->ops->set_trip_temp) { if (tz->ops.set_trip_temp) {
ret = tz->ops->set_trip_temp(tz, trip_id, temp); ret = tz->ops.set_trip_temp(tz, trip_id, temp);
if (ret) if (ret)
goto unlock; goto unlock;
} }
...@@ -174,18 +174,11 @@ trip_point_hyst_store(struct device *dev, struct device_attribute *attr, ...@@ -174,18 +174,11 @@ trip_point_hyst_store(struct device *dev, struct device_attribute *attr,
trip = &tz->trips[trip_id]; trip = &tz->trips[trip_id];
if (hyst != trip->hysteresis) { if (hyst != trip->hysteresis) {
if (tz->ops->set_trip_hyst) {
ret = tz->ops->set_trip_hyst(tz, trip_id, hyst);
if (ret)
goto unlock;
}
trip->hysteresis = hyst; trip->hysteresis = hyst;
thermal_zone_trip_updated(tz, trip); thermal_zone_trip_updated(tz, trip);
} }
unlock:
mutex_unlock(&tz->lock); mutex_unlock(&tz->lock);
return ret ? ret : count; return ret ? ret : count;
...@@ -250,10 +243,10 @@ emul_temp_store(struct device *dev, struct device_attribute *attr, ...@@ -250,10 +243,10 @@ emul_temp_store(struct device *dev, struct device_attribute *attr,
mutex_lock(&tz->lock); mutex_lock(&tz->lock);
if (!tz->ops->set_emul_temp) if (!tz->ops.set_emul_temp)
tz->emul_temperature = temperature; tz->emul_temperature = temperature;
else else
ret = tz->ops->set_emul_temp(tz, temperature); ret = tz->ops.set_emul_temp(tz, temperature);
if (!ret) if (!ret)
__thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED); __thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
...@@ -392,17 +385,16 @@ static const struct attribute_group *thermal_zone_attribute_groups[] = { ...@@ -392,17 +385,16 @@ static const struct attribute_group *thermal_zone_attribute_groups[] = {
/** /**
* create_trip_attrs() - create attributes for trip points * create_trip_attrs() - create attributes for trip points
* @tz: the thermal zone device * @tz: the thermal zone device
* @mask: Writeable trip point bitmap.
* *
* helper function to instantiate sysfs entries for every trip * helper function to instantiate sysfs entries for every trip
* point and its properties of a struct thermal_zone_device. * point and its properties of a struct thermal_zone_device.
* *
* Return: 0 on success, the proper error value otherwise. * Return: 0 on success, the proper error value otherwise.
*/ */
static int create_trip_attrs(struct thermal_zone_device *tz, int mask) static int create_trip_attrs(struct thermal_zone_device *tz)
{ {
const struct thermal_trip *trip;
struct attribute **attrs; struct attribute **attrs;
int indx;
/* This function works only for zones with at least one trip */ /* This function works only for zones with at least one trip */
if (tz->num_trips <= 0) if (tz->num_trips <= 0)
...@@ -437,7 +429,9 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) ...@@ -437,7 +429,9 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask)
return -ENOMEM; return -ENOMEM;
} }
for (indx = 0; indx < tz->num_trips; indx++) { for_each_trip(tz, trip) {
int indx = thermal_zone_trip_id(tz, 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,
"trip_point_%d_type", indx); "trip_point_%d_type", indx);
...@@ -458,8 +452,7 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) ...@@ -458,8 +452,7 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask)
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 (IS_ENABLED(CONFIG_THERMAL_WRITABLE_TRIPS) && if (trip->flags & THERMAL_TRIP_FLAG_RW_TEMP) {
mask & (1 << indx)) {
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;
...@@ -474,7 +467,7 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) ...@@ -474,7 +467,7 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask)
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 (tz->ops->set_trip_hyst) { if (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;
...@@ -506,8 +499,7 @@ static void destroy_trip_attrs(struct thermal_zone_device *tz) ...@@ -506,8 +499,7 @@ static void destroy_trip_attrs(struct thermal_zone_device *tz)
kfree(tz->trips_attribute_group.attrs); kfree(tz->trips_attribute_group.attrs);
} }
int thermal_zone_create_device_groups(struct thermal_zone_device *tz, int thermal_zone_create_device_groups(struct thermal_zone_device *tz)
int mask)
{ {
const struct attribute_group **groups; const struct attribute_group **groups;
int i, size, result; int i, size, result;
...@@ -523,7 +515,7 @@ int thermal_zone_create_device_groups(struct thermal_zone_device *tz, ...@@ -523,7 +515,7 @@ int thermal_zone_create_device_groups(struct thermal_zone_device *tz,
groups[i] = thermal_zone_attribute_groups[i]; groups[i] = thermal_zone_attribute_groups[i];
if (tz->num_trips) { if (tz->num_trips) {
result = create_trip_attrs(tz, mask); result = create_trip_attrs(tz);
if (result) { if (result) {
kfree(groups); kfree(groups);
......
...@@ -70,7 +70,7 @@ void __thermal_zone_set_trips(struct thermal_zone_device *tz) ...@@ -70,7 +70,7 @@ void __thermal_zone_set_trips(struct thermal_zone_device *tz)
lockdep_assert_held(&tz->lock); lockdep_assert_held(&tz->lock);
if (!tz->ops->set_trips) if (!tz->ops.set_trips)
return; return;
for_each_trip(tz, trip) { for_each_trip(tz, trip) {
...@@ -114,7 +114,7 @@ void __thermal_zone_set_trips(struct thermal_zone_device *tz) ...@@ -114,7 +114,7 @@ void __thermal_zone_set_trips(struct thermal_zone_device *tz)
* Set a temperature window. When this window is left the driver * Set a temperature window. When this window is left the driver
* must inform the thermal core via thermal_zone_device_update. * must inform the thermal core via thermal_zone_device_update.
*/ */
ret = tz->ops->set_trips(tz, low, high); ret = tz->ops.set_trips(tz, low, high);
if (ret) if (ret)
dev_err(&tz->device, "Failed to set trips: %d\n", ret); dev_err(&tz->device, "Failed to set trips: %d\n", ret);
} }
...@@ -122,7 +122,7 @@ void __thermal_zone_set_trips(struct thermal_zone_device *tz) ...@@ -122,7 +122,7 @@ void __thermal_zone_set_trips(struct thermal_zone_device *tz)
int __thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id, int __thermal_zone_get_trip(struct thermal_zone_device *tz, int trip_id,
struct thermal_trip *trip) struct thermal_trip *trip)
{ {
if (!tz || !tz->trips || 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];
......
...@@ -64,15 +64,23 @@ enum thermal_notify_event { ...@@ -64,15 +64,23 @@ enum thermal_notify_event {
* @threshold: trip crossing notification threshold 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
*/ */
struct thermal_trip { struct thermal_trip {
int temperature; int temperature;
int hysteresis; int hysteresis;
int threshold; int threshold;
enum thermal_trip_type type; enum thermal_trip_type type;
u8 flags;
void *priv; void *priv;
}; };
#define THERMAL_TRIP_FLAG_RW_TEMP BIT(0)
#define THERMAL_TRIP_FLAG_RW_HYST BIT(1)
#define THERMAL_TRIP_FLAG_RW (THERMAL_TRIP_FLAG_RW_TEMP | \
THERMAL_TRIP_FLAG_RW_HYST)
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 *);
...@@ -83,7 +91,6 @@ struct thermal_zone_device_ops { ...@@ -83,7 +91,6 @@ struct thermal_zone_device_ops {
int (*change_mode) (struct thermal_zone_device *, int (*change_mode) (struct thermal_zone_device *,
enum thermal_device_mode); enum thermal_device_mode);
int (*set_trip_temp) (struct thermal_zone_device *, int, int); int (*set_trip_temp) (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 (*get_trend) (struct thermal_zone_device *,
...@@ -130,7 +137,6 @@ struct thermal_cooling_device { ...@@ -130,7 +137,6 @@ struct thermal_cooling_device {
* @trip_hyst_attrs: attributes for trip points for sysfs: trip hysteresis * @trip_hyst_attrs: attributes for trip points for sysfs: trip hysteresis
* @mode: current mode of this thermal zone * @mode: current mode of this thermal zone
* @devdata: private pointer for device private data * @devdata: private pointer for device private data
* @trips: an array of struct thermal_trip
* @num_trips: number of trip points the thermal zone supports * @num_trips: number of trip points the thermal zone supports
* @passive_delay_jiffies: number of jiffies to wait between polls when * @passive_delay_jiffies: number of jiffies to wait between polls when
* performing passive cooling. * performing passive cooling.
...@@ -160,6 +166,7 @@ struct thermal_cooling_device { ...@@ -160,6 +166,7 @@ struct thermal_cooling_device {
* @poll_queue: delayed work for polling * @poll_queue: delayed work for polling
* @notify_event: Last notification event * @notify_event: Last notification event
* @suspended: thermal zone suspend indicator * @suspended: thermal zone suspend indicator
* @trips: array of struct thermal_trip objects
*/ */
struct thermal_zone_device { struct thermal_zone_device {
int id; int id;
...@@ -172,7 +179,6 @@ struct thermal_zone_device { ...@@ -172,7 +179,6 @@ struct thermal_zone_device {
struct thermal_attr *trip_hyst_attrs; struct thermal_attr *trip_hyst_attrs;
enum thermal_device_mode mode; enum thermal_device_mode mode;
void *devdata; void *devdata;
struct thermal_trip *trips;
int num_trips; int num_trips;
unsigned long passive_delay_jiffies; unsigned long passive_delay_jiffies;
unsigned long polling_delay_jiffies; unsigned long polling_delay_jiffies;
...@@ -183,7 +189,7 @@ struct thermal_zone_device { ...@@ -183,7 +189,7 @@ struct thermal_zone_device {
int prev_low_trip; int prev_low_trip;
int prev_high_trip; int prev_high_trip;
atomic_t need_update; atomic_t need_update;
struct thermal_zone_device_ops *ops; struct thermal_zone_device_ops ops;
struct thermal_zone_params *tzp; struct thermal_zone_params *tzp;
struct thermal_governor *governor; struct thermal_governor *governor;
void *governor_data; void *governor_data;
...@@ -193,10 +199,11 @@ struct thermal_zone_device { ...@@ -193,10 +199,11 @@ struct thermal_zone_device {
struct list_head node; struct list_head node;
struct delayed_work poll_queue; struct delayed_work poll_queue;
enum thermal_notify_event notify_event; enum thermal_notify_event notify_event;
bool suspended;
#ifdef CONFIG_THERMAL_DEBUGFS #ifdef CONFIG_THERMAL_DEBUGFS
struct thermal_debugfs *debugfs; struct thermal_debugfs *debugfs;
#endif #endif
bool suspended; struct thermal_trip trips[] __counted_by(num_trips);
}; };
/** /**
...@@ -315,17 +322,16 @@ int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp); ...@@ -315,17 +322,16 @@ int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp);
#ifdef CONFIG_THERMAL #ifdef CONFIG_THERMAL
struct thermal_zone_device *thermal_zone_device_register_with_trips( struct thermal_zone_device *thermal_zone_device_register_with_trips(
const char *type, const char *type,
struct thermal_trip *trips, const struct thermal_trip *trips,
int num_trips, int mask, int num_trips, void *devdata,
void *devdata, const struct thermal_zone_device_ops *ops,
struct thermal_zone_device_ops *ops,
const struct thermal_zone_params *tzp, const struct thermal_zone_params *tzp,
int passive_delay, int polling_delay); int passive_delay, int polling_delay);
struct thermal_zone_device *thermal_tripless_zone_device_register( struct thermal_zone_device *thermal_tripless_zone_device_register(
const char *type, const char *type,
void *devdata, void *devdata,
struct thermal_zone_device_ops *ops, const struct thermal_zone_device_ops *ops,
const struct thermal_zone_params *tzp); const struct thermal_zone_params *tzp);
void thermal_zone_device_unregister(struct thermal_zone_device *tz); void thermal_zone_device_unregister(struct thermal_zone_device *tz);
...@@ -375,10 +381,9 @@ void thermal_zone_device_critical(struct thermal_zone_device *tz); ...@@ -375,10 +381,9 @@ void thermal_zone_device_critical(struct thermal_zone_device *tz);
#else #else
static inline struct thermal_zone_device *thermal_zone_device_register_with_trips( static inline struct thermal_zone_device *thermal_zone_device_register_with_trips(
const char *type, const char *type,
struct thermal_trip *trips, const struct thermal_trip *trips,
int num_trips, int mask, int num_trips, void *devdata,
void *devdata, const struct thermal_zone_device_ops *ops,
struct thermal_zone_device_ops *ops,
const struct thermal_zone_params *tzp, const struct thermal_zone_params *tzp,
int passive_delay, int polling_delay) int passive_delay, int polling_delay)
{ return ERR_PTR(-ENODEV); } { return ERR_PTR(-ENODEV); }
......
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