MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_thermal_zone_device_update

Function rt_thermal_zone_device_update

components/drivers/thermal/thermal.c:552–715  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

550}
551
552void rt_thermal_zone_device_update(struct rt_thermal_zone_device *zdev, rt_ubase_t msg)
553{
554 rt_err_t err;
555 rt_bool_t passive = RT_FALSE, need_cool = RT_FALSE;
556 struct rt_thermal_notifier *notifier, *next_notifier;
557
558 RT_ASSERT(zdev != RT_NULL);
559
560 if (!rt_interrupt_get_nest())
561 {
562 rt_mutex_take(&zdev->mutex, RT_WAITING_FOREVER);
563 }
564
565 /* Check thermal zone status */
566 if (msg == RT_THERMAL_MSG_DEVICE_DOWN)
567 {
568 zdev->enabled = RT_FALSE;
569 }
570 else if (msg == RT_THERMAL_MSG_DEVICE_UP)
571 {
572 zdev->enabled = RT_TRUE;
573 }
574
575 /* Read temperature */
576 zdev->last_temperature = zdev->temperature;
577 zdev->ops->get_temp(zdev, &zdev->temperature);
578
579 for (int i = 0; i < zdev->trips_nr; ++i)
580 {
581 struct rt_thermal_trip *tmp_trip = &zdev->trips[i];
582
583 if (zdev->temperature <= tmp_trip->temperature)
584 {
585 continue;
586 }
587
588 switch (tmp_trip->type)
589 {
590 case RT_THERMAL_TRIP_PASSIVE:
591 passive = RT_TRUE;
592 goto cooling;
593
594 case RT_THERMAL_TRIP_CRITICAL:
595 if (zdev->ops->critical)
596 {
597 zdev->ops->critical(zdev);
598 }
599 else if (zdev->last_temperature > tmp_trip->temperature)
600 {
601 /* Tried to cool already, but failed */
602 rt_hw_cpu_reset();
603 }
604 else
605 {
606 goto cooling;
607 }
608 break;
609

Callers 2

thermal_zone_pollFunction · 0.85
rt_thermal_zone_set_tripFunction · 0.85

Calls 12

rt_interrupt_get_nestFunction · 0.85
rt_mutex_takeFunction · 0.85
rt_memcpyFunction · 0.85
rt_dm_dev_get_nameFunction · 0.85
rt_strerrorFunction · 0.85
rt_work_cancelFunction · 0.85
rt_work_submitFunction · 0.85
rt_mutex_releaseFunction · 0.85
rt_hw_cpu_resetFunction · 0.50
rt_spin_lockFunction · 0.50
rt_spin_unlockFunction · 0.50

Tested by

no test coverage detected