@@ -192,73 +192,6 @@ static void __acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
192
192
bool valid = false;
193
193
int i ;
194
194
195
- /* Passive (optional) */
196
- if (((flag & ACPI_TRIPS_PASSIVE ) && tz -> trips .passive .trip .valid ) ||
197
- flag == ACPI_TRIPS_INIT ) {
198
- valid = tz -> trips .passive .trip .valid ;
199
- if (psv == -1 ) {
200
- status = AE_SUPPORT ;
201
- } else if (psv > 0 ) {
202
- tmp = celsius_to_deci_kelvin (psv );
203
- status = AE_OK ;
204
- } else {
205
- status = acpi_evaluate_integer (tz -> device -> handle ,
206
- "_PSV" , NULL , & tmp );
207
- }
208
-
209
- if (ACPI_FAILURE (status )) {
210
- tz -> trips .passive .trip .valid = false;
211
- } else {
212
- tz -> trips .passive .trip .temperature = tmp ;
213
- tz -> trips .passive .trip .valid = true;
214
- if (flag == ACPI_TRIPS_INIT ) {
215
- status = acpi_evaluate_integer (tz -> device -> handle ,
216
- "_TC1" , NULL , & tmp );
217
- if (ACPI_FAILURE (status ))
218
- tz -> trips .passive .trip .valid = false;
219
- else
220
- tz -> trips .passive .tc1 = tmp ;
221
-
222
- status = acpi_evaluate_integer (tz -> device -> handle ,
223
- "_TC2" , NULL , & tmp );
224
- if (ACPI_FAILURE (status ))
225
- tz -> trips .passive .trip .valid = false;
226
- else
227
- tz -> trips .passive .tc2 = tmp ;
228
-
229
- status = acpi_evaluate_integer (tz -> device -> handle ,
230
- "_TSP" , NULL , & tmp );
231
- if (ACPI_FAILURE (status ))
232
- tz -> trips .passive .trip .valid = false;
233
- else
234
- tz -> trips .passive .tsp = tmp ;
235
- }
236
- }
237
- }
238
- if ((flag & ACPI_TRIPS_DEVICES ) && tz -> trips .passive .trip .valid ) {
239
- memset (& devices , 0 , sizeof (struct acpi_handle_list ));
240
- status = acpi_evaluate_reference (tz -> device -> handle , "_PSL" ,
241
- NULL , & devices );
242
- if (ACPI_FAILURE (status )) {
243
- acpi_handle_info (tz -> device -> handle ,
244
- "Invalid passive threshold\n" );
245
- tz -> trips .passive .trip .valid = false;
246
- } else {
247
- tz -> trips .passive .trip .valid = true;
248
- }
249
-
250
- if (memcmp (& tz -> trips .passive .devices , & devices ,
251
- sizeof (struct acpi_handle_list ))) {
252
- memcpy (& tz -> trips .passive .devices , & devices ,
253
- sizeof (struct acpi_handle_list ));
254
- ACPI_THERMAL_TRIPS_EXCEPTION (flag , tz , "device" );
255
- }
256
- }
257
- if ((flag & ACPI_TRIPS_PASSIVE ) || (flag & ACPI_TRIPS_DEVICES )) {
258
- if (valid != tz -> trips .passive .trip .valid )
259
- ACPI_THERMAL_TRIPS_EXCEPTION (flag , tz , "state" );
260
- }
261
-
262
195
/* Active (optional) */
263
196
for (i = 0 ; i < ACPI_THERMAL_MAX_ACTIVE ; i ++ ) {
264
197
char name [5 ] = { '_' , 'A' , 'C' , ('0' + i ), '\0' };
@@ -339,6 +272,72 @@ static void __acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
339
272
}
340
273
}
341
274
275
+ static void update_acpi_thermal_trip_temp (struct acpi_thermal_trip * acpi_trip ,
276
+ int temp )
277
+ {
278
+ acpi_trip -> valid = temp != THERMAL_TEMP_INVALID ;
279
+ acpi_trip -> temperature = temp ;
280
+ }
281
+
282
+ static long get_passive_temp (struct acpi_thermal * tz )
283
+ {
284
+ unsigned long long tmp ;
285
+ acpi_status status ;
286
+
287
+ status = acpi_evaluate_integer (tz -> device -> handle , "_PSV" , NULL , & tmp );
288
+ if (ACPI_FAILURE (status ))
289
+ return THERMAL_TEMP_INVALID ;
290
+
291
+ return tmp ;
292
+ }
293
+
294
+ static void acpi_thermal_update_passive_trip (struct acpi_thermal * tz )
295
+ {
296
+ struct acpi_thermal_trip * acpi_trip = & tz -> trips .passive .trip ;
297
+
298
+ if (!acpi_trip -> valid || psv > 0 )
299
+ return ;
300
+
301
+ update_acpi_thermal_trip_temp (acpi_trip , get_passive_temp (tz ));
302
+ if (!acpi_trip -> valid )
303
+ ACPI_THERMAL_TRIPS_EXCEPTION (ACPI_TRIPS_PASSIVE , tz , "state" );
304
+ }
305
+
306
+ static bool update_passive_devices (struct acpi_thermal * tz , bool compare )
307
+ {
308
+ struct acpi_handle_list devices ;
309
+ acpi_status status ;
310
+
311
+ memset (& devices , 0 , sizeof (devices ));
312
+
313
+ status = acpi_evaluate_reference (tz -> device -> handle , "_PSL" , NULL , & devices );
314
+ if (ACPI_FAILURE (status )) {
315
+ acpi_handle_info (tz -> device -> handle ,
316
+ "Missing device list for passive threshold\n" );
317
+ return false;
318
+ }
319
+
320
+ if (compare && memcmp (& tz -> trips .passive .devices , & devices , sizeof (devices )))
321
+ ACPI_THERMAL_TRIPS_EXCEPTION (ACPI_TRIPS_PASSIVE , tz , "device" );
322
+
323
+ memcpy (& tz -> trips .passive .devices , & devices , sizeof (devices ));
324
+ return true;
325
+ }
326
+
327
+ static void acpi_thermal_update_passive_devices (struct acpi_thermal * tz )
328
+ {
329
+ struct acpi_thermal_trip * acpi_trip = & tz -> trips .passive .trip ;
330
+
331
+ if (!acpi_trip -> valid )
332
+ return ;
333
+
334
+ if (update_passive_devices (tz , true))
335
+ return ;
336
+
337
+ update_acpi_thermal_trip_temp (acpi_trip , THERMAL_TEMP_INVALID );
338
+ ACPI_THERMAL_TRIPS_EXCEPTION (ACPI_TRIPS_PASSIVE , tz , "state" );
339
+ }
340
+
342
341
static int acpi_thermal_adjust_trip (struct thermal_trip * trip , void * data )
343
342
{
344
343
struct acpi_thermal_trip * acpi_trip = trip -> priv ;
@@ -359,8 +358,15 @@ static void acpi_thermal_adjust_thermal_zone(struct thermal_zone_device *thermal
359
358
unsigned long data )
360
359
{
361
360
struct acpi_thermal * tz = thermal_zone_device_priv (thermal );
362
- int flag = data == ACPI_THERMAL_NOTIFY_THRESHOLDS ?
363
- ACPI_TRIPS_THRESHOLDS : ACPI_TRIPS_DEVICES ;
361
+ int flag ;
362
+
363
+ if (data == ACPI_THERMAL_NOTIFY_THRESHOLDS ) {
364
+ acpi_thermal_update_passive_trip (tz );
365
+ flag = ACPI_TRIPS_THRESHOLDS ;
366
+ } else {
367
+ acpi_thermal_update_passive_devices (tz );
368
+ flag = ACPI_TRIPS_DEVICES ;
369
+ }
364
370
365
371
__acpi_thermal_trips_update (tz , flag );
366
372
@@ -446,17 +452,63 @@ static long acpi_thermal_get_hot_trip(struct acpi_thermal *tz)
446
452
return tmp ;
447
453
}
448
454
455
+ static bool acpi_thermal_init_passive_trip (struct acpi_thermal * tz )
456
+ {
457
+ unsigned long long tmp ;
458
+ acpi_status status ;
459
+ int temp ;
460
+
461
+ if (psv == -1 )
462
+ goto fail ;
463
+
464
+ if (psv > 0 ) {
465
+ temp = celsius_to_deci_kelvin (psv );
466
+ } else {
467
+ temp = get_passive_temp (tz );
468
+ if (temp == THERMAL_TEMP_INVALID )
469
+ goto fail ;
470
+ }
471
+
472
+ status = acpi_evaluate_integer (tz -> device -> handle , "_TC1" , NULL , & tmp );
473
+ if (ACPI_FAILURE (status ))
474
+ goto fail ;
475
+
476
+ tz -> trips .passive .tc1 = tmp ;
477
+
478
+ status = acpi_evaluate_integer (tz -> device -> handle , "_TC2" , NULL , & tmp );
479
+ if (ACPI_FAILURE (status ))
480
+ goto fail ;
481
+
482
+ tz -> trips .passive .tc2 = tmp ;
483
+
484
+ status = acpi_evaluate_integer (tz -> device -> handle , "_TSP" , NULL , & tmp );
485
+ if (ACPI_FAILURE (status ))
486
+ goto fail ;
487
+
488
+ tz -> trips .passive .tsp = tmp ;
489
+
490
+ if (!update_passive_devices (tz , false))
491
+ goto fail ;
492
+
493
+ update_acpi_thermal_trip_temp (& tz -> trips .passive .trip , temp );
494
+ return true;
495
+
496
+ fail :
497
+ update_acpi_thermal_trip_temp (& tz -> trips .passive .trip , THERMAL_TEMP_INVALID );
498
+ return false;
499
+ }
500
+
449
501
static int acpi_thermal_get_trip_points (struct acpi_thermal * tz )
450
502
{
451
503
unsigned int count = 0 ;
452
504
int i ;
453
505
454
- /* Passive and active trip points (optional). */
455
- __acpi_thermal_trips_update (tz , ACPI_TRIPS_INIT );
456
-
457
- if (tz -> trips .passive .trip .valid )
506
+ if (acpi_thermal_init_passive_trip (tz ))
458
507
count ++ ;
459
508
509
+ /* Active trip points (optional). */
510
+ __acpi_thermal_trips_update (tz , ACPI_TRIPS_INIT );
511
+
460
512
for (i = 0 ; i < ACPI_THERMAL_MAX_ACTIVE ; i ++ ) {
461
513
if (tz -> trips .active [i ].trip .valid )
462
514
count ++ ;
0 commit comments