Skip to content

Commit

Permalink
thermal: gov_power_allocator: Rearrange local variables
Browse files Browse the repository at this point in the history
Rearrange the order of local variable definitions in multiple functions
so as to follow the kernel coding style in that respect.

Also, move local variable definitions located in nested code blocks to
the beginning of each function to improve the visibility of all local
variables in use.

This change is not expected to alter the general functionality.

Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Lukasz Luba authored and Rafael J. Wysocki committed Nov 28, 2023
1 parent c7568e7 commit 499cc39
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions drivers/thermal/gov_power_allocator.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 499cc39

Please sign in to comment.