Linux Power Management development
 help / color / mirror / Atom feed
From: Lukasz Luba <lukasz.luba@arm.com>
To: linux-kernel@vger.kernel.org, daniel.lezcano@linaro.org,
	rafael@kernel.org
Cc: linux-pm@vger.kernel.org, rui.zhang@intel.com, lukasz.luba@arm.com
Subject: [PATCH 4/7] thermal: gov_power_allocator: Rearrange the order of variables
Date: Wed, 25 Oct 2023 20:22:22 +0100	[thread overview]
Message-ID: <20231025192225.468228-5-lukasz.luba@arm.com> (raw)
In-Reply-To: <20231025192225.468228-1-lukasz.luba@arm.com>

Rearrange the order of variables in function and make them aligned with
the standard order for the kernel coding style. Also, move some variables
defined in nested code into the top of the function, to improve visibility
off all variables used.

This change is not expected to alter the general functionality.

Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
---
 drivers/thermal/gov_power_allocator.c | 39 ++++++++++++++-------------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c
index 4b9ef04577a9a..79621b42ead38 100644
--- a/drivers/thermal/gov_power_allocator.c
+++ b/drivers/thermal/gov_power_allocator.c
@@ -84,13 +84,14 @@ struct power_allocator_params {
  */
 static u32 estimate_sustainable_power(struct thermal_zone_device *tz)
 {
-	u32 sustainable_power = 0;
-	struct thermal_instance *instance;
 	struct power_allocator_params *params = tz->governor_data;
+	struct thermal_cooling_device *cdev;
+	struct thermal_instance *instance;
+	u32 sustainable_power = 0;
+	u32 min_power;
 
 	list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
-		struct thermal_cooling_device *cdev = instance->cdev;
-		u32 min_power;
+		cdev = instance->cdev;
 
 		if (instance->trip != params->trip_max)
 			continue;
@@ -211,10 +212,10 @@ static u32 pid_controller(struct thermal_zone_device *tz,
 			  int control_temp,
 			  u32 max_allocatable_power)
 {
+	struct power_allocator_params *params = tz->governor_data;
 	s64 p, i, d, power_range;
 	s32 err, max_power_frac;
 	u32 sustainable_power;
-	struct power_allocator_params *params = tz->governor_data;
 
 	max_power_frac = int_to_frac(max_allocatable_power);
 
@@ -373,20 +374,20 @@ static void divvy_up_power(u32 *req_power, u32 *max_power, int num_actors,
 		}
 }
 
-static int allocate_power(struct thermal_zone_device *tz,
-			  int control_temp)
+static int allocate_power(struct thermal_zone_device *tz, int control_temp)
 {
-	struct thermal_instance *instance;
+	u32 total_req_power, max_allocatable_power, total_weighted_req_power;
+	u32 *req_power, *max_power, *granted_power, *extra_actor_power;
 	struct power_allocator_params *params = tz->governor_data;
 	const struct thermal_trip *trip_max = params->trip_max;
-	u32 *req_power, *max_power, *granted_power, *extra_actor_power;
-	u32 *weighted_req_power;
-	u32 total_req_power, max_allocatable_power, total_weighted_req_power;
 	u32 total_granted_power, power_range;
-	int i, num_actors, total_weight, ret = 0;
+	struct thermal_cooling_device *cdev;
+	struct thermal_instance *instance;
+	u32 *weighted_req_power;
+	int i, weight, ret = 0;
+	int total_weight = 0;
+	int num_actors = 0;
 
-	num_actors = 0;
-	total_weight = 0;
 	list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
 		if ((instance->trip == trip_max) &&
 		    cdev_is_power_actor(instance->cdev)) {
@@ -424,8 +425,7 @@ static int allocate_power(struct thermal_zone_device *tz,
 	max_allocatable_power = 0;
 
 	list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
-		int weight;
-		struct thermal_cooling_device *cdev = instance->cdev;
+		cdev = instance->cdev;
 
 		if (instance->trip != trip_max)
 			continue;
@@ -547,12 +547,13 @@ static void reset_pid_controller(struct power_allocator_params *params)
 
 static void allow_maximum_power(struct thermal_zone_device *tz, bool update)
 {
-	struct thermal_instance *instance;
 	struct power_allocator_params *params = tz->governor_data;
+	struct thermal_cooling_device *cdev;
+	struct thermal_instance *instance;
 	u32 req_power;
 
 	list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
-		struct thermal_cooling_device *cdev = instance->cdev;
+		cdev = instance->cdev;
 
 		if (instance->trip != params->trip_max ||
 		    !cdev_is_power_actor(instance->cdev))
@@ -619,8 +620,8 @@ static int check_power_actors(struct thermal_zone_device *tz,
  */
 static int power_allocator_bind(struct thermal_zone_device *tz)
 {
-	int ret;
 	struct power_allocator_params *params;
+	int ret;
 
 	params = kzalloc(sizeof(*params), GFP_KERNEL);
 	if (!params)
-- 
2.25.1


  parent reply	other threads:[~2023-10-25 19:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-25 19:22 [PATCH 0/7] Minor cleanup for thermal gov power allocator Lukasz Luba
2023-10-25 19:22 ` [PATCH 1/7] thermal: gov_power_allocator: Rename trip_max_desired_temperature Lukasz Luba
2023-10-25 19:22 ` [PATCH 2/7] thermal: gov_power_allocator: Setup trip points earlier Lukasz Luba
2023-10-25 19:22 ` [PATCH 3/7] thermal: gov_power_allocator: Check the cooling devices only for trip_max Lukasz Luba
2023-10-25 19:22 ` Lukasz Luba [this message]
2023-10-25 19:22 ` [PATCH 5/7] thermal: gov_power_allocator: Use shorter variable when possible Lukasz Luba
2023-10-25 19:22 ` [PATCH 6/7] thermal: gov_power_allocator: Remove unneeded local variables Lukasz Luba
2023-10-25 19:22 ` [PATCH 7/7] thermal: gov_power_allocator: Clean needed variables at the beginning Lukasz Luba
2023-10-26  8:54 ` [PATCH 0/7] Minor cleanup for thermal gov power allocator Rafael J. Wysocki
2023-10-26 12:22   ` Lukasz Luba
2023-11-23 15:19     ` Lukasz Luba
2023-11-23 19:50       ` Rafael J. Wysocki
2023-11-24  7:45         ` Lukasz Luba
2023-11-28 15:17           ` Rafael J. Wysocki
2023-11-28 15:32             ` Lukasz Luba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231025192225.468228-5-lukasz.luba@arm.com \
    --to=lukasz.luba@arm.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox