43
43
#define ACPI_THERMAL_MAX_ACTIVE 10
44
44
#define ACPI_THERMAL_MAX_LIMIT_STR_LEN 65
45
45
46
+ #define ACPI_THERMAL_TRIP_PASSIVE (-1)
47
+
46
48
/*
47
49
* This exception is thrown out in two cases:
48
50
* 1.An invalid trip point becomes invalid or a valid trip point becomes invalid
@@ -202,18 +204,25 @@ static void acpi_thermal_update_passive_trip(struct acpi_thermal *tz)
202
204
ACPI_THERMAL_TRIPS_EXCEPTION (tz , "state" );
203
205
}
204
206
205
- static bool update_passive_devices (struct acpi_thermal * tz , bool compare )
207
+ static bool update_trip_devices (struct acpi_thermal * tz ,
208
+ struct acpi_thermal_trip * acpi_trip ,
209
+ int index , bool compare )
206
210
{
207
- struct acpi_thermal_trip * acpi_trip = & tz -> trips .passive .trip ;
208
211
struct acpi_handle_list devices ;
212
+ char method [] = "_PSL" ;
209
213
acpi_status status ;
210
214
215
+ if (index != ACPI_THERMAL_TRIP_PASSIVE ) {
216
+ method [1 ] = 'A' ;
217
+ method [2 ] = 'L' ;
218
+ method [3 ] = '0' + index ;
219
+ }
220
+
211
221
memset (& devices , 0 , sizeof (devices ));
212
222
213
- status = acpi_evaluate_reference (tz -> device -> handle , "_PSL" , NULL , & devices );
223
+ status = acpi_evaluate_reference (tz -> device -> handle , method , NULL , & devices );
214
224
if (ACPI_FAILURE (status )) {
215
- acpi_handle_info (tz -> device -> handle ,
216
- "Missing device list for passive threshold\n" );
225
+ acpi_handle_info (tz -> device -> handle , "%s evaluation failure\n" , method );
217
226
return false;
218
227
}
219
228
@@ -231,8 +240,9 @@ static void acpi_thermal_update_passive_devices(struct acpi_thermal *tz)
231
240
if (!acpi_thermal_trip_valid (acpi_trip ))
232
241
return ;
233
242
234
- if (update_passive_devices (tz , true))
243
+ if (update_trip_devices (tz , acpi_trip , ACPI_THERMAL_TRIP_PASSIVE , true)) {
235
244
return ;
245
+ }
236
246
237
247
acpi_trip -> temperature = THERMAL_TEMP_INVALID ;
238
248
ACPI_THERMAL_TRIPS_EXCEPTION (tz , "state" );
@@ -273,38 +283,14 @@ static void acpi_thermal_update_active_trip(struct acpi_thermal *tz, int index)
273
283
ACPI_THERMAL_TRIPS_EXCEPTION (tz , "state" );
274
284
}
275
285
276
- static bool update_active_devices (struct acpi_thermal * tz , int index , bool compare )
277
- {
278
- char method [] = { '_' , 'A' , 'L' , '0' + index , '\0' };
279
- struct acpi_thermal_trip * acpi_trip = & tz -> trips .active [index ].trip ;
280
- struct acpi_handle_list devices ;
281
- acpi_status status ;
282
-
283
- memset (& devices , 0 , sizeof (devices ));
284
-
285
- status = acpi_evaluate_reference (tz -> device -> handle , method , NULL , & devices );
286
- if (ACPI_FAILURE (status )) {
287
- acpi_handle_info (tz -> device -> handle ,
288
- "Missing device list for active threshold %d\n" ,
289
- index );
290
- return false;
291
- }
292
-
293
- if (compare && memcmp (& acpi_trip -> devices , & devices , sizeof (devices )))
294
- ACPI_THERMAL_TRIPS_EXCEPTION (tz , "device" );
295
-
296
- memcpy (& acpi_trip -> devices , & devices , sizeof (devices ));
297
- return true;
298
- }
299
-
300
286
static void acpi_thermal_update_active_devices (struct acpi_thermal * tz , int index )
301
287
{
302
288
struct acpi_thermal_trip * acpi_trip = & tz -> trips .active [index ].trip ;
303
289
304
290
if (!acpi_thermal_trip_valid (acpi_trip ))
305
291
return ;
306
292
307
- if (update_active_devices (tz , index , true))
293
+ if (update_trip_devices (tz , acpi_trip , index , true))
308
294
return ;
309
295
310
296
acpi_trip -> temperature = THERMAL_TEMP_INVALID ;
@@ -460,7 +446,8 @@ static bool acpi_thermal_init_passive_trip(struct acpi_thermal *tz)
460
446
461
447
tz -> trips .passive .tsp = tmp ;
462
448
463
- if (!update_passive_devices (tz , false))
449
+ if (!update_trip_devices (tz , & tz -> trips .passive .trip ,
450
+ ACPI_THERMAL_TRIP_PASSIVE , false))
464
451
goto fail ;
465
452
466
453
tz -> trips .passive .trip .temperature = temp ;
@@ -482,7 +469,7 @@ static bool acpi_thermal_init_active_trip(struct acpi_thermal *tz, int index)
482
469
if (temp == THERMAL_TEMP_INVALID )
483
470
goto fail ;
484
471
485
- if (!update_active_devices (tz , index , false))
472
+ if (!update_trip_devices (tz , & tz -> trips . active [ index ]. trip , index , false))
486
473
goto fail ;
487
474
488
475
tz -> trips .active [index ].trip .temperature = temp ;
0 commit comments