Use the feature type rather than the feature name to figure out whether

we need to add "_input" to get the correct sysfs file name. This is
much faster. This is still a ugly hack I'd like to get rid of, but at
least now the slowdown is acceptable.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4743 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare committed 2007-09-02 11:09:16 +00:00
1 parent 4b012c9f63
commit 75859ca9dc
1 file changed
+6 -10
+6 -10
View File
@@ -411,17 +411,15 @@ int sensors_read_sysfs_attr(const sensors_chip_name *name, int feature,
int mag;
char n[NAME_MAX];
FILE *f;
int dummy;
char check;
const char *suffix = "";
if (!(the_feature = sensors_lookup_feature_nr(name, feature)))
return -SENSORS_ERR_NO_ENTRY;
/* REVISIT: this is a ugly hack */
if (sscanf(the_feature->data.name, "in%d%c", &dummy, &check) == 1
|| sscanf(the_feature->data.name, "fan%d%c", &dummy, &check) == 1
|| sscanf(the_feature->data.name, "temp%d%c", &dummy, &check) == 1)
if (the_feature->data.type == SENSORS_FEATURE_IN
|| the_feature->data.type == SENSORS_FEATURE_FAN
|| the_feature->data.type == SENSORS_FEATURE_TEMP)
suffix = "_input";
snprintf(n, NAME_MAX, "%s/%s%s", name->path, the_feature->data.name,
@@ -446,17 +444,15 @@ int sensors_write_sysfs_attr(const sensors_chip_name *name, int feature,
int mag;
char n[NAME_MAX];
FILE *f;
int dummy;
char check;
const char *suffix = "";
if (!(the_feature = sensors_lookup_feature_nr(name, feature)))
return -SENSORS_ERR_NO_ENTRY;
/* REVISIT: this is a ugly hack */
if (sscanf(the_feature->data.name, "in%d%c", &dummy, &check) == 1
|| sscanf(the_feature->data.name, "fan%d%c", &dummy, &check) == 1
|| sscanf(the_feature->data.name, "temp%d%c", &dummy, &check) == 1)
if (the_feature->data.type == SENSORS_FEATURE_IN
|| the_feature->data.type == SENSORS_FEATURE_FAN
|| the_feature->data.type == SENSORS_FEATURE_TEMP)
suffix = "_input";
snprintf(n, NAME_MAX, "%s/%s%s", name->path, the_feature->data.name,