mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-27 20:48:22 +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,
|
||||
|
||||
+18
-10
@@ -44,8 +44,10 @@ libsensors \- publicly accessible functions provided by the sensors library
|
||||
.B int sensors_do_chip_sets(const sensors_chip_name *name);
|
||||
.B const sensors_chip_name *sensors_get_detected_chips(const sensors_chip_name
|
||||
\fB*match, int *nr);\fP
|
||||
.B const sensors_feature_data *sensors_get_all_features
|
||||
.B const sensors_feature_data *sensors_get_features
|
||||
\fB(const sensors_chip_name *name, int *nr);\fP
|
||||
.B const sensors_feature_data *sensors_get_all_subfeatures
|
||||
\fB(const sensors_chip_name *name, int feature, int *nr);\fP
|
||||
.B const char *libsensors_version;
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
@@ -121,16 +123,22 @@ The flags field is a bitfield, its value is a combination of
|
||||
SENSORS_MODE_R (readable), SENSORS_MODE_W (writable) and SENSORS_COMPUTE_MAPPING
|
||||
(affected by the computation rules of the main feature).
|
||||
|
||||
\fBconst sensors_feature_data *sensors_get_all_features
|
||||
(const sensors_chip_name *name, int *nr);\fP
|
||||
\fBconst sensors_feature_data *sensors_get_features(const sensors_chip_name *name, int *nr);\fP
|
||||
.br
|
||||
This returns all features of a specific chip. They are returned in bunches:
|
||||
everything with the same mapping is returned just after each other, with
|
||||
the master feature in front (that feature does not map to itself, but
|
||||
has SENSORS_NO_MAPPING as mapping field). nr is an internally used variable.
|
||||
Set it to zero to start again at the begin of the list. If no more features
|
||||
are found NULL is returned. Do not try to change the returned structure; you
|
||||
will corrupt internal data structures.
|
||||
This returns all main features of a specific chip. nr is an internally
|
||||
used variable. Set it to zero to start at the begin of the list. If no
|
||||
more features are found NULL is returned.
|
||||
Do not try to change the returned structure; you will corrupt internal
|
||||
data structures.
|
||||
|
||||
\fBconst sensors_feature_data *sensors_get_all_subfeatures(const sensors_chip_name *name, int feature, int *nr);\fP
|
||||
.br
|
||||
This returns all subfeatures of a given main feature (including that
|
||||
main feature itself, in first position.) nr is an internally used
|
||||
variable. Set it to zero to start at the begin of the list. If no more
|
||||
features are found NULL is returned.
|
||||
Do not try to change the returned structure; you will corrupt internal
|
||||
data structures.
|
||||
|
||||
\fBconst char *libsensors_version;\fP
|
||||
.br
|
||||
|
||||
+14
-8
@@ -183,16 +183,22 @@ typedef struct sensors_feature_data {
|
||||
unsigned int flags;
|
||||
} sensors_feature_data;
|
||||
|
||||
/* This returns all features of a specific chip. They are returned in
|
||||
bunches: everything with the same mapping is returned just after each
|
||||
other, with the master feature in front (that feature does not map to
|
||||
itself, but has SENSORS_NO_MAPPING as mapping field). nr is
|
||||
an internally used variable. Set it to zero to start again at the
|
||||
begin of the list. If no more features are found NULL is returned.
|
||||
/* This returns all main features of a specific chip. nr is an internally
|
||||
used variable. Set it to zero to start at the begin of the list. If no
|
||||
more features are found NULL is returned.
|
||||
Do not try to change the returned structure; you will corrupt internal
|
||||
data structures. */
|
||||
const sensors_feature_data *sensors_get_all_features
|
||||
(const sensors_chip_name *name, int *nr);
|
||||
const sensors_feature_data *
|
||||
sensors_get_features(const sensors_chip_name *name, int *nr);
|
||||
|
||||
/* This returns all subfeatures of a given main feature (including that
|
||||
main feature itself, in first position.) nr is an internally used
|
||||
variable. Set it to zero to start at the begin of the list. If no more
|
||||
features are found NULL is returned.
|
||||
Do not try to change the returned structure; you will corrupt internal
|
||||
data structures. */
|
||||
const sensors_feature_data *
|
||||
sensors_get_all_subfeatures(const sensors_chip_name *name, int feature, int *nr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user