Lines Matching full:hwmon
3 * thermal_hwmon.c - Generic Thermal Management hwmon support.
15 #include <linux/hwmon.h>
22 /* hwmon sys I/F */
23 /* thermal zone devices with the same type share one hwmon device */
41 struct thermal_hwmon_attr temp_input; /* hwmon sys attr */
42 struct thermal_hwmon_attr temp_crit; /* hwmon sys attr */
97 struct thermal_hwmon_device *hwmon; in thermal_hwmon_lookup_by_type() local
101 list_for_each_entry(hwmon, &thermal_hwmon_list, node) { in thermal_hwmon_lookup_by_type()
104 if (!strcmp(hwmon->type, type)) { in thermal_hwmon_lookup_by_type()
106 return hwmon; in thermal_hwmon_lookup_by_type()
116 thermal_hwmon_lookup_temp(const struct thermal_hwmon_device *hwmon, in thermal_hwmon_lookup_temp() argument
122 list_for_each_entry(temp, &hwmon->tz_list, hwmon_node) in thermal_hwmon_lookup_temp()
140 struct thermal_hwmon_device *hwmon; in thermal_add_hwmon_sysfs() local
145 hwmon = thermal_hwmon_lookup_by_type(tz); in thermal_add_hwmon_sysfs()
146 if (hwmon) { in thermal_add_hwmon_sysfs()
151 hwmon = kzalloc(sizeof(*hwmon), GFP_KERNEL); in thermal_add_hwmon_sysfs()
152 if (!hwmon) in thermal_add_hwmon_sysfs()
155 INIT_LIST_HEAD(&hwmon->tz_list); in thermal_add_hwmon_sysfs()
156 strscpy(hwmon->type, tz->type, THERMAL_NAME_LENGTH); in thermal_add_hwmon_sysfs()
157 strreplace(hwmon->type, '-', '_'); in thermal_add_hwmon_sysfs()
158 hwmon->device = hwmon_device_register_for_thermal(&tz->device, in thermal_add_hwmon_sysfs()
159 hwmon->type, hwmon); in thermal_add_hwmon_sysfs()
160 if (IS_ERR(hwmon->device)) { in thermal_add_hwmon_sysfs()
161 result = PTR_ERR(hwmon->device); in thermal_add_hwmon_sysfs()
173 hwmon->count++; in thermal_add_hwmon_sysfs()
176 "temp%d_input", hwmon->count); in thermal_add_hwmon_sysfs()
181 result = device_create_file(hwmon->device, &temp->temp_input.attr); in thermal_add_hwmon_sysfs()
188 "temp%d_crit", hwmon->count); in thermal_add_hwmon_sysfs()
193 result = device_create_file(hwmon->device, in thermal_add_hwmon_sysfs()
201 list_add_tail(&hwmon->node, &thermal_hwmon_list); in thermal_add_hwmon_sysfs()
202 list_add_tail(&temp->hwmon_node, &hwmon->tz_list); in thermal_add_hwmon_sysfs()
208 device_remove_file(hwmon->device, &temp->temp_input.attr); in thermal_add_hwmon_sysfs()
213 hwmon_device_unregister(hwmon->device); in thermal_add_hwmon_sysfs()
215 kfree(hwmon); in thermal_add_hwmon_sysfs()
223 struct thermal_hwmon_device *hwmon; in thermal_remove_hwmon_sysfs() local
226 hwmon = thermal_hwmon_lookup_by_type(tz); in thermal_remove_hwmon_sysfs()
227 if (unlikely(!hwmon)) { in thermal_remove_hwmon_sysfs()
229 dev_dbg(&tz->device, "hwmon device lookup failed!\n"); in thermal_remove_hwmon_sysfs()
233 temp = thermal_hwmon_lookup_temp(hwmon, tz); in thermal_remove_hwmon_sysfs()
240 device_remove_file(hwmon->device, &temp->temp_input.attr); in thermal_remove_hwmon_sysfs()
242 device_remove_file(hwmon->device, &temp->temp_crit.attr); in thermal_remove_hwmon_sysfs()
247 if (!list_empty(&hwmon->tz_list)) { in thermal_remove_hwmon_sysfs()
251 list_del(&hwmon->node); in thermal_remove_hwmon_sysfs()
254 hwmon_device_unregister(hwmon->device); in thermal_remove_hwmon_sysfs()
255 kfree(hwmon); in thermal_remove_hwmon_sysfs()
278 dev_warn(dev, "Failed to add hwmon sysfs attributes\n"); in devm_thermal_add_hwmon_sysfs()