mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-10-31 13:10:30 +00:00
add sensors_feature_get_type method, by Bob Schlarmann and Luuk Kleiweg
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4360 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
666fe95cdb
commit
05087736f8
2 files changed
+96
No files matched your search
@@ -496,3 +496,67 @@ int sensors_do_all_sets(void)
|
||||
};
|
||||
return sensors_do_chip_sets(name);
|
||||
}
|
||||
|
||||
/* Return the feature type based on the feature name */
|
||||
sensors_feature_type sensors_feature_get_type(
|
||||
const sensors_feature_data *feature)
|
||||
{
|
||||
const char *name;
|
||||
|
||||
/* this will only work when the sensors_chip_feature is obtained through
|
||||
sensors_get_all_features */
|
||||
if (((const struct sensors_chip_feature *)feature)->sysname)
|
||||
name = ((const struct sensors_chip_feature *)feature)->sysname;
|
||||
else
|
||||
name = feature->name;
|
||||
|
||||
if (strstr(name, "temp")) {
|
||||
if (strlen(name) == 5)
|
||||
return SENSORS_FEATURE_TEMP;
|
||||
|
||||
if (strstr(name, "hyst"))
|
||||
return SENSORS_FEATURE_TEMP_HYST;
|
||||
|
||||
if (strstr(name, "over"))
|
||||
return SENSORS_FEATURE_TEMP_OVER;
|
||||
|
||||
if (strstr(name, "max"))
|
||||
return SENSORS_FEATURE_TEMP_MAX;
|
||||
|
||||
if (strstr(name, "min"))
|
||||
return SENSORS_FEATURE_TEMP_MIN;
|
||||
|
||||
if (strstr(name, "low"))
|
||||
return SENSORS_FEATURE_TEMP_LOW;
|
||||
|
||||
if (strstr(name, "crit"))
|
||||
return SENSORS_FEATURE_TEMP_CRIT;
|
||||
} else if (strstr(name, "in") && name[0] != 'f') {
|
||||
if (strlen(name) == 3 || strstr(name, "input"))
|
||||
return SENSORS_FEATURE_IN;
|
||||
|
||||
if (strstr(name, "max"))
|
||||
return SENSORS_FEATURE_IN_MAX;
|
||||
|
||||
if (strstr(name, "min"))
|
||||
return SENSORS_FEATURE_IN_MIN;
|
||||
|
||||
if (strstr(name, "alarm"))
|
||||
return SENSORS_FEATURE_IN_ALARM;
|
||||
} else if (strstr(name, "fan")) {
|
||||
if (strlen(name) == 4)
|
||||
return SENSORS_FEATURE_FAN;
|
||||
|
||||
if (strstr(name, "min"))
|
||||
return SENSORS_FEATURE_FAN_MIN;
|
||||
|
||||
if (strstr(name, "div"))
|
||||
return SENSORS_FEATURE_FAN_DIV;
|
||||
} else if (!strcmp(name, "vrm")) {
|
||||
return SENSORS_FEATURE_VRM;
|
||||
} else if (strstr(name, "vid")) {
|
||||
return SENSORS_FEATURE_VID;
|
||||
}
|
||||
|
||||
return SENSORS_FEATURE_UNKNOWN;
|
||||
}
|
||||
@@ -146,6 +146,38 @@ typedef struct sensors_feature_data {
|
||||
extern const sensors_feature_data *sensors_get_all_features
|
||||
(sensors_chip_name name, int *nr1,int *nr2);
|
||||
|
||||
typedef enum sensors_feature_type {
|
||||
SENSORS_FEATURE_TEMP = 0,
|
||||
SENSORS_FEATURE_TEMP_ALARM,
|
||||
SENSORS_FEATURE_TEMP_HYST,
|
||||
SENSORS_FEATURE_TEMP_OVER,
|
||||
SENSORS_FEATURE_TEMP_MAX,
|
||||
SENSORS_FEATURE_TEMP_MIN,
|
||||
SENSORS_FEATURE_TEMP_HIGH,
|
||||
SENSORS_FEATURE_TEMP_LOW,
|
||||
SENSORS_FEATURE_TEMP_LIM,
|
||||
SENSORS_FEATURE_TEMP_CRIT,
|
||||
|
||||
SENSORS_FEATURE_IN,
|
||||
SENSORS_FEATURE_IN_ALARM,
|
||||
SENSORS_FEATURE_IN_MIN,
|
||||
SENSORS_FEATURE_IN_MAX,
|
||||
SENSORS_FEATURE_IN_MIN_ALARM,
|
||||
SENSORS_FEATURE_IN_MAX_ALARM,
|
||||
|
||||
SENSORS_FEATURE_FAN,
|
||||
SENSORS_FEATURE_FAN_ALARM,
|
||||
SENSORS_FEATURE_FAN_MIN,
|
||||
SENSORS_FEATURE_FAN_DIV,
|
||||
|
||||
SENSORS_FEATURE_VID,
|
||||
SENSORS_FEATURE_VRM,
|
||||
|
||||
SENSORS_FEATURE_UNKNOWN
|
||||
} sensors_feature_type;
|
||||
|
||||
sensors_feature_type sensors_feature_get_type(
|
||||
const sensors_feature_data *feature);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
Reference in new issue
Block a user