diff mbox series

[RESEND,v1,3/8] thermal: qcom: Use thermal_zone_get_crit_temp() in qpnp_tm_init()

Message ID 7712228.EvYhyI6sBW@rjwysocki.net (mailing list archive)
State Not Applicable
Headers show
Series None | expand

Commit Message

Rafael J. Wysocki July 29, 2024, 3:58 p.m. UTC
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Modify qpnp_tm_init() to use thermal_zone_get_crit_temp() to get the
critical trip temperature instead of iterating over trip indices and
using thermal_zone_get_trip() to get a struct thermal_trip pointer
from a trip index until it finds the critical one.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---

This patch does not depend on the previous patch(es) in the series.

---
 drivers/thermal/qcom/qcom-spmi-temp-alarm.c |   22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)

Comments

Lukasz Luba Aug. 2, 2024, 9:37 a.m. UTC | #1
On 7/29/24 16:58, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> Modify qpnp_tm_init() to use thermal_zone_get_crit_temp() to get the
> critical trip temperature instead of iterating over trip indices and
> using thermal_zone_get_trip() to get a struct thermal_trip pointer
> from a trip index until it finds the critical one.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> 
> This patch does not depend on the previous patch(es) in the series.
> 
> ---
>   drivers/thermal/qcom/qcom-spmi-temp-alarm.c |   22 +++-------------------
>   1 file changed, 3 insertions(+), 19 deletions(-)
> 
> Index: linux-pm/drivers/thermal/qcom/qcom-spmi-temp-alarm.c
> ===================================================================
> --- linux-pm.orig/drivers/thermal/qcom/qcom-spmi-temp-alarm.c
> +++ linux-pm/drivers/thermal/qcom/qcom-spmi-temp-alarm.c
> @@ -291,24 +291,6 @@ static irqreturn_t qpnp_tm_isr(int irq,
>   	return IRQ_HANDLED;
>   }
>   
> -static int qpnp_tm_get_critical_trip_temp(struct qpnp_tm_chip *chip)
> -{
> -	struct thermal_trip trip;
> -	int i, ret;
> -
> -	for (i = 0; i < thermal_zone_get_num_trips(chip->tz_dev); i++) {
> -
> -		ret = thermal_zone_get_trip(chip->tz_dev, i, &trip);
> -		if (ret)
> -			continue;
> -
> -		if (trip.type == THERMAL_TRIP_CRITICAL)
> -			return trip.temperature;
> -	}
> -
> -	return THERMAL_TEMP_INVALID;
> -}
> -
>   /*
>    * This function initializes the internal temp value based on only the
>    * current thermal stage and threshold. Setup threshold control and
> @@ -343,7 +325,9 @@ static int qpnp_tm_init(struct qpnp_tm_c
>   
>   	mutex_unlock(&chip->lock);
>   
> -	crit_temp = qpnp_tm_get_critical_trip_temp(chip);
> +	ret = thermal_zone_get_crit_temp(chip->tz_dev, &crit_temp);
> +	if (ret)
> +		crit_temp = THERMAL_TEMP_INVALID;
>   
>   	mutex_lock(&chip->lock);
>   
> 
> 
> 


Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Amit Kucheria Aug. 14, 2024, 5:09 a.m. UTC | #2
On Mon, Jul 29, 2024 at 10:43 PM Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
>
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Modify qpnp_tm_init() to use thermal_zone_get_crit_temp() to get the
> critical trip temperature instead of iterating over trip indices and
> using thermal_zone_get_trip() to get a struct thermal_trip pointer
> from a trip index until it finds the critical one.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Makes sense.

Reviewed-by: Amit Kucheria <amitk@kernel.org>

> ---
>
> This patch does not depend on the previous patch(es) in the series.
>
> ---
>  drivers/thermal/qcom/qcom-spmi-temp-alarm.c |   22 +++-------------------
>  1 file changed, 3 insertions(+), 19 deletions(-)
>
> Index: linux-pm/drivers/thermal/qcom/qcom-spmi-temp-alarm.c
> ===================================================================
> --- linux-pm.orig/drivers/thermal/qcom/qcom-spmi-temp-alarm.c
> +++ linux-pm/drivers/thermal/qcom/qcom-spmi-temp-alarm.c
> @@ -291,24 +291,6 @@ static irqreturn_t qpnp_tm_isr(int irq,
>         return IRQ_HANDLED;
>  }
>
> -static int qpnp_tm_get_critical_trip_temp(struct qpnp_tm_chip *chip)
> -{
> -       struct thermal_trip trip;
> -       int i, ret;
> -
> -       for (i = 0; i < thermal_zone_get_num_trips(chip->tz_dev); i++) {
> -
> -               ret = thermal_zone_get_trip(chip->tz_dev, i, &trip);
> -               if (ret)
> -                       continue;
> -
> -               if (trip.type == THERMAL_TRIP_CRITICAL)
> -                       return trip.temperature;
> -       }
> -
> -       return THERMAL_TEMP_INVALID;
> -}
> -
>  /*
>   * This function initializes the internal temp value based on only the
>   * current thermal stage and threshold. Setup threshold control and
> @@ -343,7 +325,9 @@ static int qpnp_tm_init(struct qpnp_tm_c
>
>         mutex_unlock(&chip->lock);
>
> -       crit_temp = qpnp_tm_get_critical_trip_temp(chip);
> +       ret = thermal_zone_get_crit_temp(chip->tz_dev, &crit_temp);
> +       if (ret)
> +               crit_temp = THERMAL_TEMP_INVALID;
>
>         mutex_lock(&chip->lock);
>
>
>
>
diff mbox series

Patch

Index: linux-pm/drivers/thermal/qcom/qcom-spmi-temp-alarm.c
===================================================================
--- linux-pm.orig/drivers/thermal/qcom/qcom-spmi-temp-alarm.c
+++ linux-pm/drivers/thermal/qcom/qcom-spmi-temp-alarm.c
@@ -291,24 +291,6 @@  static irqreturn_t qpnp_tm_isr(int irq,
 	return IRQ_HANDLED;
 }
 
-static int qpnp_tm_get_critical_trip_temp(struct qpnp_tm_chip *chip)
-{
-	struct thermal_trip trip;
-	int i, ret;
-
-	for (i = 0; i < thermal_zone_get_num_trips(chip->tz_dev); i++) {
-
-		ret = thermal_zone_get_trip(chip->tz_dev, i, &trip);
-		if (ret)
-			continue;
-
-		if (trip.type == THERMAL_TRIP_CRITICAL)
-			return trip.temperature;
-	}
-
-	return THERMAL_TEMP_INVALID;
-}
-
 /*
  * This function initializes the internal temp value based on only the
  * current thermal stage and threshold. Setup threshold control and
@@ -343,7 +325,9 @@  static int qpnp_tm_init(struct qpnp_tm_c
 
 	mutex_unlock(&chip->lock);
 
-	crit_temp = qpnp_tm_get_critical_trip_temp(chip);
+	ret = thermal_zone_get_crit_temp(chip->tz_dev, &crit_temp);
+	if (ret)
+		crit_temp = THERMAL_TEMP_INVALID;
 
 	mutex_lock(&chip->lock);