Lines Matching full:tz
67 * @tz: a valid pointer to a struct thermal_zone_device
73 static void bind_previous_governor(struct thermal_zone_device *tz, in bind_previous_governor() argument
76 if (tz->governor && tz->governor->bind_to_tz) { in bind_previous_governor()
77 if (tz->governor->bind_to_tz(tz)) { in bind_previous_governor()
78 dev_err(&tz->device, in bind_previous_governor()
80 failed_gov_name, tz->governor->name, tz->type); in bind_previous_governor()
81 tz->governor = NULL; in bind_previous_governor()
88 * @tz: a valid pointer to a struct thermal_zone_device
91 * Change the governor of thermal zone @tz.
95 static int thermal_set_governor(struct thermal_zone_device *tz, in thermal_set_governor() argument
100 if (tz->governor && tz->governor->unbind_from_tz) in thermal_set_governor()
101 tz->governor->unbind_from_tz(tz); in thermal_set_governor()
104 ret = new_gov->bind_to_tz(tz); in thermal_set_governor()
106 bind_previous_governor(tz, new_gov->name); in thermal_set_governor()
112 tz->governor = new_gov; in thermal_set_governor()
146 * only thermal zones with specified tz->tzp->governor_name in thermal_register_governor()
147 * may run with tz->govenor unset in thermal_register_governor()
191 int thermal_zone_device_set_policy(struct thermal_zone_device *tz, in thermal_zone_device_set_policy() argument
198 guard(thermal_zone)(tz); in thermal_zone_device_set_policy()
202 ret = thermal_set_governor(tz, gov); in thermal_zone_device_set_policy()
204 thermal_notify_tz_gov_change(tz, policy); in thermal_zone_device_set_policy()
262 static int __thermal_zone_device_set_mode(struct thermal_zone_device *tz, in __thermal_zone_device_set_mode() argument
265 if (tz->ops.change_mode) { in __thermal_zone_device_set_mode()
268 ret = tz->ops.change_mode(tz, mode); in __thermal_zone_device_set_mode()
273 tz->mode = mode; in __thermal_zone_device_set_mode()
278 static void thermal_zone_broken_disable(struct thermal_zone_device *tz) in thermal_zone_broken_disable() argument
282 dev_err(&tz->device, "Unable to get temperature, disabling!\n"); in thermal_zone_broken_disable()
287 __thermal_zone_device_set_mode(tz, THERMAL_DEVICE_DISABLED); in thermal_zone_broken_disable()
288 thermal_notify_tz_disable(tz); in thermal_zone_broken_disable()
290 for_each_trip_desc(tz, td) { in thermal_zone_broken_disable()
293 dev_crit(&tz->device, in thermal_zone_broken_disable()
310 static void thermal_zone_device_set_polling(struct thermal_zone_device *tz, in thermal_zone_device_set_polling() argument
316 mod_delayed_work(system_freezable_power_efficient_wq, &tz->poll_queue, delay); in thermal_zone_device_set_polling()
319 static void thermal_zone_recheck(struct thermal_zone_device *tz, int error) in thermal_zone_recheck() argument
322 thermal_zone_device_set_polling(tz, THERMAL_RECHECK_DELAY); in thermal_zone_recheck()
331 if (tz->recheck_delay_jiffies == THERMAL_RECHECK_DELAY) in thermal_zone_recheck()
332 dev_info(&tz->device, "Temperature check failed (%d)\n", error); in thermal_zone_recheck()
334 thermal_zone_device_set_polling(tz, tz->recheck_delay_jiffies); in thermal_zone_recheck()
336 tz->recheck_delay_jiffies += max(tz->recheck_delay_jiffies >> 1, 1ULL); in thermal_zone_recheck()
337 if (tz->recheck_delay_jiffies > THERMAL_MAX_RECHECK_DELAY) { in thermal_zone_recheck()
338 thermal_zone_broken_disable(tz); in thermal_zone_recheck()
343 tz->recheck_delay_jiffies = THERMAL_RECHECK_DELAY; in thermal_zone_recheck()
347 static void monitor_thermal_zone(struct thermal_zone_device *tz) in monitor_thermal_zone() argument
349 if (tz->passive > 0 && tz->passive_delay_jiffies) in monitor_thermal_zone()
350 thermal_zone_device_set_polling(tz, tz->passive_delay_jiffies); in monitor_thermal_zone()
351 else if (tz->polling_delay_jiffies) in monitor_thermal_zone()
352 thermal_zone_device_set_polling(tz, tz->polling_delay_jiffies); in monitor_thermal_zone()
355 static struct thermal_governor *thermal_get_tz_governor(struct thermal_zone_device *tz) in thermal_get_tz_governor() argument
357 if (tz->governor) in thermal_get_tz_governor()
358 return tz->governor; in thermal_get_tz_governor()
363 void thermal_governor_update_tz(struct thermal_zone_device *tz, in thermal_governor_update_tz() argument
366 if (!tz->governor || !tz->governor->update_tz) in thermal_governor_update_tz()
369 tz->governor->update_tz(tz, reason); in thermal_governor_update_tz()
372 static void thermal_zone_device_halt(struct thermal_zone_device *tz, bool shutdown) in thermal_zone_device_halt() argument
381 dev_emerg(&tz->device, "%s: critical temperature reached\n", tz->type); in thermal_zone_device_halt()
389 void thermal_zone_device_critical(struct thermal_zone_device *tz) in thermal_zone_device_critical() argument
391 thermal_zone_device_halt(tz, true); in thermal_zone_device_critical()
395 void thermal_zone_device_critical_reboot(struct thermal_zone_device *tz) in thermal_zone_device_critical_reboot() argument
397 thermal_zone_device_halt(tz, false); in thermal_zone_device_critical_reboot()
400 static void handle_critical_trips(struct thermal_zone_device *tz, in handle_critical_trips() argument
403 trace_thermal_zone_trip(tz, thermal_zone_trip_id(tz, trip), trip->type); in handle_critical_trips()
406 tz->ops.critical(tz); in handle_critical_trips()
407 else if (tz->ops.hot) in handle_critical_trips()
408 tz->ops.hot(tz); in handle_critical_trips()
432 static void move_to_trips_high(struct thermal_zone_device *tz, in move_to_trips_high() argument
436 move_trip_to_sorted_list(td, &tz->trips_high); in move_to_trips_high()
439 static void move_to_trips_reached(struct thermal_zone_device *tz, in move_to_trips_reached() argument
443 move_trip_to_sorted_list(td, &tz->trips_reached); in move_to_trips_reached()
446 static void move_to_trips_invalid(struct thermal_zone_device *tz, in move_to_trips_invalid() argument
450 list_move(&td->list_node, &tz->trips_invalid); in move_to_trips_invalid()
454 struct thermal_zone_device *tz, in thermal_governor_trip_crossed() argument
462 governor->trip_crossed(tz, trip, crossed_up); in thermal_governor_trip_crossed()
465 static void thermal_trip_crossed(struct thermal_zone_device *tz, in thermal_trip_crossed() argument
474 tz->passive++; in thermal_trip_crossed()
477 handle_critical_trips(tz, trip); in thermal_trip_crossed()
479 thermal_notify_tz_trip_up(tz, trip); in thermal_trip_crossed()
480 thermal_debug_tz_trip_up(tz, trip); in thermal_trip_crossed()
483 tz->passive--; in thermal_trip_crossed()
484 WARN_ON(tz->passive < 0); in thermal_trip_crossed()
486 thermal_notify_tz_trip_down(tz, trip); in thermal_trip_crossed()
487 thermal_debug_tz_trip_down(tz, trip); in thermal_trip_crossed()
489 thermal_governor_trip_crossed(governor, tz, trip, crossed_up); in thermal_trip_crossed()
492 void thermal_zone_set_trip_hyst(struct thermal_zone_device *tz, in thermal_zone_set_trip_hyst() argument
498 thermal_notify_tz_trip_change(tz, trip); in thermal_zone_set_trip_hyst()
505 if (tz->temperature >= td->threshold) in thermal_zone_set_trip_hyst()
506 move_to_trips_reached(tz, td); in thermal_zone_set_trip_hyst()
509 void thermal_zone_set_trip_temp(struct thermal_zone_device *tz, in thermal_zone_set_trip_temp() argument
519 thermal_notify_tz_trip_change(tz, trip); in thermal_zone_set_trip_temp()
529 move_to_trips_high(tz, td); in thermal_zone_set_trip_temp()
539 if (tz->temperature >= td->threshold) in thermal_zone_set_trip_temp()
540 thermal_trip_crossed(tz, td, thermal_get_tz_governor(tz), false); in thermal_zone_set_trip_temp()
542 move_to_trips_invalid(tz, td); in thermal_zone_set_trip_temp()
551 if (tz->temperature >= td->threshold) in thermal_zone_set_trip_temp()
552 move_to_trips_reached(tz, td); in thermal_zone_set_trip_temp()
554 move_to_trips_high(tz, td); in thermal_zone_set_trip_temp()
558 static void thermal_zone_handle_trips(struct thermal_zone_device *tz, in thermal_zone_handle_trips() argument
566 list_for_each_entry_safe_reverse(td, next, &tz->trips_reached, list_node) { in thermal_zone_handle_trips()
567 if (td->threshold <= tz->temperature) in thermal_zone_handle_trips()
570 thermal_trip_crossed(tz, td, governor, false); in thermal_zone_handle_trips()
578 list_for_each_entry_safe(td, next, &tz->trips_high, list_node) { in thermal_zone_handle_trips()
579 if (td->threshold > tz->temperature) in thermal_zone_handle_trips()
582 thermal_trip_crossed(tz, td, governor, true); in thermal_zone_handle_trips()
583 move_to_trips_reached(tz, td); in thermal_zone_handle_trips()
587 move_to_trips_high(tz, td); in thermal_zone_handle_trips()
589 if (!list_empty(&tz->trips_reached)) { in thermal_zone_handle_trips()
590 td = list_last_entry(&tz->trips_reached, in thermal_zone_handle_trips()
599 if (!list_empty(&tz->trips_high)) { in thermal_zone_handle_trips()
600 td = list_first_entry(&tz->trips_high, in thermal_zone_handle_trips()
606 void __thermal_zone_device_update(struct thermal_zone_device *tz, in __thermal_zone_device_update() argument
609 struct thermal_governor *governor = thermal_get_tz_governor(tz); in __thermal_zone_device_update()
613 if (tz->state != TZ_STATE_READY || tz->mode != THERMAL_DEVICE_ENABLED) in __thermal_zone_device_update()
616 ret = __thermal_zone_get_temp(tz, &temp); in __thermal_zone_device_update()
618 thermal_zone_recheck(tz, ret); in __thermal_zone_device_update()
630 tz->recheck_delay_jiffies = THERMAL_RECHECK_DELAY; in __thermal_zone_device_update()
632 tz->last_temperature = tz->temperature; in __thermal_zone_device_update()
633 tz->temperature = temp; in __thermal_zone_device_update()
635 trace_thermal_temperature(tz); in __thermal_zone_device_update()
637 thermal_genl_sampling_temp(tz->id, temp); in __thermal_zone_device_update()
639 tz->notify_event = event; in __thermal_zone_device_update()
641 thermal_zone_handle_trips(tz, governor, &low, &high); in __thermal_zone_device_update()
643 thermal_thresholds_handle(tz, &low, &high); in __thermal_zone_device_update()
645 thermal_zone_set_trips(tz, low, high); in __thermal_zone_device_update()
648 governor->manage(tz); in __thermal_zone_device_update()
650 thermal_debug_update_trip_stats(tz); in __thermal_zone_device_update()
653 monitor_thermal_zone(tz); in __thermal_zone_device_update()
656 static int thermal_zone_device_set_mode(struct thermal_zone_device *tz, in thermal_zone_device_set_mode() argument
661 guard(thermal_zone)(tz); in thermal_zone_device_set_mode()
664 if (mode == tz->mode) in thermal_zone_device_set_mode()
667 ret = __thermal_zone_device_set_mode(tz, mode); in thermal_zone_device_set_mode()
671 __thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED); in thermal_zone_device_set_mode()
674 thermal_notify_tz_enable(tz); in thermal_zone_device_set_mode()
676 thermal_notify_tz_disable(tz); in thermal_zone_device_set_mode()
681 int thermal_zone_device_enable(struct thermal_zone_device *tz) in thermal_zone_device_enable() argument
683 return thermal_zone_device_set_mode(tz, THERMAL_DEVICE_ENABLED); in thermal_zone_device_enable()
687 int thermal_zone_device_disable(struct thermal_zone_device *tz) in thermal_zone_device_disable() argument
689 return thermal_zone_device_set_mode(tz, THERMAL_DEVICE_DISABLED); in thermal_zone_device_disable()
693 static bool thermal_zone_is_present(struct thermal_zone_device *tz) in thermal_zone_is_present() argument
695 return !list_empty(&tz->node); in thermal_zone_is_present()
698 void thermal_zone_device_update(struct thermal_zone_device *tz, in thermal_zone_device_update() argument
701 guard(thermal_zone)(tz); in thermal_zone_device_update()
703 if (thermal_zone_is_present(tz)) in thermal_zone_device_update()
704 __thermal_zone_device_update(tz, event); in thermal_zone_device_update()
747 struct thermal_zone_device *tz; in for_each_thermal_zone() local
751 list_for_each_entry(tz, &thermal_tz_list, node) { in for_each_thermal_zone()
754 ret = cb(tz, data); in for_each_thermal_zone()
764 struct thermal_zone_device *tz; in thermal_zone_get_by_id() local
768 list_for_each_entry(tz, &thermal_tz_list, node) { in thermal_zone_get_by_id()
769 if (tz->id == id) { in thermal_zone_get_by_id()
770 get_device(&tz->device); in thermal_zone_get_by_id()
771 return tz; in thermal_zone_get_by_id()
810 * @tz: pointer to struct thermal_zone_device
821 static int thermal_bind_cdev_to_trip(struct thermal_zone_device *tz, in thermal_bind_cdev_to_trip() argument
856 result = ida_alloc(&tz->ida, GFP_KERNEL); in thermal_bind_cdev_to_trip()
863 sysfs_create_link(&tz->device.kobj, &cdev->device.kobj, dev->name); in thermal_bind_cdev_to_trip()
873 result = device_create_file(&tz->device, &dev->attr); in thermal_bind_cdev_to_trip()
884 result = device_create_file(&tz->device, &dev->weight_attr); in thermal_bind_cdev_to_trip()
892 thermal_governor_update_tz(tz, THERMAL_TZ_BIND_CDEV); in thermal_bind_cdev_to_trip()
897 device_remove_file(&tz->device, &dev->weight_attr); in thermal_bind_cdev_to_trip()
899 device_remove_file(&tz->device, &dev->attr); in thermal_bind_cdev_to_trip()
901 sysfs_remove_link(&tz->device.kobj, dev->name); in thermal_bind_cdev_to_trip()
903 ida_free(&tz->ida, dev->id); in thermal_bind_cdev_to_trip()
920 * @tz: pointer to a struct thermal_zone_device.
928 static void thermal_unbind_cdev_from_trip(struct thermal_zone_device *tz, in thermal_unbind_cdev_from_trip() argument
944 thermal_governor_update_tz(tz, THERMAL_TZ_UNBIND_CDEV); in thermal_unbind_cdev_from_trip()
946 device_remove_file(&tz->device, &pos->weight_attr); in thermal_unbind_cdev_from_trip()
947 device_remove_file(&tz->device, &pos->attr); in thermal_unbind_cdev_from_trip()
948 sysfs_remove_link(&tz->device.kobj, pos->name); in thermal_unbind_cdev_from_trip()
949 ida_free(&tz->ida, pos->id); in thermal_unbind_cdev_from_trip()
955 struct thermal_zone_device *tz; in thermal_release() local
960 tz = to_thermal_zone(dev); in thermal_release()
961 thermal_zone_destroy_device_groups(tz); in thermal_release()
962 mutex_destroy(&tz->lock); in thermal_release()
963 complete(&tz->removal); in thermal_release()
977 void print_bind_err_msg(struct thermal_zone_device *tz, in print_bind_err_msg() argument
981 dev_err(&tz->device, "binding cdev %s to trip %d failed: %d\n", in print_bind_err_msg()
982 cdev->type, thermal_zone_trip_id(tz, &td->trip), ret); in print_bind_err_msg()
985 static bool __thermal_zone_cdev_bind(struct thermal_zone_device *tz, in __thermal_zone_cdev_bind() argument
991 if (!tz->ops.should_bind) in __thermal_zone_cdev_bind()
994 for_each_trip_desc(tz, td) { in __thermal_zone_cdev_bind()
1002 if (!tz->ops.should_bind(tz, &td->trip, cdev, &c)) in __thermal_zone_cdev_bind()
1005 ret = thermal_bind_cdev_to_trip(tz, td, cdev, &c); in __thermal_zone_cdev_bind()
1007 print_bind_err_msg(tz, td, cdev, ret); in __thermal_zone_cdev_bind()
1017 static void thermal_zone_cdev_bind(struct thermal_zone_device *tz, in thermal_zone_cdev_bind() argument
1020 guard(thermal_zone)(tz); in thermal_zone_cdev_bind()
1022 if (__thermal_zone_cdev_bind(tz, cdev)) in thermal_zone_cdev_bind()
1023 __thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED); in thermal_zone_cdev_bind()
1028 struct thermal_zone_device *tz; in thermal_cooling_device_init_complete() local
1034 list_for_each_entry(tz, &thermal_tz_list, node) in thermal_cooling_device_init_complete()
1035 thermal_zone_cdev_bind(tz, cdev); in thermal_cooling_device_init_complete()
1314 static void __thermal_zone_cdev_unbind(struct thermal_zone_device *tz, in __thermal_zone_cdev_unbind() argument
1319 for_each_trip_desc(tz, td) in __thermal_zone_cdev_unbind()
1320 thermal_unbind_cdev_from_trip(tz, td, cdev); in __thermal_zone_cdev_unbind()
1323 static void thermal_zone_cdev_unbind(struct thermal_zone_device *tz, in thermal_zone_cdev_unbind() argument
1326 guard(thermal_zone)(tz); in thermal_zone_cdev_unbind()
1328 __thermal_zone_cdev_unbind(tz, cdev); in thermal_zone_cdev_unbind()
1333 struct thermal_zone_device *tz; in thermal_cooling_device_exit() local
1342 list_for_each_entry(tz, &thermal_tz_list, node) in thermal_cooling_device_exit()
1343 thermal_zone_cdev_unbind(tz, cdev); in thermal_cooling_device_exit()
1364 int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp) in thermal_zone_get_crit_temp() argument
1369 if (tz->ops.get_crit_temp) in thermal_zone_get_crit_temp()
1370 return tz->ops.get_crit_temp(tz, temp); in thermal_zone_get_crit_temp()
1372 guard(thermal_zone)(tz); in thermal_zone_get_crit_temp()
1374 for_each_trip_desc(tz, td) { in thermal_zone_get_crit_temp()
1390 struct thermal_zone_device *tz = container_of(work, struct in thermal_zone_device_check() local
1393 thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED); in thermal_zone_device_check()
1396 static void thermal_zone_device_init(struct thermal_zone_device *tz) in thermal_zone_device_init() argument
1400 INIT_DELAYED_WORK(&tz->poll_queue, thermal_zone_device_check); in thermal_zone_device_init()
1402 tz->temperature = THERMAL_TEMP_INIT; in thermal_zone_device_init()
1403 tz->passive = 0; in thermal_zone_device_init()
1404 tz->prev_low_trip = -INT_MAX; in thermal_zone_device_init()
1405 tz->prev_high_trip = INT_MAX; in thermal_zone_device_init()
1406 for_each_trip_desc(tz, td) { in thermal_zone_device_init()
1416 list_for_each_entry_safe(td, next, &tz->trips_invalid, list_node) { in thermal_zone_device_init()
1418 move_to_trips_high(tz, td); in thermal_zone_device_init()
1421 list_for_each_entry_safe(td, next, &tz->trips_reached, list_node) { in thermal_zone_device_init()
1423 move_to_trips_invalid(tz, td); in thermal_zone_device_init()
1425 move_to_trips_high(tz, td); in thermal_zone_device_init()
1429 static int thermal_zone_init_governor(struct thermal_zone_device *tz) in thermal_zone_init_governor() argument
1435 if (tz->tzp) in thermal_zone_init_governor()
1436 governor = __find_governor(tz->tzp->governor_name); in thermal_zone_init_governor()
1440 return thermal_set_governor(tz, governor); in thermal_zone_init_governor()
1443 static void thermal_zone_init_complete(struct thermal_zone_device *tz) in thermal_zone_init_complete() argument
1449 list_add_tail(&tz->node, &thermal_tz_list); in thermal_zone_init_complete()
1451 guard(thermal_zone)(tz); in thermal_zone_init_complete()
1455 __thermal_zone_cdev_bind(tz, cdev); in thermal_zone_init_complete()
1457 tz->state &= ~TZ_STATE_FLAG_INIT; in thermal_zone_init_complete()
1464 tz->state |= TZ_STATE_FLAG_SUSPENDED; in thermal_zone_init_complete()
1466 __thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED); in thermal_zone_init_complete()
1503 struct thermal_zone_device *tz; in thermal_zone_device_register_with_trips() local
1538 tz = kzalloc(struct_size(tz, trips, num_trips), GFP_KERNEL); in thermal_zone_device_register_with_trips()
1539 if (!tz) in thermal_zone_device_register_with_trips()
1543 tz->tzp = kmemdup(tzp, sizeof(*tzp), GFP_KERNEL); in thermal_zone_device_register_with_trips()
1544 if (!tz->tzp) { in thermal_zone_device_register_with_trips()
1550 INIT_LIST_HEAD(&tz->node); in thermal_zone_device_register_with_trips()
1551 INIT_LIST_HEAD(&tz->trips_high); in thermal_zone_device_register_with_trips()
1552 INIT_LIST_HEAD(&tz->trips_reached); in thermal_zone_device_register_with_trips()
1553 INIT_LIST_HEAD(&tz->trips_invalid); in thermal_zone_device_register_with_trips()
1554 ida_init(&tz->ida); in thermal_zone_device_register_with_trips()
1555 mutex_init(&tz->lock); in thermal_zone_device_register_with_trips()
1556 init_completion(&tz->removal); in thermal_zone_device_register_with_trips()
1557 init_completion(&tz->resume); in thermal_zone_device_register_with_trips()
1564 tz->id = id; in thermal_zone_device_register_with_trips()
1565 strscpy(tz->type, type, sizeof(tz->type)); in thermal_zone_device_register_with_trips()
1567 tz->ops = *ops; in thermal_zone_device_register_with_trips()
1568 if (!tz->ops.critical) in thermal_zone_device_register_with_trips()
1569 tz->ops.critical = thermal_zone_device_critical; in thermal_zone_device_register_with_trips()
1571 tz->device.class = thermal_class; in thermal_zone_device_register_with_trips()
1572 tz->devdata = devdata; in thermal_zone_device_register_with_trips()
1573 tz->num_trips = num_trips; in thermal_zone_device_register_with_trips()
1574 for_each_trip_desc(tz, td) { in thermal_zone_device_register_with_trips()
1583 move_to_trips_invalid(tz, td); in thermal_zone_device_register_with_trips()
1586 tz->polling_delay_jiffies = msecs_to_jiffies(polling_delay); in thermal_zone_device_register_with_trips()
1587 tz->passive_delay_jiffies = msecs_to_jiffies(passive_delay); in thermal_zone_device_register_with_trips()
1588 tz->recheck_delay_jiffies = THERMAL_RECHECK_DELAY; in thermal_zone_device_register_with_trips()
1590 tz->state = TZ_STATE_FLAG_INIT; in thermal_zone_device_register_with_trips()
1594 result = thermal_zone_create_device_groups(tz); in thermal_zone_device_register_with_trips()
1598 result = dev_set_name(&tz->device, "thermal_zone%d", tz->id); in thermal_zone_device_register_with_trips()
1600 thermal_zone_destroy_device_groups(tz); in thermal_zone_device_register_with_trips()
1603 thermal_zone_device_init(tz); in thermal_zone_device_register_with_trips()
1604 result = device_register(&tz->device); in thermal_zone_device_register_with_trips()
1608 result = thermal_zone_init_governor(tz); in thermal_zone_device_register_with_trips()
1612 if (!tz->tzp || !tz->tzp->no_hwmon) { in thermal_zone_device_register_with_trips()
1613 result = thermal_add_hwmon_sysfs(tz); in thermal_zone_device_register_with_trips()
1618 result = thermal_thresholds_init(tz); in thermal_zone_device_register_with_trips()
1622 thermal_zone_init_complete(tz); in thermal_zone_device_register_with_trips()
1624 thermal_notify_tz_create(tz); in thermal_zone_device_register_with_trips()
1626 thermal_debug_tz_add(tz); in thermal_zone_device_register_with_trips()
1628 return tz; in thermal_zone_device_register_with_trips()
1631 thermal_remove_hwmon_sysfs(tz); in thermal_zone_device_register_with_trips()
1633 device_del(&tz->device); in thermal_zone_device_register_with_trips()
1635 put_device(&tz->device); in thermal_zone_device_register_with_trips()
1639 kfree(tz->tzp); in thermal_zone_device_register_with_trips()
1641 kfree(tz); in thermal_zone_device_register_with_trips()
1681 static bool thermal_zone_exit(struct thermal_zone_device *tz) in thermal_zone_exit() argument
1687 if (list_empty(&tz->node)) in thermal_zone_exit()
1690 guard(thermal_zone)(tz); in thermal_zone_exit()
1692 tz->state |= TZ_STATE_FLAG_EXIT; in thermal_zone_exit()
1693 list_del_init(&tz->node); in thermal_zone_exit()
1697 __thermal_zone_cdev_unbind(tz, cdev); in thermal_zone_exit()
1704 * @tz: the thermal zone device to remove
1706 void thermal_zone_device_unregister(struct thermal_zone_device *tz) in thermal_zone_device_unregister() argument
1708 if (!tz) in thermal_zone_device_unregister()
1711 thermal_debug_tz_remove(tz); in thermal_zone_device_unregister()
1713 if (!thermal_zone_exit(tz)) in thermal_zone_device_unregister()
1716 cancel_delayed_work_sync(&tz->poll_queue); in thermal_zone_device_unregister()
1718 thermal_set_governor(tz, NULL); in thermal_zone_device_unregister()
1720 thermal_thresholds_exit(tz); in thermal_zone_device_unregister()
1721 thermal_remove_hwmon_sysfs(tz); in thermal_zone_device_unregister()
1722 ida_free(&thermal_tz_ida, tz->id); in thermal_zone_device_unregister()
1723 ida_destroy(&tz->ida); in thermal_zone_device_unregister()
1725 device_del(&tz->device); in thermal_zone_device_unregister()
1726 put_device(&tz->device); in thermal_zone_device_unregister()
1728 thermal_notify_tz_delete(tz); in thermal_zone_device_unregister()
1730 wait_for_completion(&tz->removal); in thermal_zone_device_unregister()
1731 kfree(tz->tzp); in thermal_zone_device_unregister()
1732 kfree(tz); in thermal_zone_device_unregister()
1775 struct thermal_zone_device *tz; in thermal_zone_device_resume() local
1777 tz = container_of(work, struct thermal_zone_device, poll_queue.work); in thermal_zone_device_resume()
1779 guard(thermal_zone)(tz); in thermal_zone_device_resume()
1781 tz->state &= ~(TZ_STATE_FLAG_SUSPENDED | TZ_STATE_FLAG_RESUMING); in thermal_zone_device_resume()
1783 thermal_debug_tz_resume(tz); in thermal_zone_device_resume()
1784 thermal_zone_device_init(tz); in thermal_zone_device_resume()
1785 thermal_governor_update_tz(tz, THERMAL_TZ_RESUME); in thermal_zone_device_resume()
1786 __thermal_zone_device_update(tz, THERMAL_TZ_RESUME); in thermal_zone_device_resume()
1788 complete(&tz->resume); in thermal_zone_device_resume()
1791 static void thermal_zone_pm_prepare(struct thermal_zone_device *tz) in thermal_zone_pm_prepare() argument
1793 guard(thermal_zone)(tz); in thermal_zone_pm_prepare()
1795 if (tz->state & TZ_STATE_FLAG_RESUMING) { in thermal_zone_pm_prepare()
1801 scoped_guard(thermal_zone_reverse, tz) { in thermal_zone_pm_prepare()
1802 wait_for_completion(&tz->resume); in thermal_zone_pm_prepare()
1806 tz->state |= TZ_STATE_FLAG_SUSPENDED; in thermal_zone_pm_prepare()
1811 struct thermal_zone_device *tz; in thermal_pm_notify_prepare() local
1817 list_for_each_entry(tz, &thermal_tz_list, node) in thermal_pm_notify_prepare()
1818 thermal_zone_pm_prepare(tz); in thermal_pm_notify_prepare()
1821 static void thermal_zone_pm_complete(struct thermal_zone_device *tz) in thermal_zone_pm_complete() argument
1823 guard(thermal_zone)(tz); in thermal_zone_pm_complete()
1825 cancel_delayed_work(&tz->poll_queue); in thermal_zone_pm_complete()
1827 reinit_completion(&tz->resume); in thermal_zone_pm_complete()
1828 tz->state |= TZ_STATE_FLAG_RESUMING; in thermal_zone_pm_complete()
1834 INIT_DELAYED_WORK(&tz->poll_queue, thermal_zone_device_resume); in thermal_zone_pm_complete()
1836 mod_delayed_work(system_freezable_power_efficient_wq, &tz->poll_queue, 0); in thermal_zone_pm_complete()
1841 struct thermal_zone_device *tz; in thermal_pm_notify_complete() local
1847 list_for_each_entry(tz, &thermal_tz_list, node) in thermal_pm_notify_complete()
1848 thermal_zone_pm_complete(tz); in thermal_pm_notify_complete()