diff mbox series

[v1,10/16] thermal: gov_step_wise: Clean up thermal_zone_trip_update()

Message ID 1883063.atdPhlSkOF@kreacher (mailing list archive)
State In Next
Delegated to: Rafael Wysocki
Headers show
Series thermal: core: Redesign the governor interface | expand

Commit Message

Rafael J. Wysocki April 10, 2024, 4:44 p.m. UTC
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Do some assorted cleanups in thermal_zone_trip_update():

 * Compute the trend value upfront.
 * Move old_target definition to the block where it is used.
 * Adjust white space around diagnositc messages and locking.
 * Use suitable field formatting in a message to avoid an explicit
   cast to int.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/thermal/gov_step_wise.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

Lukasz Luba April 19, 2024, 6:21 p.m. UTC | #1
On 4/10/24 17:44, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> Do some assorted cleanups in thermal_zone_trip_update():
> 
>   * Compute the trend value upfront.
>   * Move old_target definition to the block where it is used.
>   * Adjust white space around diagnositc messages and locking.

s/diagnositc/diagnostic/

>   * Use suitable field formatting in a message to avoid an explicit
>     cast to int.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>   drivers/thermal/gov_step_wise.c |   13 +++++++------
>   1 file changed, 7 insertions(+), 6 deletions(-)
> 
> Index: linux-pm/drivers/thermal/gov_step_wise.c
> ===================================================================
> --- linux-pm.orig/drivers/thermal/gov_step_wise.c
> +++ linux-pm/drivers/thermal/gov_step_wise.c
> @@ -65,13 +65,10 @@ static void thermal_zone_trip_update(str
>   				     const struct thermal_trip *trip,
>   				     int trip_threshold)
>   {
> +	enum thermal_trend trend = get_tz_trend(tz, trip);
>   	int trip_id = thermal_zone_trip_id(tz, trip);
> -	enum thermal_trend trend;
>   	struct thermal_instance *instance;
>   	bool throttle = false;
> -	int old_target;
> -
> -	trend = get_tz_trend(tz, trip);
>   
>   	if (tz->temperature >= trip_threshold) {
>   		throttle = true;
> @@ -82,13 +79,16 @@ static void thermal_zone_trip_update(str
>   		trip_id, trip->type, trip_threshold, trend, throttle);
>   
>   	list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
> +		int old_target;
> +
>   		if (instance->trip != trip)
>   			continue;
>   
>   		old_target = instance->target;
>   		instance->target = get_target_state(instance, trend, throttle);
> -		dev_dbg(&instance->cdev->device, "old_target=%d, target=%d\n",
> -					old_target, (int)instance->target);
> +
> +		dev_dbg(&instance->cdev->device, "old_target=%d, target=%ld\n",
> +			old_target, instance->target);
>   
>   		if (instance->initialized && old_target == instance->target)
>   			continue;
> @@ -104,6 +104,7 @@ static void thermal_zone_trip_update(str
>   		}
>   
>   		instance->initialized = true;
> +
>   		mutex_lock(&instance->cdev->lock);
>   		instance->cdev->updated = false; /* cdev needs update */
>   		mutex_unlock(&instance->cdev->lock);
> 
> 
> 

LGTM w/ spelling fixed.

Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
diff mbox series

Patch

Index: linux-pm/drivers/thermal/gov_step_wise.c
===================================================================
--- linux-pm.orig/drivers/thermal/gov_step_wise.c
+++ linux-pm/drivers/thermal/gov_step_wise.c
@@ -65,13 +65,10 @@  static void thermal_zone_trip_update(str
 				     const struct thermal_trip *trip,
 				     int trip_threshold)
 {
+	enum thermal_trend trend = get_tz_trend(tz, trip);
 	int trip_id = thermal_zone_trip_id(tz, trip);
-	enum thermal_trend trend;
 	struct thermal_instance *instance;
 	bool throttle = false;
-	int old_target;
-
-	trend = get_tz_trend(tz, trip);
 
 	if (tz->temperature >= trip_threshold) {
 		throttle = true;
@@ -82,13 +79,16 @@  static void thermal_zone_trip_update(str
 		trip_id, trip->type, trip_threshold, trend, throttle);
 
 	list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
+		int old_target;
+
 		if (instance->trip != trip)
 			continue;
 
 		old_target = instance->target;
 		instance->target = get_target_state(instance, trend, throttle);
-		dev_dbg(&instance->cdev->device, "old_target=%d, target=%d\n",
-					old_target, (int)instance->target);
+
+		dev_dbg(&instance->cdev->device, "old_target=%d, target=%ld\n",
+			old_target, instance->target);
 
 		if (instance->initialized && old_target == instance->target)
 			continue;
@@ -104,6 +104,7 @@  static void thermal_zone_trip_update(str
 		}
 
 		instance->initialized = true;
+
 		mutex_lock(&instance->cdev->lock);
 		instance->cdev->updated = false; /* cdev needs update */
 		mutex_unlock(&instance->cdev->lock);