Commit 0b6a3e45 authored by Daniel Lezcano's avatar Daniel Lezcano Committed by Daniel Lezcano

thermal/drivers/rcar: 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>
Reviewed-by: default avatarNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Link: https://lore.kernel.org/r/20221003092602.1323944-23-daniel.lezcano@linaro.org
parent 30233a22
...@@ -278,52 +278,12 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp) ...@@ -278,52 +278,12 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
return rcar_thermal_get_current_temp(priv, temp); return rcar_thermal_get_current_temp(priv, temp);
} }
static int rcar_thermal_get_trip_type(struct thermal_zone_device *zone, static struct thermal_zone_device_ops rcar_thermal_zone_ops = {
int trip, enum thermal_trip_type *type)
{
struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
struct device *dev = rcar_priv_to_dev(priv);
/* see rcar_thermal_get_temp() */
switch (trip) {
case 0: /* +90 <= temp */
*type = THERMAL_TRIP_CRITICAL;
break;
default:
dev_err(dev, "rcar driver trip error\n");
return -EINVAL;
}
return 0;
}
static int rcar_thermal_get_trip_temp(struct thermal_zone_device *zone,
int trip, int *temp)
{
struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
struct device *dev = rcar_priv_to_dev(priv);
/* see rcar_thermal_get_temp() */
switch (trip) {
case 0: /* +90 <= temp */
*temp = MCELSIUS(90);
break;
default:
dev_err(dev, "rcar driver trip error\n");
return -EINVAL;
}
return 0;
}
static const struct thermal_zone_device_ops rcar_thermal_zone_of_ops = {
.get_temp = rcar_thermal_get_temp, .get_temp = rcar_thermal_get_temp,
}; };
static struct thermal_zone_device_ops rcar_thermal_zone_ops = { static struct thermal_trip trips[] = {
.get_temp = rcar_thermal_get_temp, { .type = THERMAL_TRIP_CRITICAL, .temperature = 90000 }
.get_trip_type = rcar_thermal_get_trip_type,
.get_trip_temp = rcar_thermal_get_trip_temp,
}; };
/* /*
...@@ -529,11 +489,10 @@ static int rcar_thermal_probe(struct platform_device *pdev) ...@@ -529,11 +489,10 @@ static int rcar_thermal_probe(struct platform_device *pdev)
if (chip->use_of_thermal) { if (chip->use_of_thermal) {
priv->zone = devm_thermal_of_zone_register( priv->zone = devm_thermal_of_zone_register(
dev, i, priv, dev, i, priv,
&rcar_thermal_zone_of_ops); &rcar_thermal_zone_ops);
} else { } else {
priv->zone = thermal_zone_device_register( priv->zone = thermal_zone_device_register_with_trips(
"rcar_thermal", "rcar_thermal", trips, ARRAY_SIZE(trips), 0, priv,
1, 0, priv,
&rcar_thermal_zone_ops, NULL, 0, &rcar_thermal_zone_ops, NULL, 0,
idle); idle);
......
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