Commit 735a968d authored by Daniel Lezcano's avatar Daniel Lezcano Committed by Daniel Lezcano

thermal/drivers/tegra: Use generic thermal_zone_get_trip() function

Replace a single call to thermal_zone_get_trip() to get a trip point
instead of calling the different ops->get_trip*
Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20221003092602.1323944-11-daniel.lezcano@linaro.org
parent 03ef4855
...@@ -582,23 +582,23 @@ static int tsensor_group_thermtrip_get(struct tegra_soctherm *ts, int id) ...@@ -582,23 +582,23 @@ static int tsensor_group_thermtrip_get(struct tegra_soctherm *ts, int id)
return temp; return temp;
} }
static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, int trip, int temp) static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, int trip_id, int temp)
{ {
struct tegra_thermctl_zone *zone = tz->devdata; struct tegra_thermctl_zone *zone = tz->devdata;
struct tegra_soctherm *ts = zone->ts; struct tegra_soctherm *ts = zone->ts;
struct thermal_trip trip;
const struct tegra_tsensor_group *sg = zone->sg; const struct tegra_tsensor_group *sg = zone->sg;
struct device *dev = zone->dev; struct device *dev = zone->dev;
enum thermal_trip_type type;
int ret; int ret;
if (!tz) if (!tz)
return -EINVAL; return -EINVAL;
ret = tz->ops->get_trip_type(tz, trip, &type); ret = thermal_zone_get_trip(tz, trip_id, &trip);
if (ret) if (ret)
return ret; return ret;
if (type == THERMAL_TRIP_CRITICAL) { if (trip.type == THERMAL_TRIP_CRITICAL) {
/* /*
* If thermtrips property is set in DT, * If thermtrips property is set in DT,
* doesn't need to program critical type trip to HW, * doesn't need to program critical type trip to HW,
...@@ -609,7 +609,7 @@ static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, int trip ...@@ -609,7 +609,7 @@ static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, int trip
else else
return 0; return 0;
} else if (type == THERMAL_TRIP_HOT) { } else if (trip.type == THERMAL_TRIP_HOT) {
int i; int i;
for (i = 0; i < THROTTLE_SIZE; i++) { for (i = 0; i < THROTTLE_SIZE; i++) {
...@@ -620,7 +620,7 @@ static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, int trip ...@@ -620,7 +620,7 @@ static int tegra_thermctl_set_trip_temp(struct thermal_zone_device *tz, int trip
continue; continue;
cdev = ts->throt_cfgs[i].cdev; cdev = ts->throt_cfgs[i].cdev;
if (get_thermal_instance(tz, cdev, trip)) if (get_thermal_instance(tz, cdev, trip_id))
stc = find_throttle_cfg_by_name(ts, cdev->type); stc = find_throttle_cfg_by_name(ts, cdev->type);
else else
continue; continue;
...@@ -687,25 +687,20 @@ static const struct thermal_zone_device_ops tegra_of_thermal_ops = { ...@@ -687,25 +687,20 @@ static const struct thermal_zone_device_ops tegra_of_thermal_ops = {
.set_trips = tegra_thermctl_set_trips, .set_trips = tegra_thermctl_set_trips,
}; };
static int get_hot_temp(struct thermal_zone_device *tz, int *trip, int *temp) static int get_hot_temp(struct thermal_zone_device *tz, int *trip_id, int *temp)
{ {
int ntrips, i, ret; int i, ret;
enum thermal_trip_type type; struct thermal_trip trip;
ntrips = of_thermal_get_ntrips(tz); for (i = 0; i < thermal_zone_get_num_trips(tz); i++) {
if (ntrips <= 0)
return -EINVAL;
for (i = 0; i < ntrips; i++) { ret = thermal_zone_get_trip(tz, i, &trip);
ret = tz->ops->get_trip_type(tz, i, &type);
if (ret) if (ret)
return -EINVAL; return -EINVAL;
if (type == THERMAL_TRIP_HOT) {
ret = tz->ops->get_trip_temp(tz, i, temp);
if (!ret)
*trip = i;
return ret; if (trip.type == THERMAL_TRIP_HOT) {
*trip_id = i;
return 0;
} }
} }
......
...@@ -316,18 +316,17 @@ static void tegra_tsensor_get_hw_channel_trips(struct thermal_zone_device *tzd, ...@@ -316,18 +316,17 @@ 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->num_trips; i++) { for (i = 0; i < thermal_zone_get_num_trips(tzd); i++) {
enum thermal_trip_type type;
int trip_temp;
tzd->ops->get_trip_temp(tzd, i, &trip_temp); struct thermal_trip trip;
tzd->ops->get_trip_type(tzd, i, &type);
if (type == THERMAL_TRIP_HOT) thermal_zone_get_trip(tzd, i, &trip);
*hot_trip = trip_temp;
if (type == THERMAL_TRIP_CRITICAL) if (trip.type == THERMAL_TRIP_HOT)
*crit_trip = trip_temp; *hot_trip = trip.temperature;
if (trip.type == THERMAL_TRIP_CRITICAL)
*crit_trip = trip.temperature;
} }
/* clamp hardware trips to the calibration limits */ /* clamp hardware trips to the calibration limits */
......
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