Commit 9ddcb809 authored by Daniel Lezcano's avatar Daniel Lezcano Committed by Daniel Lezcano

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

The thermal framework gives the possibility to register the trip
points with the thermal zone. When that is done, no get_trip_* ops are
needed and they can be removed.

Convert ops content logic into generic trip points and register them with the
thermal zone.
Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: default avatarJakub Kicinski <kuba@kernel.org>
Link: https://lore.kernel.org/r/20221003092602.1323944-28-daniel.lezcano@linaro.org
parent a1ebf2cd
...@@ -1079,8 +1079,6 @@ struct mbox_list { ...@@ -1079,8 +1079,6 @@ struct mbox_list {
#if IS_ENABLED(CONFIG_THERMAL) #if IS_ENABLED(CONFIG_THERMAL)
struct ch_thermal { struct ch_thermal {
struct thermal_zone_device *tzdev; struct thermal_zone_device *tzdev;
int trip_temp;
int trip_type;
}; };
#endif #endif
......
...@@ -29,36 +29,12 @@ static int cxgb4_thermal_get_temp(struct thermal_zone_device *tzdev, ...@@ -29,36 +29,12 @@ static int cxgb4_thermal_get_temp(struct thermal_zone_device *tzdev,
return 0; return 0;
} }
static int cxgb4_thermal_get_trip_type(struct thermal_zone_device *tzdev,
int trip, enum thermal_trip_type *type)
{
struct adapter *adap = tzdev->devdata;
if (!adap->ch_thermal.trip_temp)
return -EINVAL;
*type = adap->ch_thermal.trip_type;
return 0;
}
static int cxgb4_thermal_get_trip_temp(struct thermal_zone_device *tzdev,
int trip, int *temp)
{
struct adapter *adap = tzdev->devdata;
if (!adap->ch_thermal.trip_temp)
return -EINVAL;
*temp = adap->ch_thermal.trip_temp;
return 0;
}
static struct thermal_zone_device_ops cxgb4_thermal_ops = { static struct thermal_zone_device_ops cxgb4_thermal_ops = {
.get_temp = cxgb4_thermal_get_temp, .get_temp = cxgb4_thermal_get_temp,
.get_trip_type = cxgb4_thermal_get_trip_type,
.get_trip_temp = cxgb4_thermal_get_trip_temp,
}; };
static struct thermal_trip trip = { .type = THERMAL_TRIP_CRITICAL } ;
int cxgb4_thermal_init(struct adapter *adap) int cxgb4_thermal_init(struct adapter *adap)
{ {
struct ch_thermal *ch_thermal = &adap->ch_thermal; struct ch_thermal *ch_thermal = &adap->ch_thermal;
...@@ -79,15 +55,14 @@ int cxgb4_thermal_init(struct adapter *adap) ...@@ -79,15 +55,14 @@ int cxgb4_thermal_init(struct adapter *adap)
if (ret < 0) { if (ret < 0) {
num_trip = 0; /* could not get trip temperature */ num_trip = 0; /* could not get trip temperature */
} else { } else {
ch_thermal->trip_temp = val * 1000; trip.temperature = val * 1000;
ch_thermal->trip_type = THERMAL_TRIP_CRITICAL;
} }
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(ch_tz_name, num_trip, ch_thermal->tzdev = thermal_zone_device_register_with_trips(ch_tz_name, &trip, num_trip,
0, adap, 0, 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)) {
ret = PTR_ERR(ch_thermal->tzdev); ret = PTR_ERR(ch_thermal->tzdev);
dev_err(adap->pdev_dev, "Failed to register thermal zone\n"); dev_err(adap->pdev_dev, "Failed to register thermal zone\n");
......
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