mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-29 21:08:19 +00:00
Split sensors_get_all_features() into two distinct functions, one to
get the list of all main features, and one to get the list of all the subfeatures of a given main feature. This is a more logical interface for applications to use. The current implementation is admittedly less than optimal, because the storage structures weren't meant for it, but this issue can (and will) be addressed later. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4831 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
08a686e3cc
commit
eba601a964
6 files changed
+130
-90
No files matched your search
+32
-3
@@ -343,9 +343,8 @@ const char *sensors_get_adapter_name(const sensors_bus_id *bus)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* nr-1 is the last feature returned */
|
||||
const sensors_feature_data *sensors_get_all_features(const sensors_chip_name *name,
|
||||
int *nr)
|
||||
static const sensors_feature_data *
|
||||
sensors_get_all_features(const sensors_chip_name *name, int *nr)
|
||||
{
|
||||
sensors_feature_data *feature_list;
|
||||
int i;
|
||||
@@ -363,6 +362,36 @@ const sensors_feature_data *sensors_get_all_features(const sensors_chip_name *na
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const sensors_feature_data *
|
||||
sensors_get_features(const sensors_chip_name *name, int *nr)
|
||||
{
|
||||
const sensors_feature_data *feature;
|
||||
|
||||
while ((feature = sensors_get_all_features(name, nr))) {
|
||||
if (feature->mapping == SENSORS_NO_MAPPING)
|
||||
return feature;
|
||||
}
|
||||
return NULL; /* end of list */
|
||||
}
|
||||
|
||||
const sensors_feature_data *
|
||||
sensors_get_all_subfeatures(const sensors_chip_name *name, int feature, int *nr)
|
||||
{
|
||||
const sensors_feature_data *subfeature;
|
||||
|
||||
/* Seek directly to the first subfeature */
|
||||
if (*nr < feature)
|
||||
*nr = feature;
|
||||
|
||||
subfeature = sensors_get_all_features(name, nr);
|
||||
if (!subfeature)
|
||||
return NULL; /* end of list */
|
||||
if (subfeature->number == feature ||
|
||||
subfeature->mapping == feature)
|
||||
return subfeature;
|
||||
return NULL; /* end of subfeature list */
|
||||
}
|
||||
|
||||
/* Evaluate an expression */
|
||||
int sensors_eval_expr(const sensors_chip_name *name,
|
||||
const sensors_expr *expr,
|
||||
|
||||
Reference in new issue
Block a user