thermal_hwmon.c (0337966d121ebebf73a1c346123e8112796e684e) | thermal_hwmon.c (e782bc169cd02d3411a6db6ff0c26d7f27f8b81a) |
---|---|
1/* 2 * thermal_hwmon.c - Generic Thermal Management hwmon support. 3 * 4 * Code based on Intel thermal_core.c. Copyrights of the original code: 5 * Copyright (C) 2008 Intel Corp 6 * Copyright (C) 2008 Zhang Rui <rui.zhang@intel.com> 7 * Copyright (C) 2008 Sujith Thomas <sujith.thomas@intel.com> 8 * --- 45 unchanged lines hidden (view full) --- 54 struct thermal_hwmon_attr temp_crit; /* hwmon sys attr */ 55}; 56 57static LIST_HEAD(thermal_hwmon_list); 58 59static DEFINE_MUTEX(thermal_hwmon_list_lock); 60 61static ssize_t | 1/* 2 * thermal_hwmon.c - Generic Thermal Management hwmon support. 3 * 4 * Code based on Intel thermal_core.c. Copyrights of the original code: 5 * Copyright (C) 2008 Intel Corp 6 * Copyright (C) 2008 Zhang Rui <rui.zhang@intel.com> 7 * Copyright (C) 2008 Sujith Thomas <sujith.thomas@intel.com> 8 * --- 45 unchanged lines hidden (view full) --- 54 struct thermal_hwmon_attr temp_crit; /* hwmon sys attr */ 55}; 56 57static LIST_HEAD(thermal_hwmon_list); 58 59static DEFINE_MUTEX(thermal_hwmon_list_lock); 60 61static ssize_t |
62name_show(struct device *dev, struct device_attribute *attr, char *buf) 63{ 64 struct thermal_hwmon_device *hwmon = dev_get_drvdata(dev); 65 return sprintf(buf, "%s\n", hwmon->type); 66} 67static DEVICE_ATTR_RO(name); 68 69static ssize_t | |
70temp_input_show(struct device *dev, struct device_attribute *attr, char *buf) 71{ 72 int temperature; 73 int ret; 74 struct thermal_hwmon_attr *hwmon_attr 75 = container_of(attr, struct thermal_hwmon_attr, attr); 76 struct thermal_hwmon_temp *temp 77 = container_of(hwmon_attr, struct thermal_hwmon_temp, --- 82 unchanged lines hidden (view full) --- 160 } 161 162 hwmon = kzalloc(sizeof(*hwmon), GFP_KERNEL); 163 if (!hwmon) 164 return -ENOMEM; 165 166 INIT_LIST_HEAD(&hwmon->tz_list); 167 strlcpy(hwmon->type, tz->type, THERMAL_NAME_LENGTH); | 62temp_input_show(struct device *dev, struct device_attribute *attr, char *buf) 63{ 64 int temperature; 65 int ret; 66 struct thermal_hwmon_attr *hwmon_attr 67 = container_of(attr, struct thermal_hwmon_attr, attr); 68 struct thermal_hwmon_temp *temp 69 = container_of(hwmon_attr, struct thermal_hwmon_temp, --- 82 unchanged lines hidden (view full) --- 152 } 153 154 hwmon = kzalloc(sizeof(*hwmon), GFP_KERNEL); 155 if (!hwmon) 156 return -ENOMEM; 157 158 INIT_LIST_HEAD(&hwmon->tz_list); 159 strlcpy(hwmon->type, tz->type, THERMAL_NAME_LENGTH); |
168 hwmon->device = hwmon_device_register(NULL); | 160 hwmon->device = hwmon_device_register_with_info(NULL, hwmon->type, 161 hwmon, NULL, NULL); |
169 if (IS_ERR(hwmon->device)) { 170 result = PTR_ERR(hwmon->device); 171 goto free_mem; 172 } | 162 if (IS_ERR(hwmon->device)) { 163 result = PTR_ERR(hwmon->device); 164 goto free_mem; 165 } |
173 dev_set_drvdata(hwmon->device, hwmon); 174 result = device_create_file(hwmon->device, &dev_attr_name); 175 if (result) 176 goto free_mem; | |
177 178 register_sys_interface: 179 temp = kzalloc(sizeof(*temp), GFP_KERNEL); 180 if (!temp) { 181 result = -ENOMEM; 182 goto unregister_name; 183 } 184 --- 32 unchanged lines hidden (view full) --- 217 218 return 0; 219 220 unregister_input: 221 device_remove_file(hwmon->device, &temp->temp_input.attr); 222 free_temp_mem: 223 kfree(temp); 224 unregister_name: | 166 167 register_sys_interface: 168 temp = kzalloc(sizeof(*temp), GFP_KERNEL); 169 if (!temp) { 170 result = -ENOMEM; 171 goto unregister_name; 172 } 173 --- 32 unchanged lines hidden (view full) --- 206 207 return 0; 208 209 unregister_input: 210 device_remove_file(hwmon->device, &temp->temp_input.attr); 211 free_temp_mem: 212 kfree(temp); 213 unregister_name: |
225 if (new_hwmon_device) { 226 device_remove_file(hwmon->device, &dev_attr_name); | 214 if (new_hwmon_device) |
227 hwmon_device_unregister(hwmon->device); | 215 hwmon_device_unregister(hwmon->device); |
228 } | |
229 free_mem: 230 if (new_hwmon_device) 231 kfree(hwmon); 232 233 return result; 234} 235EXPORT_SYMBOL_GPL(thermal_add_hwmon_sysfs); 236 --- 25 unchanged lines hidden (view full) --- 262 kfree(temp); 263 if (!list_empty(&hwmon->tz_list)) { 264 mutex_unlock(&thermal_hwmon_list_lock); 265 return; 266 } 267 list_del(&hwmon->node); 268 mutex_unlock(&thermal_hwmon_list_lock); 269 | 216 free_mem: 217 if (new_hwmon_device) 218 kfree(hwmon); 219 220 return result; 221} 222EXPORT_SYMBOL_GPL(thermal_add_hwmon_sysfs); 223 --- 25 unchanged lines hidden (view full) --- 249 kfree(temp); 250 if (!list_empty(&hwmon->tz_list)) { 251 mutex_unlock(&thermal_hwmon_list_lock); 252 return; 253 } 254 list_del(&hwmon->node); 255 mutex_unlock(&thermal_hwmon_list_lock); 256 |
270 device_remove_file(hwmon->device, &dev_attr_name); | |
271 hwmon_device_unregister(hwmon->device); 272 kfree(hwmon); 273} 274EXPORT_SYMBOL_GPL(thermal_remove_hwmon_sysfs); | 257 hwmon_device_unregister(hwmon->device); 258 kfree(hwmon); 259} 260EXPORT_SYMBOL_GPL(thermal_remove_hwmon_sysfs); |