Lines Matching refs:tz
29 struct thermal_zone_device *tz = to_thermal_zone(dev); in type_show() local
31 return sprintf(buf, "%s\n", tz->type); in type_show()
37 struct thermal_zone_device *tz = to_thermal_zone(dev); in temp_show() local
40 ret = thermal_zone_get_temp(tz, &temperature); in temp_show()
51 struct thermal_zone_device *tz = to_thermal_zone(dev); in mode_show() local
54 mutex_lock(&tz->lock); in mode_show()
55 enabled = thermal_zone_device_is_enabled(tz); in mode_show()
56 mutex_unlock(&tz->lock); in mode_show()
65 struct thermal_zone_device *tz = to_thermal_zone(dev); in mode_store() local
69 result = thermal_zone_device_enable(tz); in mode_store()
71 result = thermal_zone_device_disable(tz); in mode_store()
85 struct thermal_zone_device *tz = to_thermal_zone(dev); in trip_point_type_show() local
89 if (!tz->ops->get_trip_type) in trip_point_type_show()
95 result = tz->ops->get_trip_type(tz, trip, &type); in trip_point_type_show()
117 struct thermal_zone_device *tz = to_thermal_zone(dev); in trip_point_temp_store() local
122 if (!tz->ops->set_trip_temp && !tz->trips) in trip_point_temp_store()
131 if (tz->ops->set_trip_temp) { in trip_point_temp_store()
132 ret = tz->ops->set_trip_temp(tz, trip, temperature); in trip_point_temp_store()
137 if (tz->trips) in trip_point_temp_store()
138 tz->trips[trip].temperature = temperature; in trip_point_temp_store()
140 if (tz->ops->get_trip_hyst) { in trip_point_temp_store()
141 ret = tz->ops->get_trip_hyst(tz, trip, &hyst); in trip_point_temp_store()
146 ret = tz->ops->get_trip_type(tz, trip, &type); in trip_point_temp_store()
150 thermal_notify_tz_trip_change(tz->id, trip, type, temperature, hyst); in trip_point_temp_store()
152 thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED); in trip_point_temp_store()
161 struct thermal_zone_device *tz = to_thermal_zone(dev); in trip_point_temp_show() local
165 if (!tz->ops->get_trip_temp) in trip_point_temp_show()
171 ret = tz->ops->get_trip_temp(tz, trip, &temperature); in trip_point_temp_show()
183 struct thermal_zone_device *tz = to_thermal_zone(dev); in trip_point_hyst_store() local
187 if (!tz->ops->set_trip_hyst) in trip_point_hyst_store()
201 ret = tz->ops->set_trip_hyst(tz, trip, temperature); in trip_point_hyst_store()
204 thermal_zone_set_trips(tz); in trip_point_hyst_store()
213 struct thermal_zone_device *tz = to_thermal_zone(dev); in trip_point_hyst_show() local
217 if (!tz->ops->get_trip_hyst) in trip_point_hyst_show()
223 ret = tz->ops->get_trip_hyst(tz, trip, &temperature); in trip_point_hyst_show()
232 struct thermal_zone_device *tz = to_thermal_zone(dev); in policy_store() local
238 ret = thermal_zone_device_set_policy(tz, name); in policy_store()
248 struct thermal_zone_device *tz = to_thermal_zone(dev); in policy_show() local
250 return sprintf(buf, "%s\n", tz->governor->name); in policy_show()
265 struct thermal_zone_device *tz = to_thermal_zone(dev); in emul_temp_store() local
272 if (!tz->ops->set_emul_temp) { in emul_temp_store()
273 mutex_lock(&tz->lock); in emul_temp_store()
274 tz->emul_temperature = temperature; in emul_temp_store()
275 mutex_unlock(&tz->lock); in emul_temp_store()
277 ret = tz->ops->set_emul_temp(tz, temperature); in emul_temp_store()
281 thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED); in emul_temp_store()
292 struct thermal_zone_device *tz = to_thermal_zone(dev); in sustainable_power_show() local
294 if (tz->tzp) in sustainable_power_show()
295 return sprintf(buf, "%u\n", tz->tzp->sustainable_power); in sustainable_power_show()
304 struct thermal_zone_device *tz = to_thermal_zone(dev); in sustainable_power_store() local
307 if (!tz->tzp) in sustainable_power_store()
313 tz->tzp->sustainable_power = sustainable_power; in sustainable_power_store()
323 struct thermal_zone_device *tz = to_thermal_zone(dev); \
325 if (tz->tzp) \
326 return sprintf(buf, "%d\n", tz->tzp->name); \
335 struct thermal_zone_device *tz = to_thermal_zone(dev); \
338 if (!tz->tzp) \
344 tz->tzp->name = value; \
422 static int create_trip_attrs(struct thermal_zone_device *tz, int mask) in create_trip_attrs() argument
428 if (tz->num_trips <= 0) in create_trip_attrs()
431 tz->trip_type_attrs = kcalloc(tz->num_trips, sizeof(*tz->trip_type_attrs), in create_trip_attrs()
433 if (!tz->trip_type_attrs) in create_trip_attrs()
436 tz->trip_temp_attrs = kcalloc(tz->num_trips, sizeof(*tz->trip_temp_attrs), in create_trip_attrs()
438 if (!tz->trip_temp_attrs) { in create_trip_attrs()
439 kfree(tz->trip_type_attrs); in create_trip_attrs()
443 if (tz->ops->get_trip_hyst) { in create_trip_attrs()
444 tz->trip_hyst_attrs = kcalloc(tz->num_trips, in create_trip_attrs()
445 sizeof(*tz->trip_hyst_attrs), in create_trip_attrs()
447 if (!tz->trip_hyst_attrs) { in create_trip_attrs()
448 kfree(tz->trip_type_attrs); in create_trip_attrs()
449 kfree(tz->trip_temp_attrs); in create_trip_attrs()
454 attrs = kcalloc(tz->num_trips * 3 + 1, sizeof(*attrs), GFP_KERNEL); in create_trip_attrs()
456 kfree(tz->trip_type_attrs); in create_trip_attrs()
457 kfree(tz->trip_temp_attrs); in create_trip_attrs()
458 if (tz->ops->get_trip_hyst) in create_trip_attrs()
459 kfree(tz->trip_hyst_attrs); in create_trip_attrs()
463 for (indx = 0; indx < tz->num_trips; indx++) { in create_trip_attrs()
465 snprintf(tz->trip_type_attrs[indx].name, THERMAL_NAME_LENGTH, in create_trip_attrs()
468 sysfs_attr_init(&tz->trip_type_attrs[indx].attr.attr); in create_trip_attrs()
469 tz->trip_type_attrs[indx].attr.attr.name = in create_trip_attrs()
470 tz->trip_type_attrs[indx].name; in create_trip_attrs()
471 tz->trip_type_attrs[indx].attr.attr.mode = S_IRUGO; in create_trip_attrs()
472 tz->trip_type_attrs[indx].attr.show = trip_point_type_show; in create_trip_attrs()
473 attrs[indx] = &tz->trip_type_attrs[indx].attr.attr; in create_trip_attrs()
476 snprintf(tz->trip_temp_attrs[indx].name, THERMAL_NAME_LENGTH, in create_trip_attrs()
479 sysfs_attr_init(&tz->trip_temp_attrs[indx].attr.attr); in create_trip_attrs()
480 tz->trip_temp_attrs[indx].attr.attr.name = in create_trip_attrs()
481 tz->trip_temp_attrs[indx].name; in create_trip_attrs()
482 tz->trip_temp_attrs[indx].attr.attr.mode = S_IRUGO; in create_trip_attrs()
483 tz->trip_temp_attrs[indx].attr.show = trip_point_temp_show; in create_trip_attrs()
486 tz->trip_temp_attrs[indx].attr.attr.mode |= S_IWUSR; in create_trip_attrs()
487 tz->trip_temp_attrs[indx].attr.store = in create_trip_attrs()
490 attrs[indx + tz->num_trips] = &tz->trip_temp_attrs[indx].attr.attr; in create_trip_attrs()
493 if (!tz->ops->get_trip_hyst) in create_trip_attrs()
495 snprintf(tz->trip_hyst_attrs[indx].name, THERMAL_NAME_LENGTH, in create_trip_attrs()
498 sysfs_attr_init(&tz->trip_hyst_attrs[indx].attr.attr); in create_trip_attrs()
499 tz->trip_hyst_attrs[indx].attr.attr.name = in create_trip_attrs()
500 tz->trip_hyst_attrs[indx].name; in create_trip_attrs()
501 tz->trip_hyst_attrs[indx].attr.attr.mode = S_IRUGO; in create_trip_attrs()
502 tz->trip_hyst_attrs[indx].attr.show = trip_point_hyst_show; in create_trip_attrs()
503 if (tz->ops->set_trip_hyst) { in create_trip_attrs()
504 tz->trip_hyst_attrs[indx].attr.attr.mode |= S_IWUSR; in create_trip_attrs()
505 tz->trip_hyst_attrs[indx].attr.store = in create_trip_attrs()
508 attrs[indx + tz->num_trips * 2] = in create_trip_attrs()
509 &tz->trip_hyst_attrs[indx].attr.attr; in create_trip_attrs()
511 attrs[tz->num_trips * 3] = NULL; in create_trip_attrs()
513 tz->trips_attribute_group.attrs = attrs; in create_trip_attrs()
524 static void destroy_trip_attrs(struct thermal_zone_device *tz) in destroy_trip_attrs() argument
526 if (!tz) in destroy_trip_attrs()
529 kfree(tz->trip_type_attrs); in destroy_trip_attrs()
530 kfree(tz->trip_temp_attrs); in destroy_trip_attrs()
531 if (tz->ops->get_trip_hyst) in destroy_trip_attrs()
532 kfree(tz->trip_hyst_attrs); in destroy_trip_attrs()
533 kfree(tz->trips_attribute_group.attrs); in destroy_trip_attrs()
536 int thermal_zone_create_device_groups(struct thermal_zone_device *tz, in thermal_zone_create_device_groups() argument
552 if (tz->num_trips) { in thermal_zone_create_device_groups()
553 result = create_trip_attrs(tz, mask); in thermal_zone_create_device_groups()
560 groups[size - 2] = &tz->trips_attribute_group; in thermal_zone_create_device_groups()
563 tz->device.groups = groups; in thermal_zone_create_device_groups()
568 void thermal_zone_destroy_device_groups(struct thermal_zone_device *tz) in thermal_zone_destroy_device_groups() argument
570 if (!tz) in thermal_zone_destroy_device_groups()
573 if (tz->num_trips) in thermal_zone_destroy_device_groups()
574 destroy_trip_attrs(tz); in thermal_zone_destroy_device_groups()
576 kfree(tz->device.groups); in thermal_zone_destroy_device_groups()