Hi there,
In power management group, we have a working item of exposing thermal information to user space through sysfs. However, so far, the thermal sensor drivers under 'drivers/hwmon' expose their information in various nodes under sysfs, which makes information collection difficult. Intel's thermal framework is located under 'drivers/thermal', but all the thermal drivers under hwmon don't make use of it due to some reason (part of the reason for this situation may be that intel's thermal framework is comparatively new therefore when those sensor drivers were implemented they did not have a framework to register themselves.) We like to find out a simple and unified way to expose thermal related information, intel's thermal interface could be a choice. Using thermal framework is straightforward, below is a sample driver for this purpose. Thus all the information goes to /sys/class/thermal, like temperature, mode...
... #include <linux/module.h> #include <linux/device.h> #include <linux/thermal.h> #include <linux/hwmon.h> static int thermal_get_temp(struct thermal_zone_device *thermal, unsigned long *temp) { *temp = xxx; return 0; } static struct device *hwmon; static struct thermal_zone_device *thermal; static struct thermal_zone_device_ops ops = { .get_temp = thermal_get_temp, }; static int __init sensor_init(void) { ... thermal = thermal_zone_device_register("sample", 0, 0, &ops, 0, 0, 0, 0); } static void __exit sensor_cleanup(void) { ... } module_init(sensor_init); module_exit(sensor_cleanup);
Are there any better ideas about this? Your comments are highly appreciated.
Yong