@@ -93,6 +93,13 @@ struct power_allocator_params {
93
93
struct power_actor * power ;
94
94
};
95
95
96
+ static bool power_actor_is_valid (struct power_allocator_params * params ,
97
+ struct thermal_instance * instance )
98
+ {
99
+ return (instance -> trip == params -> trip_max &&
100
+ cdev_is_power_actor (instance -> cdev ));
101
+ }
102
+
96
103
/**
97
104
* estimate_sustainable_power() - Estimate the sustainable power of a thermal zone
98
105
* @tz: thermal zone we are operating in
@@ -113,14 +120,10 @@ static u32 estimate_sustainable_power(struct thermal_zone_device *tz)
113
120
u32 min_power ;
114
121
115
122
list_for_each_entry (instance , & tz -> thermal_instances , tz_node ) {
116
- cdev = instance -> cdev ;
117
-
118
- if (instance -> trip != params -> trip_max )
119
- continue ;
120
-
121
- if (!cdev_is_power_actor (cdev ))
123
+ if (!power_actor_is_valid (params , instance ))
122
124
continue ;
123
125
126
+ cdev = instance -> cdev ;
124
127
if (cdev -> ops -> state2power (cdev , instance -> upper , & min_power ))
125
128
continue ;
126
129
@@ -409,8 +412,7 @@ static int allocate_power(struct thermal_zone_device *tz, int control_temp)
409
412
return - ENODEV ;
410
413
411
414
list_for_each_entry (instance , & tz -> thermal_instances , tz_node )
412
- if ((instance -> trip == params -> trip_max ) &&
413
- cdev_is_power_actor (instance -> cdev ))
415
+ if (power_actor_is_valid (params , instance ))
414
416
total_weight += instance -> weight ;
415
417
416
418
/* Clean all buffers for new power estimations */
@@ -419,13 +421,10 @@ static int allocate_power(struct thermal_zone_device *tz, int control_temp)
419
421
list_for_each_entry (instance , & tz -> thermal_instances , tz_node ) {
420
422
struct power_actor * pa = & power [i ];
421
423
422
- cdev = instance -> cdev ;
423
-
424
- if (instance -> trip != params -> trip_max )
424
+ if (!power_actor_is_valid (params , instance ))
425
425
continue ;
426
426
427
- if (!cdev_is_power_actor (cdev ))
428
- continue ;
427
+ cdev = instance -> cdev ;
429
428
430
429
ret = cdev -> ops -> get_requested_power (cdev , & pa -> req_power );
431
430
if (ret )
@@ -459,10 +458,7 @@ static int allocate_power(struct thermal_zone_device *tz, int control_temp)
459
458
list_for_each_entry (instance , & tz -> thermal_instances , tz_node ) {
460
459
struct power_actor * pa = & power [i ];
461
460
462
- if (instance -> trip != params -> trip_max )
463
- continue ;
464
-
465
- if (!cdev_is_power_actor (instance -> cdev ))
461
+ if (!power_actor_is_valid (params , instance ))
466
462
continue ;
467
463
468
464
power_actor_set_power (instance -> cdev , instance ,
@@ -548,12 +544,11 @@ static void allow_maximum_power(struct thermal_zone_device *tz, bool update)
548
544
u32 req_power ;
549
545
550
546
list_for_each_entry (instance , & tz -> thermal_instances , tz_node ) {
551
- cdev = instance -> cdev ;
552
-
553
- if (instance -> trip != params -> trip_max ||
554
- !cdev_is_power_actor (instance -> cdev ))
547
+ if (!power_actor_is_valid (params , instance ))
555
548
continue ;
556
549
550
+ cdev = instance -> cdev ;
551
+
557
552
instance -> target = 0 ;
558
553
mutex_lock (& cdev -> lock );
559
554
/*
@@ -648,8 +643,7 @@ static void power_allocator_update_tz(struct thermal_zone_device *tz,
648
643
case THERMAL_TZ_BIND_CDEV :
649
644
case THERMAL_TZ_UNBIND_CDEV :
650
645
list_for_each_entry (instance , & tz -> thermal_instances , tz_node )
651
- if ((instance -> trip == params -> trip_max ) &&
652
- cdev_is_power_actor (instance -> cdev ))
646
+ if (power_actor_is_valid (params , instance ))
653
647
num_actors ++ ;
654
648
655
649
if (num_actors == params -> num_actors )
0 commit comments