aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPA4WDH2024-07-28 15:57:46 +0200
committerPA4WDH2024-07-28 15:57:46 +0200
commitadeba6b981c4dd9830caf01113209a4c15f98018 (patch)
treed13b3543faa7661b7944ecf349c0ea1812f1185e
parentRewrite cpufreq_set_str to use opendir/readdir/closedir (diff)
downloadcputemp2maxfreq-adeba6b981c4dd9830caf01113209a4c15f98018.tar.gz
cputemp2maxfreq-adeba6b981c4dd9830caf01113209a4c15f98018.tar.bz2
cputemp2maxfreq-adeba6b981c4dd9830caf01113209a4c15f98018.zip
Check driver names in autodetection
-rw-r--r--cputemp.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/cputemp.c b/cputemp.c
index 559056f..0960662 100644
--- a/cputemp.c
+++ b/cputemp.c
@@ -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