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 */
100 struct thermal_hwmon_device *hwmon;
104 list_for_each_entry(hwmon, &thermal_hwmon_list, node) {
107 if (!strcmp(hwmon->type, type)) {
109 return hwmon;
119 thermal_hwmon_lookup_temp(const struct thermal_hwmon_device *hwmon,
125 list_for_each_entry(temp, &hwmon->tz_list, hwmon_node)
143 struct thermal_hwmon_device *hwmon;
148 hwmon = thermal_hwmon_lookup_by_type(tz);
149 if (hwmon) {
154 hwmon = kzalloc(sizeof(*hwmon), GFP_KERNEL);
155 if (!hwmon)
158 INIT_LIST_HEAD(&hwmon->tz_list);
159 strscpy(hwmon->type, tz->type, THERMAL_NAME_LENGTH);
160 strreplace(hwmon->type, '-', '_');
161 hwmon->device = hwmon_device_register_for_thermal(&tz->device,
162 hwmon->type, hwmon);
163 if (IS_ERR(hwmon->device)) {
164 result = PTR_ERR(hwmon->device);
176 hwmon->count++;
179 "temp%d_input", hwmon->count);
184 result = device_create_file(hwmon->device, &temp->temp_input.attr);
191 "temp%d_crit", hwmon->count);
196 result = device_create_file(hwmon->device,
204 list_add_tail(&hwmon->node, &thermal_hwmon_list);
205 list_add_tail(&temp->hwmon_node, &hwmon->tz_list);
211 device_remove_file(hwmon->device, &temp->temp_input.attr);
216 hwmon_device_unregister(hwmon->device);
218 kfree(hwmon);
226 struct thermal_hwmon_device *hwmon;
229 hwmon = thermal_hwmon_lookup_by_type(tz);
230 if (unlikely(!hwmon)) {
232 dev_dbg(&tz->device, "hwmon device lookup failed!\n");
236 temp = thermal_hwmon_lookup_temp(hwmon, tz);
243 device_remove_file(hwmon->device, &temp->temp_input.attr);
245 device_remove_file(hwmon->device, &temp->temp_crit.attr);
250 if (!list_empty(&hwmon->tz_list)) {
254 list_del(&hwmon->node);
257 hwmon_device_unregister(hwmon->device);
258 kfree(hwmon);
281 dev_warn(dev, "Failed to add hwmon sysfs attributes\n");