Commit e5bfcd30 authored by Daniel Lezcano's avatar Daniel Lezcano Committed by Daniel Lezcano

thermal/core: Rename 'trips' to 'num_trips'

In order to use thermal trips defined in the thermal structure, rename
the 'trips' field to 'num_trips' to have the 'trips' field containing the
thermal trip points.

Cc: Alexandre Bailon <abailon@baylibre.com>
Cc: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linexp.org>
Link: https://lore.kernel.org/r/20220722200007.1839356-8-daniel.lezcano@linexp.orgSigned-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
parent e5f2cda6
...@@ -25,10 +25,10 @@ static int get_trip_level(struct thermal_zone_device *tz) ...@@ -25,10 +25,10 @@ static int get_trip_level(struct thermal_zone_device *tz)
int trip_temp; int trip_temp;
enum thermal_trip_type trip_type; enum thermal_trip_type trip_type;
if (tz->trips == 0 || !tz->ops->get_trip_temp) if (tz->num_trips == 0 || !tz->ops->get_trip_temp)
return 0; return 0;
for (count = 0; count < tz->trips; count++) { for (count = 0; count < tz->num_trips; count++) {
tz->ops->get_trip_temp(tz, count, &trip_temp); tz->ops->get_trip_temp(tz, count, &trip_temp);
if (tz->temperature < trip_temp) if (tz->temperature < trip_temp)
break; break;
...@@ -53,7 +53,7 @@ static long get_target_state(struct thermal_zone_device *tz, ...@@ -53,7 +53,7 @@ static long get_target_state(struct thermal_zone_device *tz,
cdev->ops->get_max_state(cdev, &max_state); cdev->ops->get_max_state(cdev, &max_state);
return (long)(percentage * level * max_state) / (100 * tz->trips); return (long)(percentage * level * max_state) / (100 * tz->num_trips);
} }
/** /**
......
...@@ -527,7 +527,7 @@ static void get_governor_trips(struct thermal_zone_device *tz, ...@@ -527,7 +527,7 @@ static void get_governor_trips(struct thermal_zone_device *tz,
last_active = INVALID_TRIP; last_active = INVALID_TRIP;
last_passive = INVALID_TRIP; last_passive = INVALID_TRIP;
for (i = 0; i < tz->trips; i++) { for (i = 0; i < tz->num_trips; i++) {
enum thermal_trip_type type; enum thermal_trip_type type;
int ret; int ret;
...@@ -668,7 +668,7 @@ static int power_allocator_bind(struct thermal_zone_device *tz) ...@@ -668,7 +668,7 @@ static int power_allocator_bind(struct thermal_zone_device *tz)
get_governor_trips(tz, params); get_governor_trips(tz, params);
if (tz->trips > 0) { if (tz->num_trips > 0) {
ret = tz->ops->get_trip_temp(tz, ret = tz->ops->get_trip_temp(tz,
params->trip_max_desired_temperature, params->trip_max_desired_temperature,
&control_temp); &control_temp);
......
...@@ -316,7 +316,7 @@ static void tegra_tsensor_get_hw_channel_trips(struct thermal_zone_device *tzd, ...@@ -316,7 +316,7 @@ static void tegra_tsensor_get_hw_channel_trips(struct thermal_zone_device *tzd,
*hot_trip = 85000; *hot_trip = 85000;
*crit_trip = 90000; *crit_trip = 90000;
for (i = 0; i < tzd->trips; i++) { for (i = 0; i < tzd->num_trips; i++) {
enum thermal_trip_type type; enum thermal_trip_type type;
int trip_temp; int trip_temp;
......
...@@ -501,7 +501,7 @@ void thermal_zone_device_update(struct thermal_zone_device *tz, ...@@ -501,7 +501,7 @@ void thermal_zone_device_update(struct thermal_zone_device *tz,
tz->notify_event = event; tz->notify_event = event;
for (count = 0; count < tz->trips; count++) for (count = 0; count < tz->num_trips; count++)
handle_thermal_trip(tz, count); handle_thermal_trip(tz, count);
} }
EXPORT_SYMBOL_GPL(thermal_zone_device_update); EXPORT_SYMBOL_GPL(thermal_zone_device_update);
...@@ -626,7 +626,7 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz, ...@@ -626,7 +626,7 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
unsigned long max_state; unsigned long max_state;
int result, ret; int result, ret;
if (trip >= tz->trips || trip < 0) if (trip >= tz->num_trips || trip < 0)
return -EINVAL; return -EINVAL;
list_for_each_entry(pos1, &thermal_tz_list, node) { list_for_each_entry(pos1, &thermal_tz_list, node) {
...@@ -807,7 +807,7 @@ static void __bind(struct thermal_zone_device *tz, int mask, ...@@ -807,7 +807,7 @@ static void __bind(struct thermal_zone_device *tz, int mask,
{ {
int i, ret; int i, ret;
for (i = 0; i < tz->trips; i++) { for (i = 0; i < tz->num_trips; i++) {
if (mask & (1 << i)) { if (mask & (1 << i)) {
unsigned long upper, lower; unsigned long upper, lower;
...@@ -1053,7 +1053,7 @@ static void __unbind(struct thermal_zone_device *tz, int mask, ...@@ -1053,7 +1053,7 @@ static void __unbind(struct thermal_zone_device *tz, int mask,
{ {
int i; int i;
for (i = 0; i < tz->trips; i++) for (i = 0; i < tz->num_trips; i++)
if (mask & (1 << i)) if (mask & (1 << i))
thermal_zone_unbind_cooling_device(tz, i, cdev); thermal_zone_unbind_cooling_device(tz, i, cdev);
} }
...@@ -1165,7 +1165,7 @@ static void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms ...@@ -1165,7 +1165,7 @@ static void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms
/** /**
* thermal_zone_device_register() - register a new thermal zone device * thermal_zone_device_register() - register a new thermal zone device
* @type: the thermal zone device type * @type: the thermal zone device type
* @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 * @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
...@@ -1187,7 +1187,7 @@ static void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms ...@@ -1187,7 +1187,7 @@ static void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms
* IS_ERR*() helpers. * IS_ERR*() helpers.
*/ */
struct thermal_zone_device * struct thermal_zone_device *
thermal_zone_device_register(const char *type, int trips, int mask, thermal_zone_device_register(const char *type, int num_trips, int mask,
void *devdata, struct thermal_zone_device_ops *ops, void *devdata, struct thermal_zone_device_ops *ops,
struct thermal_zone_params *tzp, int passive_delay, struct thermal_zone_params *tzp, int passive_delay,
int polling_delay) int polling_delay)
...@@ -1211,7 +1211,7 @@ thermal_zone_device_register(const char *type, int trips, int mask, ...@@ -1211,7 +1211,7 @@ thermal_zone_device_register(const char *type, int trips, int mask,
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
if (trips > THERMAL_MAX_TRIPS || trips < 0 || mask >> trips) { if (num_trips > THERMAL_MAX_TRIPS || 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);
} }
...@@ -1221,7 +1221,7 @@ thermal_zone_device_register(const char *type, int trips, int mask, ...@@ -1221,7 +1221,7 @@ thermal_zone_device_register(const char *type, int trips, int mask,
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
if (trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp)) if (num_trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp))
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
tz = kzalloc(sizeof(*tz), GFP_KERNEL); tz = kzalloc(sizeof(*tz), GFP_KERNEL);
...@@ -1251,7 +1251,7 @@ thermal_zone_device_register(const char *type, int trips, int mask, ...@@ -1251,7 +1251,7 @@ thermal_zone_device_register(const char *type, int trips, int mask,
tz->tzp = tzp; tz->tzp = tzp;
tz->device.class = &thermal_class; tz->device.class = &thermal_class;
tz->devdata = devdata; tz->devdata = devdata;
tz->trips = trips; tz->num_trips = num_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);
...@@ -1269,7 +1269,7 @@ thermal_zone_device_register(const char *type, int trips, int mask, ...@@ -1269,7 +1269,7 @@ thermal_zone_device_register(const char *type, int trips, int mask,
if (result) if (result)
goto release_device; goto release_device;
for (count = 0; count < trips; count++) { for (count = 0; count < num_trips; count++) {
if (tz->ops->get_trip_type(tz, count, &trip_type) || if (tz->ops->get_trip_type(tz, count, &trip_type) ||
tz->ops->get_trip_temp(tz, count, &trip_temp) || tz->ops->get_trip_temp(tz, count, &trip_temp) ||
!trip_temp) !trip_temp)
......
...@@ -89,7 +89,7 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp) ...@@ -89,7 +89,7 @@ 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 (count = 0; count < tz->trips; count++) { for (count = 0; count < tz->num_trips; count++) {
ret = tz->ops->get_trip_type(tz, count, &type); ret = tz->ops->get_trip_type(tz, count, &type);
if (!ret && type == THERMAL_TRIP_CRITICAL) { if (!ret && type == THERMAL_TRIP_CRITICAL) {
ret = tz->ops->get_trip_temp(tz, count, ret = tz->ops->get_trip_temp(tz, count,
...@@ -137,7 +137,7 @@ void thermal_zone_set_trips(struct thermal_zone_device *tz) ...@@ -137,7 +137,7 @@ void thermal_zone_set_trips(struct thermal_zone_device *tz)
if (!tz->ops->set_trips || !tz->ops->get_trip_hyst) if (!tz->ops->set_trips || !tz->ops->get_trip_hyst)
goto exit; goto exit;
for (i = 0; i < tz->trips; i++) { for (i = 0; i < tz->num_trips; i++) {
int trip_low; int trip_low;
tz->ops->get_trip_temp(tz, i, &trip_temp); tz->ops->get_trip_temp(tz, i, &trip_temp);
......
...@@ -469,7 +469,7 @@ static int thermal_genl_cmd_tz_get_trip(struct param *p) ...@@ -469,7 +469,7 @@ static int thermal_genl_cmd_tz_get_trip(struct param *p)
mutex_lock(&tz->lock); mutex_lock(&tz->lock);
for (i = 0; i < tz->trips; i++) { for (i = 0; i < tz->num_trips; i++) {
enum thermal_trip_type type; enum thermal_trip_type type;
int temp, hyst = 0; int temp, hyst = 0;
......
...@@ -416,15 +416,15 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) ...@@ -416,15 +416,15 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask)
int indx; 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->trips <= 0) if (tz->num_trips <= 0)
return -EINVAL; return -EINVAL;
tz->trip_type_attrs = kcalloc(tz->trips, sizeof(*tz->trip_type_attrs), tz->trip_type_attrs = kcalloc(tz->num_trips, sizeof(*tz->trip_type_attrs),
GFP_KERNEL); GFP_KERNEL);
if (!tz->trip_type_attrs) if (!tz->trip_type_attrs)
return -ENOMEM; return -ENOMEM;
tz->trip_temp_attrs = kcalloc(tz->trips, sizeof(*tz->trip_temp_attrs), tz->trip_temp_attrs = kcalloc(tz->num_trips, sizeof(*tz->trip_temp_attrs),
GFP_KERNEL); GFP_KERNEL);
if (!tz->trip_temp_attrs) { if (!tz->trip_temp_attrs) {
kfree(tz->trip_type_attrs); kfree(tz->trip_type_attrs);
...@@ -432,7 +432,7 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) ...@@ -432,7 +432,7 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask)
} }
if (tz->ops->get_trip_hyst) { if (tz->ops->get_trip_hyst) {
tz->trip_hyst_attrs = kcalloc(tz->trips, tz->trip_hyst_attrs = kcalloc(tz->num_trips,
sizeof(*tz->trip_hyst_attrs), sizeof(*tz->trip_hyst_attrs),
GFP_KERNEL); GFP_KERNEL);
if (!tz->trip_hyst_attrs) { if (!tz->trip_hyst_attrs) {
...@@ -442,7 +442,7 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) ...@@ -442,7 +442,7 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask)
} }
} }
attrs = kcalloc(tz->trips * 3 + 1, sizeof(*attrs), GFP_KERNEL); attrs = kcalloc(tz->num_trips * 3 + 1, sizeof(*attrs), GFP_KERNEL);
if (!attrs) { if (!attrs) {
kfree(tz->trip_type_attrs); kfree(tz->trip_type_attrs);
kfree(tz->trip_temp_attrs); kfree(tz->trip_temp_attrs);
...@@ -451,7 +451,7 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) ...@@ -451,7 +451,7 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask)
return -ENOMEM; return -ENOMEM;
} }
for (indx = 0; indx < tz->trips; indx++) { for (indx = 0; indx < tz->num_trips; indx++) {
/* 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);
...@@ -478,7 +478,7 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) ...@@ -478,7 +478,7 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask)
tz->trip_temp_attrs[indx].attr.store = tz->trip_temp_attrs[indx].attr.store =
trip_point_temp_store; trip_point_temp_store;
} }
attrs[indx + tz->trips] = &tz->trip_temp_attrs[indx].attr.attr; attrs[indx + tz->num_trips] = &tz->trip_temp_attrs[indx].attr.attr;
/* create Optional trip hyst attribute */ /* create Optional trip hyst attribute */
if (!tz->ops->get_trip_hyst) if (!tz->ops->get_trip_hyst)
...@@ -496,10 +496,10 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask) ...@@ -496,10 +496,10 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask)
tz->trip_hyst_attrs[indx].attr.store = tz->trip_hyst_attrs[indx].attr.store =
trip_point_hyst_store; trip_point_hyst_store;
} }
attrs[indx + tz->trips * 2] = attrs[indx + tz->num_trips * 2] =
&tz->trip_hyst_attrs[indx].attr.attr; &tz->trip_hyst_attrs[indx].attr.attr;
} }
attrs[tz->trips * 3] = NULL; attrs[tz->num_trips * 3] = NULL;
tz->trips_attribute_group.attrs = attrs; tz->trips_attribute_group.attrs = attrs;
...@@ -540,7 +540,7 @@ int thermal_zone_create_device_groups(struct thermal_zone_device *tz, ...@@ -540,7 +540,7 @@ int thermal_zone_create_device_groups(struct thermal_zone_device *tz,
for (i = 0; i < size - 2; i++) for (i = 0; i < size - 2; i++)
groups[i] = thermal_zone_attribute_groups[i]; groups[i] = thermal_zone_attribute_groups[i];
if (tz->trips) { if (tz->num_trips) {
result = create_trip_attrs(tz, mask); result = create_trip_attrs(tz, mask);
if (result) { if (result) {
kfree(groups); kfree(groups);
...@@ -561,7 +561,7 @@ void thermal_zone_destroy_device_groups(struct thermal_zone_device *tz) ...@@ -561,7 +561,7 @@ void thermal_zone_destroy_device_groups(struct thermal_zone_device *tz)
if (!tz) if (!tz)
return; return;
if (tz->trips) if (tz->num_trips)
destroy_trip_attrs(tz); destroy_trip_attrs(tz);
kfree(tz->device.groups); kfree(tz->device.groups);
......
...@@ -123,7 +123,7 @@ struct thermal_cooling_device { ...@@ -123,7 +123,7 @@ 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: number of trip points the thermal zone supports * @num_trips: number of trip points the thermal zone supports
* @trips_disabled; bitmap for disabled trips * @trips_disabled; bitmap for disabled trips
* @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.
...@@ -163,7 +163,7 @@ struct thermal_zone_device { ...@@ -163,7 +163,7 @@ 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;
int trips; int num_trips;
unsigned long trips_disabled; /* bitmap for disabled trips */ unsigned long trips_disabled; /* bitmap for disabled trips */
unsigned long passive_delay_jiffies; unsigned long passive_delay_jiffies;
unsigned long polling_delay_jiffies; unsigned long polling_delay_jiffies;
......
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