@@ -94,6 +94,11 @@ static struct lpi_constraints *lpi_constraints_table;
94
94
static int lpi_constraints_table_size ;
95
95
static int rev_id ;
96
96
97
+ #define for_each_lpi_constraint (entry ) \
98
+ for (int i = 0; \
99
+ entry = &lpi_constraints_table[i], i < lpi_constraints_table_size; \
100
+ i++)
101
+
97
102
static void lpi_device_get_constraints_amd (void )
98
103
{
99
104
union acpi_object * out_obj ;
@@ -296,30 +301,29 @@ static void lpi_device_get_constraints(void)
296
301
297
302
static void lpi_check_constraints (void )
298
303
{
299
- int i ;
304
+ struct lpi_constraints * entry ;
300
305
301
- for (i = 0 ; i < lpi_constraints_table_size ; ++ i ) {
302
- acpi_handle handle = lpi_constraints_table [i ].handle ;
303
- struct acpi_device * adev = acpi_fetch_acpi_dev (handle );
306
+ for_each_lpi_constraint (entry ) {
307
+ struct acpi_device * adev = acpi_fetch_acpi_dev (entry -> handle );
304
308
305
309
if (!adev )
306
310
continue ;
307
311
308
- acpi_handle_debug (handle ,
312
+ acpi_handle_debug (entry -> handle ,
309
313
"LPI: required min power state:%s current power state:%s\n" ,
310
- acpi_power_state_string (lpi_constraints_table [ i ]. min_dstate ),
314
+ acpi_power_state_string (entry -> min_dstate ),
311
315
acpi_power_state_string (adev -> power .state ));
312
316
313
317
if (!adev -> flags .power_manageable ) {
314
- acpi_handle_info (handle , "LPI: Device not power manageable\n" );
315
- lpi_constraints_table [ i ]. handle = NULL ;
318
+ acpi_handle_info (entry -> handle , "LPI: Device not power manageable\n" );
319
+ entry -> handle = NULL ;
316
320
continue ;
317
321
}
318
322
319
- if (adev -> power .state < lpi_constraints_table [ i ]. min_dstate )
320
- acpi_handle_info (handle ,
323
+ if (adev -> power .state < entry -> min_dstate )
324
+ acpi_handle_info (entry -> handle ,
321
325
"LPI: Constraint not met; min power state:%s current power state:%s\n" ,
322
- acpi_power_state_string (lpi_constraints_table [ i ]. min_dstate ),
326
+ acpi_power_state_string (entry -> min_dstate ),
323
327
acpi_power_state_string (adev -> power .state ));
324
328
}
325
329
}
0 commit comments