diff mbox series

[v2,08/26] thermal/drivers/rcar: Use generic thermal_zone_get_trip() function

Message ID 20220809220436.711020-9-daniel.lezcano@linaro.org (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show
Series Rework the trip points creation | expand

Commit Message

Daniel Lezcano Aug. 9, 2022, 10:04 p.m. UTC
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: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/thermal/rcar_thermal.c | 49 +++++-----------------------------
 1 file changed, 6 insertions(+), 43 deletions(-)

Comments

Niklas Söderlund Aug. 16, 2022, 9 a.m. UTC | #1
Hi Daniel,

Thanks for your work.

On 2022-08-10 00:04:18 +0200, Daniel Lezcano wrote:
> 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: Daniel Lezcano <daniel.lezcano@linaro.org>

Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

> ---
>  drivers/thermal/rcar_thermal.c | 49 +++++-----------------------------
>  1 file changed, 6 insertions(+), 43 deletions(-)
> 
> diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
> index 4df42d70d867..003457810072 100644
> --- a/drivers/thermal/rcar_thermal.c
> +++ b/drivers/thermal/rcar_thermal.c
> @@ -278,52 +278,16 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
>  	return rcar_thermal_get_current_temp(priv, temp);
>  }
>  
> -static int rcar_thermal_get_trip_type(struct thermal_zone_device *zone,
> -				      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 struct thermal_zone_device_ops rcar_thermal_zone_of_ops = {
>  	.get_temp	= rcar_thermal_get_temp,
>  };
>  
>  static struct thermal_zone_device_ops rcar_thermal_zone_ops = {
>  	.get_temp	= rcar_thermal_get_temp,
> -	.get_trip_type	= rcar_thermal_get_trip_type,
> -	.get_trip_temp	= rcar_thermal_get_trip_temp,
> +};
> +
> +static struct thermal_trip trips[] = {
> +	{ .type = THERMAL_TRIP_CRITICAL, .temperature = 90000 }
>  };
>  
>  /*
> @@ -531,9 +495,8 @@ static int rcar_thermal_probe(struct platform_device *pdev)
>  						dev, i, priv,
>  						&rcar_thermal_zone_of_ops);
>  		} else {
> -			priv->zone = thermal_zone_device_register(
> -						"rcar_thermal",
> -						1, 0, priv,
> +			priv->zone = thermal_zone_device_register_with_trips(
> +				"rcar_thermal", trips, ARRAY_SIZE(trips), 0, priv,
>  						&rcar_thermal_zone_ops, NULL, 0,
>  						idle);
>  
> -- 
> 2.34.1
>
diff mbox series

Patch

diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index 4df42d70d867..003457810072 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -278,52 +278,16 @@  static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
 	return rcar_thermal_get_current_temp(priv, temp);
 }
 
-static int rcar_thermal_get_trip_type(struct thermal_zone_device *zone,
-				      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 struct thermal_zone_device_ops rcar_thermal_zone_of_ops = {
 	.get_temp	= rcar_thermal_get_temp,
 };
 
 static struct thermal_zone_device_ops rcar_thermal_zone_ops = {
 	.get_temp	= rcar_thermal_get_temp,
-	.get_trip_type	= rcar_thermal_get_trip_type,
-	.get_trip_temp	= rcar_thermal_get_trip_temp,
+};
+
+static struct thermal_trip trips[] = {
+	{ .type = THERMAL_TRIP_CRITICAL, .temperature = 90000 }
 };
 
 /*
@@ -531,9 +495,8 @@  static int rcar_thermal_probe(struct platform_device *pdev)
 						dev, i, priv,
 						&rcar_thermal_zone_of_ops);
 		} else {
-			priv->zone = thermal_zone_device_register(
-						"rcar_thermal",
-						1, 0, priv,
+			priv->zone = thermal_zone_device_register_with_trips(
+				"rcar_thermal", trips, ARRAY_SIZE(trips), 0, priv,
 						&rcar_thermal_zone_ops, NULL, 0,
 						idle);