Lines Matching defs:tz

47 	struct thermal_zone_device *tz;
102 struct thermal_zone_device *tz = to_thermal_zone(dev);
104 return sprintf(buf, "%s\n", tz->type);
110 struct thermal_zone_device *tz = to_thermal_zone(dev);
114 if (!tz->ops->get_temp)
117 ret = tz->ops->get_temp(tz, &temperature);
128 struct thermal_zone_device *tz = to_thermal_zone(dev);
132 if (!tz->ops->get_mode)
135 result = tz->ops->get_mode(tz, &mode);
147 struct thermal_zone_device *tz = to_thermal_zone(dev);
150 if (!tz->ops->set_mode)
154 result = tz->ops->set_mode(tz, THERMAL_DEVICE_ENABLED);
156 result = tz->ops->set_mode(tz, THERMAL_DEVICE_DISABLED);
170 struct thermal_zone_device *tz = to_thermal_zone(dev);
174 if (!tz->ops->get_trip_type)
180 result = tz->ops->get_trip_type(tz, trip, &type);
202 struct thermal_zone_device *tz = to_thermal_zone(dev);
206 if (!tz->ops->get_trip_temp)
212 ret = tz->ops->get_trip_temp(tz, trip, &temperature);
224 struct thermal_zone_device *tz = to_thermal_zone(dev);
237 if (state && !tz->forced_passive) {
242 thermal_zone_bind_cooling_device(tz,
247 if (!tz->passive_delay)
248 tz->passive_delay = 1000;
249 } else if (!state && tz->forced_passive) {
254 thermal_zone_unbind_cooling_device(tz,
259 tz->passive_delay = 0;
262 tz->tc1 = 1;
263 tz->tc2 = 1;
265 tz->forced_passive = state;
267 thermal_zone_device_update(tz);
276 struct thermal_zone_device *tz = to_thermal_zone(dev);
278 return sprintf(buf, "%d\n", tz->forced_passive);
422 struct thermal_zone_device *tz;
447 struct thermal_zone_device *tz = temp->tz;
449 ret = tz->ops->get_temp(tz, &temperature);
466 struct thermal_zone_device *tz = temp->tz;
470 ret = tz->ops->get_trip_temp(tz, 0, &temperature);
479 thermal_hwmon_lookup_by_type(const struct thermal_zone_device *tz)
485 if (!strcmp(hwmon->type, tz->type)) {
497 const struct thermal_zone_device *tz)
503 if (temp->tz == tz) {
513 thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
520 hwmon = thermal_hwmon_lookup_by_type(tz);
531 strlcpy(hwmon->type, tz->type, THERMAL_NAME_LENGTH);
549 temp->tz = tz;
562 if (tz->ops->get_crit_temp) {
564 if (!tz->ops->get_crit_temp(tz, &temperature)) {
603 thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz)
608 hwmon = thermal_hwmon_lookup_by_type(tz);
611 dev_dbg(&tz->device, "hwmon device lookup failed!\n");
615 temp = thermal_hwmon_lookup_temp(hwmon, tz);
618 dev_dbg(&tz->device, "temperature input lookup failed!\n");
623 if (tz->ops->get_crit_temp)
642 thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
648 thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz)
653 static void thermal_zone_device_set_polling(struct thermal_zone_device *tz,
656 cancel_delayed_work(&(tz->poll_queue));
662 queue_delayed_work(system_freezable_wq, &(tz->poll_queue),
665 queue_delayed_work(system_freezable_wq, &(tz->poll_queue),
669 static void thermal_zone_device_passive(struct thermal_zone_device *tz,
685 tz->passive = true;
687 trend = (tz->tc1 * (temp - tz->last_temperature)) +
688 (tz->tc2 * (temp - trip_temp));
692 list_for_each_entry(instance, &tz->cooling_devices,
703 list_for_each_entry(instance, &tz->cooling_devices,
724 list_for_each_entry(instance, &tz->cooling_devices, node) {
733 tz->passive = false;
739 struct thermal_zone_device *tz = container_of(work, struct
742 thermal_zone_device_update(tz);
747 * @tz: thermal zone device
754 int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
764 if (trip >= tz->trips || (trip < 0 && trip != THERMAL_TRIPS_NONE))
768 if (pos1 == tz)
776 if (tz != pos1 || cdev != pos2)
783 dev->tz = tz;
786 result = get_idr(&tz->idr, &tz->lock, &dev->id);
792 sysfs_create_link(&tz->device.kobj, &cdev->device.kobj, dev->name);
801 result = device_create_file(&tz->device, &dev->attr);
805 mutex_lock(&tz->lock);
806 list_for_each_entry(pos, &tz->cooling_devices, node)
807 if (pos->tz == tz && pos->trip == trip && pos->cdev == cdev) {
812 list_add_tail(&dev->node, &tz->cooling_devices);
813 mutex_unlock(&tz->lock);
818 device_remove_file(&tz->device, &dev->attr);
820 sysfs_remove_link(&tz->device.kobj, dev->name);
822 release_idr(&tz->idr, &tz->lock, dev->id);
831 * @tz: thermal zone device
838 int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz,
844 mutex_lock(&tz->lock);
845 list_for_each_entry_safe(pos, next, &tz->cooling_devices, node) {
846 if (pos->tz == tz && pos->trip == trip && pos->cdev == cdev) {
848 mutex_unlock(&tz->lock);
852 mutex_unlock(&tz->lock);
857 device_remove_file(&tz->device, &pos->attr);
858 sysfs_remove_link(&tz->device.kobj, pos->name);
859 release_idr(&tz->idr, &tz->lock, pos->id);
867 struct thermal_zone_device *tz;
872 tz = to_thermal_zone(dev);
873 kfree(tz);
976 struct thermal_zone_device *tz;
992 list_for_each_entry(tz, &thermal_tz_list, node) {
993 if (!tz->ops->unbind)
995 tz->ops->unbind(tz, cdev);
1014 void thermal_zone_device_update(struct thermal_zone_device *tz)
1022 mutex_lock(&tz->lock);
1024 if (tz->ops->get_temp(tz, &temp)) {
1026 pr_warn("failed to read out thermal zone %d\n", tz->id);
1030 for (count = 0; count < tz->trips; count++) {
1031 tz->ops->get_trip_type(tz, count, &trip_type);
1032 tz->ops->get_trip_temp(tz, count, &trip_temp);
1037 if (tz->ops->notify)
1038 ret = tz->ops->notify(tz, count,
1049 if (tz->ops->notify)
1050 tz->ops->notify(tz, count, trip_type);
1053 list_for_each_entry(instance, &tz->cooling_devices,
1067 if (temp >= trip_temp || tz->passive)
1068 thermal_zone_device_passive(tz, temp,
1074 if (tz->forced_passive)
1075 thermal_zone_device_passive(tz, temp, tz->forced_passive,
1078 tz->last_temperature = temp;
1081 if (tz->passive)
1082 thermal_zone_device_set_polling(tz, tz->passive_delay);
1083 else if (tz->polling_delay)
1084 thermal_zone_device_set_polling(tz, tz->polling_delay);
1086 thermal_zone_device_set_polling(tz, 0);
1087 mutex_unlock(&tz->lock);
1114 struct thermal_zone_device *tz;
1130 tz = kzalloc(sizeof(struct thermal_zone_device), GFP_KERNEL);
1131 if (!tz)
1134 INIT_LIST_HEAD(&tz->cooling_devices);
1135 idr_init(&tz->idr);
1136 mutex_init(&tz->lock);
1137 result = get_idr(&thermal_tz_idr, &thermal_idr_lock, &tz->id);
1139 kfree(tz);
1143 strcpy(tz->type, type);
1144 tz->ops = ops;
1145 tz->device.class = &thermal_class;
1146 tz->devdata = devdata;
1147 tz->trips = trips;
1148 tz->tc1 = tc1;
1149 tz->tc2 = tc2;
1150 tz->passive_delay = passive_delay;
1151 tz->polling_delay = polling_delay;
1153 dev_set_name(&tz->device, "thermal_zone%d", tz->id);
1154 result = device_register(&tz->device);
1156 release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id);
1157 kfree(tz);
1163 result = device_create_file(&tz->device, &dev_attr_type);
1168 result = device_create_file(&tz->device, &dev_attr_temp);
1173 result = device_create_file(&tz->device, &dev_attr_mode);
1179 result = device_create_file(&tz->device,
1183 result = device_create_file(&tz->device,
1187 tz->ops->get_trip_type(tz, count, &trip_type);
1193 result = device_create_file(&tz->device,
1199 result = thermal_add_hwmon_sysfs(tz);
1204 list_add_tail(&tz->node, &thermal_tz_list);
1207 result = ops->bind(tz, pos);
1213 INIT_DELAYED_WORK(&(tz->poll_queue), thermal_zone_device_check);
1215 thermal_zone_device_update(tz);
1218 return tz;
1221 release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id);
1222 device_unregister(&tz->device);
1229 * @tz: the thermal zone device to remove
1231 void thermal_zone_device_unregister(struct thermal_zone_device *tz)
1237 if (!tz)
1242 if (pos == tz)
1244 if (pos != tz) {
1249 list_del(&tz->node);
1250 if (tz->ops->unbind)
1252 tz->ops->unbind(tz, cdev);
1255 thermal_zone_device_set_polling(tz, 0);
1257 if (tz->type[0])
1258 device_remove_file(&tz->device, &dev_attr_type);
1259 device_remove_file(&tz->device, &dev_attr_temp);
1260 if (tz->ops->get_mode)
1261 device_remove_file(&tz->device, &dev_attr_mode);
1263 for (count = 0; count < tz->trips; count++) {
1264 device_remove_file(&tz->device,
1266 device_remove_file(&tz->device,
1269 thermal_remove_hwmon_sysfs(tz);
1270 release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id);
1271 idr_destroy(&tz->idr);
1272 mutex_destroy(&tz->lock);
1273 device_unregister(&tz->device);