@@ -300,8 +300,6 @@ static void monitor_thermal_zone(struct thermal_zone_device *tz)
300
300
thermal_zone_device_set_polling (tz , tz -> passive_delay_jiffies );
301
301
else if (tz -> polling_delay_jiffies )
302
302
thermal_zone_device_set_polling (tz , tz -> polling_delay_jiffies );
303
- else if (tz -> temperature == THERMAL_TEMP_INVALID )
304
- thermal_zone_device_set_polling (tz , msecs_to_jiffies (THERMAL_RECHECK_DELAY_MS ));
305
303
}
306
304
307
305
static struct thermal_governor * thermal_get_tz_governor (struct thermal_zone_device * tz )
@@ -382,7 +380,7 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
382
380
td -> threshold = trip -> temperature ;
383
381
384
382
if (tz -> last_temperature >= old_threshold &&
385
- tz -> last_temperature != THERMAL_TEMP_INVALID ) {
383
+ tz -> last_temperature != THERMAL_TEMP_INIT ) {
386
384
/*
387
385
* Mitigation is under way, so it needs to stop if the zone
388
386
* temperature falls below the low temperature of the trip.
@@ -417,27 +415,6 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
417
415
}
418
416
}
419
417
420
- static void update_temperature (struct thermal_zone_device * tz )
421
- {
422
- int temp , ret ;
423
-
424
- ret = __thermal_zone_get_temp (tz , & temp );
425
- if (ret ) {
426
- if (ret != - EAGAIN )
427
- dev_warn (& tz -> device ,
428
- "failed to read out thermal zone (%d)\n" ,
429
- ret );
430
- return ;
431
- }
432
-
433
- tz -> last_temperature = tz -> temperature ;
434
- tz -> temperature = temp ;
435
-
436
- trace_thermal_temperature (tz );
437
-
438
- thermal_genl_sampling_temp (tz -> id , temp );
439
- }
440
-
441
418
static void thermal_zone_device_check (struct work_struct * work )
442
419
{
443
420
struct thermal_zone_device * tz = container_of (work , struct
@@ -452,7 +429,7 @@ static void thermal_zone_device_init(struct thermal_zone_device *tz)
452
429
453
430
INIT_DELAYED_WORK (& tz -> poll_queue , thermal_zone_device_check );
454
431
455
- tz -> temperature = THERMAL_TEMP_INVALID ;
432
+ tz -> temperature = THERMAL_TEMP_INIT ;
456
433
tz -> passive = 0 ;
457
434
tz -> prev_low_trip = - INT_MAX ;
458
435
tz -> prev_high_trip = INT_MAX ;
@@ -504,17 +481,37 @@ void __thermal_zone_device_update(struct thermal_zone_device *tz,
504
481
struct thermal_trip_desc * td ;
505
482
LIST_HEAD (way_down_list );
506
483
LIST_HEAD (way_up_list );
484
+ int temp , ret ;
507
485
508
486
if (tz -> suspended )
509
487
return ;
510
488
511
489
if (!thermal_zone_device_is_enabled (tz ))
512
490
return ;
513
491
514
- update_temperature (tz );
492
+ ret = __thermal_zone_get_temp (tz , & temp );
493
+ if (ret ) {
494
+ if (ret != - EAGAIN )
495
+ dev_info (& tz -> device , "Temperature check failed (%d)\n" , ret );
515
496
516
- if (tz -> temperature == THERMAL_TEMP_INVALID )
497
+ thermal_zone_device_set_polling (tz , msecs_to_jiffies (THERMAL_RECHECK_DELAY_MS ));
498
+ return ;
499
+ } else if (temp <= THERMAL_TEMP_INVALID ) {
500
+ /*
501
+ * Special case: No valid temperature value is available, but
502
+ * the zone owner does not want the core to do anything about
503
+ * it. Continue regular zone polling if needed, so that this
504
+ * function can be called again, but skip everything else.
505
+ */
517
506
goto monitor ;
507
+ }
508
+
509
+ tz -> last_temperature = tz -> temperature ;
510
+ tz -> temperature = temp ;
511
+
512
+ trace_thermal_temperature (tz );
513
+
514
+ thermal_genl_sampling_temp (tz -> id , temp );
518
515
519
516
tz -> notify_event = event ;
520
517
0 commit comments