Lines Matching +full:cooling +full:- +full:device
1 // SPDX-License-Identifier: GPL-2.0
3 * thermal.c - Generic Thermal Management Sysfs support.
12 #include <linux/device.h>
59 if (!strncasecmp(name, pos->name, THERMAL_NAME_LENGTH)) in __find_governor()
66 * bind_previous_governor() - bind the previous governor of the thermal zone
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()
87 * thermal_set_governor() - Switch to another governor
100 if (tz->governor && tz->governor->unbind_from_tz) in thermal_set_governor()
101 tz->governor->unbind_from_tz(tz); in thermal_set_governor()
103 if (new_gov && new_gov->bind_to_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()
124 return -EINVAL; in thermal_register_governor()
128 err = -EBUSY; in thermal_register_governor()
129 if (!__find_governor(governor->name)) { in thermal_register_governor()
133 list_add(&governor->governor_list, &thermal_governor_list); in thermal_register_governor()
134 match_default = !strncmp(governor->name, in thermal_register_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()
149 if (pos->governor) in thermal_register_governor()
152 name = pos->tzp->governor_name; in thermal_register_governor()
154 if (!strncasecmp(name, governor->name, THERMAL_NAME_LENGTH)) { in thermal_register_governor()
159 dev_err(&pos->device, in thermal_register_governor()
161 governor->name, pos->type, ret); in thermal_register_governor()
180 if (!__find_governor(governor->name)) in thermal_unregister_governor()
186 if (!strncasecmp(pos->governor->name, governor->name, in thermal_unregister_governor()
192 list_del(&governor->governor_list); in thermal_unregister_governor()
201 int ret = -EINVAL; in thermal_zone_device_set_policy()
204 mutex_lock(&tz->lock); in thermal_zone_device_set_policy()
213 mutex_unlock(&tz->lock); in thermal_zone_device_set_policy()
216 thermal_notify_tz_gov_change(tz->id, policy); in thermal_zone_device_set_policy()
229 count += scnprintf(buf + count, PAGE_SIZE - count, "%s ", in thermal_build_list_of_policies()
230 pos->name); in thermal_build_list_of_policies()
232 count += scnprintf(buf + count, PAGE_SIZE - count, "\n"); in thermal_build_list_of_policies()
256 (*governor)->name); in thermal_register_governors()
261 (*governor)->name); in thermal_register_governors()
284 * - Non-critical trips will invoke the governor responsible for that zone;
285 * - Hot trips will produce a notification to userspace;
286 * - Critical trip point will cause a system shutdown.
293 &tz->poll_queue, delay); in thermal_zone_device_set_polling()
295 cancel_delayed_work(&tz->poll_queue); in thermal_zone_device_set_polling()
300 if (tz->mode != THERMAL_DEVICE_ENABLED) in monitor_thermal_zone()
302 else if (tz->passive) in monitor_thermal_zone()
303 thermal_zone_device_set_polling(tz, tz->passive_delay_jiffies); in monitor_thermal_zone()
304 else if (tz->polling_delay_jiffies) in monitor_thermal_zone()
305 thermal_zone_device_set_polling(tz, tz->polling_delay_jiffies); in monitor_thermal_zone()
310 tz->governor ? tz->governor->throttle(tz, trip) : in handle_non_critical_trips()
311 def_governor->throttle(tz, trip); in handle_non_critical_trips()
322 dev_emerg(&tz->device, "%s: critical temperature reached, " in thermal_zone_device_critical()
323 "shutting down\n", tz->type); in thermal_zone_device_critical()
333 if (trip_temp <= 0 || tz->temperature < trip_temp) in handle_critical_trips()
338 if (trip_type == THERMAL_TRIP_HOT && tz->ops->hot) in handle_critical_trips()
339 tz->ops->hot(tz); in handle_critical_trips()
341 tz->ops->critical(tz); in handle_critical_trips()
350 if (test_bit(trip, &tz->trips_disabled)) in handle_thermal_trip()
353 tz->ops->get_trip_temp(tz, trip, &trip_temp); in handle_thermal_trip()
354 tz->ops->get_trip_type(tz, trip, &type); in handle_thermal_trip()
355 if (tz->ops->get_trip_hyst) in handle_thermal_trip()
356 tz->ops->get_trip_hyst(tz, trip, &hyst); in handle_thermal_trip()
358 if (tz->last_temperature != THERMAL_TEMP_INVALID) { in handle_thermal_trip()
359 if (tz->last_temperature < trip_temp && in handle_thermal_trip()
360 tz->temperature >= trip_temp) in handle_thermal_trip()
361 thermal_notify_tz_trip_up(tz->id, trip, in handle_thermal_trip()
362 tz->temperature); in handle_thermal_trip()
363 if (tz->last_temperature >= trip_temp && in handle_thermal_trip()
364 tz->temperature < (trip_temp - hyst)) in handle_thermal_trip()
365 thermal_notify_tz_trip_down(tz->id, trip, in handle_thermal_trip()
366 tz->temperature); in handle_thermal_trip()
381 if (ret != -EAGAIN) in update_temperature()
382 dev_warn(&tz->device, in update_temperature()
388 tz->last_temperature = tz->temperature; in update_temperature()
389 tz->temperature = temp; in update_temperature()
393 thermal_genl_sampling_temp(tz->id, temp); in update_temperature()
399 tz->temperature = THERMAL_TEMP_INVALID; in thermal_zone_device_init()
400 tz->prev_low_trip = -INT_MAX; in thermal_zone_device_init()
401 tz->prev_high_trip = INT_MAX; in thermal_zone_device_init()
402 list_for_each_entry(pos, &tz->thermal_instances, tz_node) in thermal_zone_device_init()
403 pos->initialized = false; in thermal_zone_device_init()
411 mutex_lock(&tz->lock); in thermal_zone_device_set_mode()
414 if (mode == tz->mode) { in thermal_zone_device_set_mode()
415 mutex_unlock(&tz->lock); in thermal_zone_device_set_mode()
420 if (tz->ops->change_mode) in thermal_zone_device_set_mode()
421 ret = tz->ops->change_mode(tz, mode); in thermal_zone_device_set_mode()
424 tz->mode = mode; in thermal_zone_device_set_mode()
426 mutex_unlock(&tz->lock); in thermal_zone_device_set_mode()
431 thermal_notify_tz_enable(tz->id); in thermal_zone_device_set_mode()
433 thermal_notify_tz_disable(tz->id); in thermal_zone_device_set_mode()
452 lockdep_assert_held(&tz->lock); in thermal_zone_device_is_enabled()
454 return tz->mode == THERMAL_DEVICE_ENABLED; in thermal_zone_device_is_enabled()
465 if (WARN_ONCE(!tz->ops->get_temp, "'%s' must not be called without " in thermal_zone_device_update()
469 mutex_lock(&tz->lock); in thermal_zone_device_update()
478 tz->notify_event = event; in thermal_zone_device_update()
480 for (count = 0; count < tz->num_trips; count++) in thermal_zone_device_update()
485 mutex_unlock(&tz->lock); in thermal_zone_device_update()
554 if (tz->id == id) { in thermal_zone_get_by_id()
565 * Device management section: cooling devices, zones devices, and binding
568 * - cooling devices lifecycle: registration, unregistration,
570 * - thermal zone devices lifecycle: registration, unregistration,
575 * thermal_zone_bind_cooling_device() - bind a cooling device to a thermal zone
577 * @trip: indicates which trip point the cooling devices is
580 * @upper: the Maximum cooling state for this trip point.
582 * and the cooling device can be in max_state.
583 * @lower: the Minimum cooling state can be used for this trip point.
585 * and the cooling device can be in cooling state 0.
586 * @weight: The weight of the cooling device to be bound to the
590 * This interface function bind a thermal cooling device to the certain trip
591 * point of a thermal zone device.
592 * This function is usually called in the thermal zone device .bind callback.
609 if (trip >= tz->num_trips || trip < 0) in thermal_zone_bind_cooling_device()
610 return -EINVAL; in thermal_zone_bind_cooling_device()
622 return -EINVAL; in thermal_zone_bind_cooling_device()
624 ret = cdev->ops->get_max_state(cdev, &max_state); in thermal_zone_bind_cooling_device()
633 return -EINVAL; in thermal_zone_bind_cooling_device()
637 return -ENOMEM; in thermal_zone_bind_cooling_device()
638 dev->tz = tz; in thermal_zone_bind_cooling_device()
639 dev->cdev = cdev; in thermal_zone_bind_cooling_device()
640 dev->trip = trip; in thermal_zone_bind_cooling_device()
641 dev->upper = upper; in thermal_zone_bind_cooling_device()
642 dev->lower = lower; in thermal_zone_bind_cooling_device()
643 dev->target = THERMAL_NO_TARGET; in thermal_zone_bind_cooling_device()
644 dev->weight = weight; in thermal_zone_bind_cooling_device()
646 result = ida_alloc(&tz->ida, GFP_KERNEL); in thermal_zone_bind_cooling_device()
650 dev->id = result; in thermal_zone_bind_cooling_device()
651 sprintf(dev->name, "cdev%d", dev->id); in thermal_zone_bind_cooling_device()
653 sysfs_create_link(&tz->device.kobj, &cdev->device.kobj, dev->name); in thermal_zone_bind_cooling_device()
657 sprintf(dev->attr_name, "cdev%d_trip_point", dev->id); in thermal_zone_bind_cooling_device()
658 sysfs_attr_init(&dev->attr.attr); in thermal_zone_bind_cooling_device()
659 dev->attr.attr.name = dev->attr_name; in thermal_zone_bind_cooling_device()
660 dev->attr.attr.mode = 0444; in thermal_zone_bind_cooling_device()
661 dev->attr.show = trip_point_show; in thermal_zone_bind_cooling_device()
662 result = device_create_file(&tz->device, &dev->attr); in thermal_zone_bind_cooling_device()
666 sprintf(dev->weight_attr_name, "cdev%d_weight", dev->id); in thermal_zone_bind_cooling_device()
667 sysfs_attr_init(&dev->weight_attr.attr); in thermal_zone_bind_cooling_device()
668 dev->weight_attr.attr.name = dev->weight_attr_name; in thermal_zone_bind_cooling_device()
669 dev->weight_attr.attr.mode = S_IWUSR | S_IRUGO; in thermal_zone_bind_cooling_device()
670 dev->weight_attr.show = weight_show; in thermal_zone_bind_cooling_device()
671 dev->weight_attr.store = weight_store; in thermal_zone_bind_cooling_device()
672 result = device_create_file(&tz->device, &dev->weight_attr); in thermal_zone_bind_cooling_device()
676 mutex_lock(&tz->lock); in thermal_zone_bind_cooling_device()
677 mutex_lock(&cdev->lock); in thermal_zone_bind_cooling_device()
678 list_for_each_entry(pos, &tz->thermal_instances, tz_node) in thermal_zone_bind_cooling_device()
679 if (pos->tz == tz && pos->trip == trip && pos->cdev == cdev) { in thermal_zone_bind_cooling_device()
680 result = -EEXIST; in thermal_zone_bind_cooling_device()
684 list_add_tail(&dev->tz_node, &tz->thermal_instances); in thermal_zone_bind_cooling_device()
685 list_add_tail(&dev->cdev_node, &cdev->thermal_instances); in thermal_zone_bind_cooling_device()
686 atomic_set(&tz->need_update, 1); in thermal_zone_bind_cooling_device()
688 mutex_unlock(&cdev->lock); in thermal_zone_bind_cooling_device()
689 mutex_unlock(&tz->lock); in thermal_zone_bind_cooling_device()
694 device_remove_file(&tz->device, &dev->weight_attr); in thermal_zone_bind_cooling_device()
696 device_remove_file(&tz->device, &dev->attr); in thermal_zone_bind_cooling_device()
698 sysfs_remove_link(&tz->device.kobj, dev->name); in thermal_zone_bind_cooling_device()
700 ida_free(&tz->ida, dev->id); in thermal_zone_bind_cooling_device()
708 * thermal_zone_unbind_cooling_device() - unbind a cooling device from a
711 * @trip: indicates which trip point the cooling devices is
715 * This interface function unbind a thermal cooling device from the certain
716 * trip point of a thermal zone device.
717 * This function is usually called in the thermal zone device .unbind callback.
727 mutex_lock(&tz->lock); in thermal_zone_unbind_cooling_device()
728 mutex_lock(&cdev->lock); in thermal_zone_unbind_cooling_device()
729 list_for_each_entry_safe(pos, next, &tz->thermal_instances, tz_node) { in thermal_zone_unbind_cooling_device()
730 if (pos->tz == tz && pos->trip == trip && pos->cdev == cdev) { in thermal_zone_unbind_cooling_device()
731 list_del(&pos->tz_node); in thermal_zone_unbind_cooling_device()
732 list_del(&pos->cdev_node); in thermal_zone_unbind_cooling_device()
733 mutex_unlock(&cdev->lock); in thermal_zone_unbind_cooling_device()
734 mutex_unlock(&tz->lock); in thermal_zone_unbind_cooling_device()
738 mutex_unlock(&cdev->lock); in thermal_zone_unbind_cooling_device()
739 mutex_unlock(&tz->lock); in thermal_zone_unbind_cooling_device()
741 return -ENODEV; in thermal_zone_unbind_cooling_device()
744 device_remove_file(&tz->device, &pos->weight_attr); in thermal_zone_unbind_cooling_device()
745 device_remove_file(&tz->device, &pos->attr); in thermal_zone_unbind_cooling_device()
746 sysfs_remove_link(&tz->device.kobj, pos->name); in thermal_zone_unbind_cooling_device()
747 ida_free(&tz->ida, pos->id); in thermal_zone_unbind_cooling_device()
753 static void thermal_release(struct device *dev) in thermal_release()
759 sizeof("thermal_zone") - 1)) { in thermal_release()
764 sizeof("cooling_device") - 1)) { in thermal_release()
779 dev_err(&tz->device, "binding zone %s with cdev %s failed:%d\n", in print_bind_err_msg()
780 tz->type, cdev->type, ret); in print_bind_err_msg()
790 for (i = 0; i < tz->num_trips; i++) { in __bind()
818 if (!pos->tzp && !pos->ops->bind) in bind_cdev()
821 if (pos->ops->bind) { in bind_cdev()
822 ret = pos->ops->bind(pos, cdev); in bind_cdev()
828 tzp = pos->tzp; in bind_cdev()
829 if (!tzp || !tzp->tbp) in bind_cdev()
832 for (i = 0; i < tzp->num_tbps; i++) { in bind_cdev()
833 if (tzp->tbp[i].cdev || !tzp->tbp[i].match) in bind_cdev()
835 if (tzp->tbp[i].match(pos, cdev)) in bind_cdev()
837 tzp->tbp[i].cdev = cdev; in bind_cdev()
838 __bind(pos, tzp->tbp[i].trip_mask, cdev, in bind_cdev()
839 tzp->tbp[i].binding_limits, in bind_cdev()
840 tzp->tbp[i].weight); in bind_cdev()
848 * __thermal_cooling_device_register() - register a new thermal cooling device
849 * @np: a pointer to a device tree node.
850 * @type: the thermal cooling device type.
851 * @devdata: device private data.
852 * @ops: standard thermal cooling devices callbacks.
854 * This interface function adds a new thermal cooling device (fan/processor/...)
855 * to /sys/class/thermal/ folder as cooling_device[0-*]. It tries to bind itself
857 * It also gives the opportunity to link the cooling device to a device tree
858 * node, so that it can be bound to a thermal zone created out of device tree.
872 if (!ops || !ops->get_max_state || !ops->get_cur_state || in __thermal_cooling_device_register()
873 !ops->set_cur_state) in __thermal_cooling_device_register()
874 return ERR_PTR(-EINVAL); in __thermal_cooling_device_register()
878 return ERR_PTR(-ENOMEM); in __thermal_cooling_device_register()
883 cdev->id = ret; in __thermal_cooling_device_register()
886 ret = dev_set_name(&cdev->device, "cooling_device%d", cdev->id); in __thermal_cooling_device_register()
890 cdev->type = kstrdup(type ? type : "", GFP_KERNEL); in __thermal_cooling_device_register()
891 if (!cdev->type) { in __thermal_cooling_device_register()
892 ret = -ENOMEM; in __thermal_cooling_device_register()
896 mutex_init(&cdev->lock); in __thermal_cooling_device_register()
897 INIT_LIST_HEAD(&cdev->thermal_instances); in __thermal_cooling_device_register()
898 cdev->np = np; in __thermal_cooling_device_register()
899 cdev->ops = ops; in __thermal_cooling_device_register()
900 cdev->updated = false; in __thermal_cooling_device_register()
901 cdev->device.class = &thermal_class; in __thermal_cooling_device_register()
902 cdev->devdata = devdata; in __thermal_cooling_device_register()
904 ret = device_register(&cdev->device); in __thermal_cooling_device_register()
910 list_add(&cdev->node, &thermal_cdev_list); in __thermal_cooling_device_register()
918 if (atomic_cmpxchg(&pos->need_update, 1, 0)) in __thermal_cooling_device_register()
927 kfree(cdev->type); in __thermal_cooling_device_register()
928 put_device(&cdev->device); in __thermal_cooling_device_register()
938 * thermal_cooling_device_register() - register a new thermal cooling device
939 * @type: the thermal cooling device type.
940 * @devdata: device private data.
941 * @ops: standard thermal cooling devices callbacks.
943 * This interface function adds a new thermal cooling device (fan/processor/...)
944 * to /sys/class/thermal/ folder as cooling_device[0-*]. It tries to bind itself
959 * thermal_of_cooling_device_register() - register an OF thermal cooling device
960 * @np: a pointer to a device tree node.
961 * @type: the thermal cooling device type.
962 * @devdata: device private data.
963 * @ops: standard thermal cooling devices callbacks.
965 * This function will register a cooling device with device tree node reference.
966 * This interface function adds a new thermal cooling device (fan/processor/...)
967 * to /sys/class/thermal/ folder as cooling_device[0-*]. It tries to bind itself
982 static void thermal_cooling_device_release(struct device *dev, void *res) in thermal_cooling_device_release()
989 * devm_thermal_of_cooling_device_register() - register an OF thermal cooling
990 * device
991 * @dev: a valid struct device pointer of a sensor device.
992 * @np: a pointer to a device tree node.
993 * @type: the thermal cooling device type.
994 * @devdata: device private data.
995 * @ops: standard thermal cooling devices callbacks.
997 * This function will register a cooling device with device tree node reference.
998 * This interface function adds a new thermal cooling device (fan/processor/...)
999 * to /sys/class/thermal/ folder as cooling_device[0-*]. It tries to bind itself
1006 devm_thermal_of_cooling_device_register(struct device *dev, in devm_thermal_of_cooling_device_register()
1016 return ERR_PTR(-ENOMEM); in devm_thermal_of_cooling_device_register()
1036 for (i = 0; i < tz->num_trips; i++) in __unbind()
1042 * thermal_cooling_device_unregister - removes a thermal cooling device
1043 * @cdev: the thermal cooling device to remove.
1046 * thermal cooling device is no longer needed.
1063 /* thermal cooling device not found */ in thermal_cooling_device_unregister()
1067 list_del(&cdev->node); in thermal_cooling_device_unregister()
1071 if (tz->ops->unbind) { in thermal_cooling_device_unregister()
1072 tz->ops->unbind(tz, cdev); in thermal_cooling_device_unregister()
1076 if (!tz->tzp || !tz->tzp->tbp) in thermal_cooling_device_unregister()
1079 tzp = tz->tzp; in thermal_cooling_device_unregister()
1080 for (i = 0; i < tzp->num_tbps; i++) { in thermal_cooling_device_unregister()
1081 if (tzp->tbp[i].cdev == cdev) { in thermal_cooling_device_unregister()
1082 __unbind(tz, tzp->tbp[i].trip_mask, cdev); in thermal_cooling_device_unregister()
1083 tzp->tbp[i].cdev = NULL; in thermal_cooling_device_unregister()
1090 ida_free(&thermal_cdev_ida, cdev->id); in thermal_cooling_device_unregister()
1091 device_del(&cdev->device); in thermal_cooling_device_unregister()
1093 kfree(cdev->type); in thermal_cooling_device_unregister()
1094 put_device(&cdev->device); in thermal_cooling_device_unregister()
1102 const struct thermal_zone_params *tzp = tz->tzp; in bind_tz()
1104 if (!tzp && !tz->ops->bind) in bind_tz()
1109 /* If there is ops->bind, try to use ops->bind */ in bind_tz()
1110 if (tz->ops->bind) { in bind_tz()
1112 ret = tz->ops->bind(tz, pos); in bind_tz()
1119 if (!tzp || !tzp->tbp) in bind_tz()
1123 for (i = 0; i < tzp->num_tbps; i++) { in bind_tz()
1124 if (tzp->tbp[i].cdev || !tzp->tbp[i].match) in bind_tz()
1126 if (tzp->tbp[i].match(tz, pos)) in bind_tz()
1128 tzp->tbp[i].cdev = pos; in bind_tz()
1129 __bind(tz, tzp->tbp[i].trip_mask, pos, in bind_tz()
1130 tzp->tbp[i].binding_limits, in bind_tz()
1131 tzp->tbp[i].weight); in bind_tz()
1146 * thermal_zone_device_register_with_trips() - register a new thermal zone device
1147 * @type: the thermal zone device type
1151 * @devdata: private device data
1152 * @ops: standard thermal zone device callbacks
1155 * performing passive cooling
1160 * This interface function adds a new thermal zone device (sensor) to
1161 * /sys/class/thermal folder as thermal_zone[0-*]. It tries to bind all the
1162 * thermal cooling devices registered at the same time.
1163 * thermal_zone_device_unregister() must be called when the device is no
1164 * longer needed. The passive cooling depends on the .get_trend() return value.
1186 return ERR_PTR(-EINVAL); in thermal_zone_device_register_with_trips()
1192 return ERR_PTR(-EINVAL); in thermal_zone_device_register_with_trips()
1198 * warning: right shift count >= width of type [-Wshift-count- overflow] in thermal_zone_device_register_with_trips()
1208 if (num_trips > (BITS_PER_TYPE(int) - 1) || num_trips < 0 || mask >> num_trips) { in thermal_zone_device_register_with_trips()
1210 return ERR_PTR(-EINVAL); in thermal_zone_device_register_with_trips()
1214 pr_err("Thermal zone device ops not defined\n"); in thermal_zone_device_register_with_trips()
1215 return ERR_PTR(-EINVAL); in thermal_zone_device_register_with_trips()
1218 if (num_trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp)) in thermal_zone_device_register_with_trips()
1219 return ERR_PTR(-EINVAL); in thermal_zone_device_register_with_trips()
1223 return ERR_PTR(-ENOMEM); in thermal_zone_device_register_with_trips()
1225 INIT_LIST_HEAD(&tz->thermal_instances); in thermal_zone_device_register_with_trips()
1226 ida_init(&tz->ida); in thermal_zone_device_register_with_trips()
1227 mutex_init(&tz->lock); in thermal_zone_device_register_with_trips()
1234 tz->id = id; in thermal_zone_device_register_with_trips()
1235 strscpy(tz->type, type, sizeof(tz->type)); in thermal_zone_device_register_with_trips()
1237 result = dev_set_name(&tz->device, "thermal_zone%d", tz->id); in thermal_zone_device_register_with_trips()
1241 if (!ops->critical) in thermal_zone_device_register_with_trips()
1242 ops->critical = thermal_zone_device_critical; in thermal_zone_device_register_with_trips()
1244 tz->ops = ops; in thermal_zone_device_register_with_trips()
1245 tz->tzp = tzp; in thermal_zone_device_register_with_trips()
1246 tz->device.class = &thermal_class; in thermal_zone_device_register_with_trips()
1247 tz->devdata = devdata; in thermal_zone_device_register_with_trips()
1248 tz->trips = trips; in thermal_zone_device_register_with_trips()
1249 tz->num_trips = num_trips; in thermal_zone_device_register_with_trips()
1251 thermal_set_delay_jiffies(&tz->passive_delay_jiffies, passive_delay); in thermal_zone_device_register_with_trips()
1252 thermal_set_delay_jiffies(&tz->polling_delay_jiffies, polling_delay); in thermal_zone_device_register_with_trips()
1261 atomic_set(&tz->need_update, 1); in thermal_zone_device_register_with_trips()
1263 result = device_register(&tz->device); in thermal_zone_device_register_with_trips()
1268 if (tz->ops->get_trip_type(tz, count, &trip_type) || in thermal_zone_device_register_with_trips()
1269 tz->ops->get_trip_temp(tz, count, &trip_temp) || in thermal_zone_device_register_with_trips()
1271 set_bit(count, &tz->trips_disabled); in thermal_zone_device_register_with_trips()
1277 if (tz->tzp) in thermal_zone_device_register_with_trips()
1278 governor = __find_governor(tz->tzp->governor_name); in thermal_zone_device_register_with_trips()
1290 if (!tz->tzp || !tz->tzp->no_hwmon) { in thermal_zone_device_register_with_trips()
1297 list_add_tail(&tz->node, &thermal_tz_list); in thermal_zone_device_register_with_trips()
1300 /* Bind cooling devices for this zone */ in thermal_zone_device_register_with_trips()
1303 INIT_DELAYED_WORK(&tz->poll_queue, thermal_zone_device_check); in thermal_zone_device_register_with_trips()
1307 if (atomic_cmpxchg(&tz->need_update, 1, 0)) in thermal_zone_device_register_with_trips()
1310 thermal_notify_tz_create(tz->id, tz->type); in thermal_zone_device_register_with_trips()
1315 device_del(&tz->device); in thermal_zone_device_register_with_trips()
1317 put_device(&tz->device); in thermal_zone_device_register_with_trips()
1339 * thermal_zone_device_unregister - removes the registered thermal zone device
1340 * @tz: the thermal zone device to remove
1352 tzp = tz->tzp; in thermal_zone_device_unregister()
1353 tz_id = tz->id; in thermal_zone_device_unregister()
1360 /* thermal zone device not found */ in thermal_zone_device_unregister()
1364 list_del(&tz->node); in thermal_zone_device_unregister()
1368 if (tz->ops->unbind) { in thermal_zone_device_unregister()
1369 tz->ops->unbind(tz, cdev); in thermal_zone_device_unregister()
1373 if (!tzp || !tzp->tbp) in thermal_zone_device_unregister()
1376 for (i = 0; i < tzp->num_tbps; i++) { in thermal_zone_device_unregister()
1377 if (tzp->tbp[i].cdev == cdev) { in thermal_zone_device_unregister()
1378 __unbind(tz, tzp->tbp[i].trip_mask, cdev); in thermal_zone_device_unregister()
1379 tzp->tbp[i].cdev = NULL; in thermal_zone_device_unregister()
1386 cancel_delayed_work_sync(&tz->poll_queue); in thermal_zone_device_unregister()
1391 ida_free(&thermal_tz_ida, tz->id); in thermal_zone_device_unregister()
1392 ida_destroy(&tz->ida); in thermal_zone_device_unregister()
1393 mutex_destroy(&tz->lock); in thermal_zone_device_unregister()
1394 device_unregister(&tz->device); in thermal_zone_device_unregister()
1401 * thermal_zone_get_zone_by_name() - search for a zone and returns its ref
1407 * matching name equals to @name, an ERR_PTR otherwise (-EINVAL for invalid
1408 * paramenters, -ENODEV for not found and -EEXIST for multiple matches).
1412 struct thermal_zone_device *pos = NULL, *ref = ERR_PTR(-EINVAL); in thermal_zone_get_zone_by_name()
1420 if (!strncasecmp(name, pos->type, THERMAL_NAME_LENGTH)) { in thermal_zone_get_zone_by_name()
1428 ref = ERR_PTR(-ENODEV); in thermal_zone_get_zone_by_name()
1431 ref = ERR_PTR(-EEXIST); in thermal_zone_get_zone_by_name()