Lines Matching defs: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 */
94 struct thermal_hwmon_device *hwmon;
98 list_for_each_entry(hwmon, &thermal_hwmon_list, node) {
101 if (!strcmp(hwmon->type, type)) {
103 return hwmon;
113 thermal_hwmon_lookup_temp(const struct thermal_hwmon_device *hwmon,
119 list_for_each_entry(temp, &hwmon->tz_list, hwmon_node)
137 struct thermal_hwmon_device *hwmon;
142 hwmon = thermal_hwmon_lookup_by_type(tz);
143 if (hwmon) {
148 hwmon = kzalloc(sizeof(*hwmon), GFP_KERNEL);
149 if (!hwmon)
152 INIT_LIST_HEAD(&hwmon->tz_list);
153 strscpy(hwmon->type, tz->type, THERMAL_NAME_LENGTH);
154 strreplace(hwmon->type, '-', '_');
155 hwmon->device = hwmon_device_register_for_thermal(&tz->device,
156 hwmon->type, hwmon);
157 if (IS_ERR(hwmon->device)) {
158 result = PTR_ERR(hwmon->device);
170 hwmon->count++;
173 "temp%d_input", hwmon->count);
178 result = device_create_file(hwmon->device, &temp->temp_input.attr);
185 "temp%d_crit", hwmon->count);
190 result = device_create_file(hwmon->device,
198 list_add_tail(&hwmon->node, &thermal_hwmon_list);
199 list_add_tail(&temp->hwmon_node, &hwmon->tz_list);
205 device_remove_file(hwmon->device, &temp->temp_input.attr);
210 hwmon_device_unregister(hwmon->device);
212 kfree(hwmon);
220 struct thermal_hwmon_device *hwmon;
223 hwmon = thermal_hwmon_lookup_by_type(tz);
224 if (unlikely(!hwmon)) {
226 dev_dbg(&tz->device, "hwmon device lookup failed!\n");
230 temp = thermal_hwmon_lookup_temp(hwmon, tz);
237 device_remove_file(hwmon->device, &temp->temp_input.attr);
239 device_remove_file(hwmon->device, &temp->temp_crit.attr);
244 if (!list_empty(&hwmon->tz_list)) {
248 list_del(&hwmon->node);
251 hwmon_device_unregister(hwmon->device);
252 kfree(hwmon);
275 dev_warn(dev, "Failed to add hwmon sysfs attributes\n");