diff options
Diffstat (limited to 'cputemp.c')
-rw-r--r-- | cputemp.c | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -87,6 +87,42 @@ void cputemp_read_hwmon(char *hwmon,char *sensor_name,struct s_sensor *sensor) hwmon_dirent=readdir(hwmon_dir); } closedir(hwmon_dir); + +// Some drivers do note have labels, so check the driver too if we didn't find anything so far + if (sensor->valid==0) + { + DEBUG2_CPUTEMP("Checking driver name\n"); + sprintf(sysfs_file,"%s/name",hwmon); + +// Read the name to see if it matches what we're looking for + datalen=sysfs_read_str(sysfs_file,buf,sizeof(buf)); + + if (datalen<0) + { + DEBUG2_CPUTEMP("Failed to driver name\n"); + } else { + DEBUG1_CPUTEMP("Name is: %s\n",buf); + if (strncasecmp(buf,sensor_name,255)==0) { + DEBUG2_CPUTEMP("Label machtes our search criteria\n"); + + sprintf(sysfs_file,"%s/temp1_input",hwmon); + DEBUG1_CPUTEMP("Input filename: %s\n",sysfs_file); + +// Validate the sensor by reading it + testdata=sysfs_read_long_int(sysfs_file); + DEBUG2_CPUTEMP("Input value: %ld\n",testdata); + if ((testdata>=VALID_TEMP_MIN) && (testdata<=VALID_TEMP_MAX)) + { + DEBUG1_CPUTEMP("Input data is valid, marking sensor as valid\n"); + sensor->valid=1; + strncpy(sensor->name,buf,sizeof(buf)); + strncpy(sensor->filename,sysfs_file,sizeof(sysfs_file)); + } else { + DEBUG1_CPUTEMP("Input data is invalid, ignoring sensor\n"); + } + } + } + } } // Find all entries under /sys/class/hwmon and check them with |