mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-21 19:51:45 +00:00
Rename struct sensors_feature_data to sensors_subfeature. This is a
first step towards a clean separation between main features and subfeatures. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4832 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
eba601a964
commit
79086fb7b8
10 files changed
+84
-83
No files matched your search
+28
-28
@@ -89,7 +89,7 @@ sensors_for_all_config_chips(const sensors_chip_name *name,
|
||||
/* Look up a resource in the intern chip list, and return a pointer to it.
|
||||
Do not modify the struct the return value points to! Returns NULL if
|
||||
not found.*/
|
||||
const sensors_feature_data *sensors_lookup_feature_nr(const sensors_chip_name *chip,
|
||||
const sensors_subfeature *sensors_lookup_feature_nr(const sensors_chip_name *chip,
|
||||
int feature)
|
||||
{
|
||||
int i;
|
||||
@@ -97,9 +97,9 @@ const sensors_feature_data *sensors_lookup_feature_nr(const sensors_chip_name *c
|
||||
for (i = 0; i < sensors_proc_chips_count; i++)
|
||||
if (sensors_match_chip(&sensors_proc_chips[i].chip, chip)) {
|
||||
if (feature < 0 ||
|
||||
feature >= sensors_proc_chips[i].feature_count)
|
||||
feature >= sensors_proc_chips[i].subfeature_count)
|
||||
return NULL;
|
||||
return sensors_proc_chips[i].feature + feature;
|
||||
return sensors_proc_chips[i].subfeature + feature;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -107,18 +107,18 @@ const sensors_feature_data *sensors_lookup_feature_nr(const sensors_chip_name *c
|
||||
/* Look up a resource in the intern chip list, and return a pointer to it.
|
||||
Do not modify the struct the return value points to! Returns NULL if
|
||||
not found.*/
|
||||
static const sensors_feature_data *
|
||||
static const sensors_subfeature *
|
||||
sensors_lookup_feature_name(const sensors_chip_name *chip, const char *feature)
|
||||
{
|
||||
int i, j;
|
||||
const sensors_feature_data *features;
|
||||
const sensors_subfeature *subfeatures;
|
||||
|
||||
for (i = 0; i < sensors_proc_chips_count; i++)
|
||||
if (sensors_match_chip(&sensors_proc_chips[i].chip, chip)) {
|
||||
features = sensors_proc_chips[i].feature;
|
||||
for (j = 0; j < sensors_proc_chips[i].feature_count; j++)
|
||||
if (!strcmp(features[j].name, feature))
|
||||
return features + j;
|
||||
subfeatures = sensors_proc_chips[i].subfeature;
|
||||
for (j = 0; j < sensors_proc_chips[i].subfeature_count; j++)
|
||||
if (!strcmp(subfeatures[j].name, feature))
|
||||
return subfeatures + j;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -145,7 +145,7 @@ char *sensors_get_label(const sensors_chip_name *name, int feature)
|
||||
{
|
||||
char *label;
|
||||
const sensors_chip *chip;
|
||||
const sensors_feature_data *featureptr;
|
||||
const sensors_subfeature *featureptr;
|
||||
char buf[128], path[PATH_MAX];
|
||||
FILE *f;
|
||||
int i;
|
||||
@@ -191,7 +191,7 @@ sensors_get_label_exit:
|
||||
1 if it should be ignored, 0 if not. This function takes
|
||||
mappings into account. */
|
||||
static int sensors_get_ignored(const sensors_chip_name *name,
|
||||
const sensors_feature_data *feature)
|
||||
const sensors_subfeature *feature)
|
||||
{
|
||||
const sensors_chip *chip;
|
||||
const char *main_feature_name;
|
||||
@@ -218,8 +218,8 @@ static int sensors_get_ignored(const sensors_chip_name *name,
|
||||
int sensors_get_value(const sensors_chip_name *name, int feature,
|
||||
double *result)
|
||||
{
|
||||
const sensors_feature_data *main_feature;
|
||||
const sensors_feature_data *alt_feature;
|
||||
const sensors_subfeature *main_feature;
|
||||
const sensors_subfeature *alt_feature;
|
||||
const sensors_chip *chip;
|
||||
const sensors_expr *expr = NULL;
|
||||
double val;
|
||||
@@ -265,8 +265,8 @@ int sensors_get_value(const sensors_chip_name *name, int feature,
|
||||
int sensors_set_value(const sensors_chip_name *name, int feature,
|
||||
double value)
|
||||
{
|
||||
const sensors_feature_data *main_feature;
|
||||
const sensors_feature_data *alt_feature;
|
||||
const sensors_subfeature *main_feature;
|
||||
const sensors_subfeature *alt_feature;
|
||||
const sensors_chip *chip;
|
||||
const sensors_expr *expr = NULL;
|
||||
int i, res;
|
||||
@@ -343,29 +343,29 @@ const char *sensors_get_adapter_name(const sensors_bus_id *bus)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const sensors_feature_data *
|
||||
static const sensors_subfeature *
|
||||
sensors_get_all_features(const sensors_chip_name *name, int *nr)
|
||||
{
|
||||
sensors_feature_data *feature_list;
|
||||
sensors_subfeature *subfeature_list;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sensors_proc_chips_count; i++)
|
||||
if (sensors_match_chip(&sensors_proc_chips[i].chip, name)) {
|
||||
feature_list = sensors_proc_chips[i].feature;
|
||||
while (*nr < sensors_proc_chips[i].feature_count
|
||||
&& sensors_get_ignored(name, &feature_list[*nr]))
|
||||
subfeature_list = sensors_proc_chips[i].subfeature;
|
||||
while (*nr < sensors_proc_chips[i].subfeature_count
|
||||
&& sensors_get_ignored(name, &subfeature_list[*nr]))
|
||||
(*nr)++;
|
||||
if (*nr == sensors_proc_chips[i].feature_count)
|
||||
if (*nr == sensors_proc_chips[i].subfeature_count)
|
||||
return NULL;
|
||||
return &feature_list[(*nr)++];
|
||||
return &subfeature_list[(*nr)++];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const sensors_feature_data *
|
||||
const sensors_subfeature *
|
||||
sensors_get_features(const sensors_chip_name *name, int *nr)
|
||||
{
|
||||
const sensors_feature_data *feature;
|
||||
const sensors_subfeature *feature;
|
||||
|
||||
while ((feature = sensors_get_all_features(name, nr))) {
|
||||
if (feature->mapping == SENSORS_NO_MAPPING)
|
||||
@@ -374,10 +374,10 @@ sensors_get_features(const sensors_chip_name *name, int *nr)
|
||||
return NULL; /* end of list */
|
||||
}
|
||||
|
||||
const sensors_feature_data *
|
||||
const sensors_subfeature *
|
||||
sensors_get_all_subfeatures(const sensors_chip_name *name, int feature, int *nr)
|
||||
{
|
||||
const sensors_feature_data *subfeature;
|
||||
const sensors_subfeature *subfeature;
|
||||
|
||||
/* Seek directly to the first subfeature */
|
||||
if (*nr < feature)
|
||||
@@ -399,7 +399,7 @@ int sensors_eval_expr(const sensors_chip_name *name,
|
||||
{
|
||||
double res1, res2;
|
||||
int res;
|
||||
const sensors_feature_data *feature;
|
||||
const sensors_subfeature *feature;
|
||||
|
||||
if (expr->kind == sensors_kind_val) {
|
||||
*result = expr->data.val;
|
||||
@@ -461,7 +461,7 @@ static int sensors_do_this_chip_sets(const sensors_chip_name *name)
|
||||
double value;
|
||||
int i, j;
|
||||
int err = 0, res;
|
||||
const sensors_feature_data *feature;
|
||||
const sensors_subfeature *feature;
|
||||
int *feature_list = NULL;
|
||||
int feature_count = 0;
|
||||
int feature_max = 0;
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
/* Look up a resource in the intern chip list, and return a pointer to it.
|
||||
Do not modify the struct the return value points to! Returns NULL if
|
||||
not found. */
|
||||
const sensors_feature_data *sensors_lookup_feature_nr(const sensors_chip_name *chip,
|
||||
const sensors_subfeature *sensors_lookup_feature_nr(const sensors_chip_name *chip,
|
||||
int feature);
|
||||
|
||||
/* Check whether the chip name is an 'absolute' name, which can only match
|
||||
|
||||
+2
-2
@@ -123,8 +123,8 @@ typedef struct sensors_bus {
|
||||
/* Internal data about all features of a type of chip */
|
||||
typedef struct sensors_chip_features {
|
||||
struct sensors_chip_name chip;
|
||||
struct sensors_feature_data *feature;
|
||||
int feature_count;
|
||||
struct sensors_subfeature *subfeature;
|
||||
int subfeature_count;
|
||||
} sensors_chip_features;
|
||||
|
||||
extern sensors_chip *sensors_config_chips;
|
||||
|
||||
+3
-3
@@ -56,9 +56,9 @@ static void free_chip_features(sensors_chip_features *features)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < features->feature_count; i++)
|
||||
free(features->feature[i].name);
|
||||
free(features->feature);
|
||||
for (i = 0; i < features->subfeature_count; i++)
|
||||
free(features->subfeature[i].name);
|
||||
free(features->subfeature);
|
||||
}
|
||||
|
||||
static void free_bus(sensors_bus *bus)
|
||||
|
||||
+4
-3
@@ -103,9 +103,10 @@ To start at the beginning of the list, use 0 for nr; NULL is returned if
|
||||
we are at the end of the list. Do not try to change these chip names, as
|
||||
they point to internal structures!
|
||||
|
||||
This structure is used when you want to get all features of a specific chip.
|
||||
This structure contains information related to a given subfeature of a
|
||||
specific chip.
|
||||
.br
|
||||
\fBtypedef struct sensors_feature_data {
|
||||
\fBtypedef struct sensors_subfeature {
|
||||
.br
|
||||
const char *name;
|
||||
.br
|
||||
@@ -117,7 +118,7 @@ This structure is used when you want to get all features of a specific chip.
|
||||
.br
|
||||
unsigned int flags;
|
||||
.br
|
||||
} sensors_feature_data;\fP
|
||||
} sensors_subfeature;\fP
|
||||
.br
|
||||
The flags field is a bitfield, its value is a combination of
|
||||
SENSORS_MODE_R (readable), SENSORS_MODE_W (writable) and SENSORS_COMPUTE_MAPPING
|
||||
|
||||
+12
-12
@@ -112,12 +112,12 @@ int sensors_do_chip_sets(const sensors_chip_name *name);
|
||||
const sensors_chip_name *sensors_get_detected_chips(const sensors_chip_name
|
||||
*match, int *nr);
|
||||
|
||||
/* These defines are used in the flags field of sensors_feature_data */
|
||||
/* These defines are used in the flags field of sensors_subfeature */
|
||||
#define SENSORS_MODE_R 1
|
||||
#define SENSORS_MODE_W 2
|
||||
#define SENSORS_COMPUTE_MAPPING 4
|
||||
|
||||
/* This define is used in the mapping field of sensors_feature_data if no
|
||||
/* This define is used in the mapping field of sensors_subfeature if no
|
||||
mapping is available */
|
||||
#define SENSORS_NO_MAPPING -1
|
||||
|
||||
@@ -163,32 +163,32 @@ typedef enum sensors_feature_type {
|
||||
SENSORS_FEATURE_UNKNOWN = INT_MAX,
|
||||
} sensors_feature_type;
|
||||
|
||||
/* Data about a single chip feature:
|
||||
name is the string name used to refer to this feature (in config files)
|
||||
number is the internal feature number, used in many functions to refer
|
||||
/* Data about a single chip subfeature:
|
||||
name is the string name used to refer to this subfeature (in config files)
|
||||
number is the internal subfeature number, used in many functions to refer
|
||||
to this feature
|
||||
type is the feature or subfeature type
|
||||
mapping is either SENSORS_NO_MAPPING if this is feature is the
|
||||
main element of category; or it is the number of a feature with which
|
||||
type is the subfeature type
|
||||
mapping is either SENSORS_NO_MAPPING if this subfeature is the
|
||||
main element of category; or it is the number of a subfeature with which
|
||||
this subfeature is logically grouped (a group could be fan, fan_min
|
||||
and fan_div)
|
||||
flags 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) */
|
||||
typedef struct sensors_feature_data {
|
||||
typedef struct sensors_subfeature {
|
||||
char *name;
|
||||
int number;
|
||||
sensors_feature_type type;
|
||||
int mapping;
|
||||
unsigned int flags;
|
||||
} sensors_feature_data;
|
||||
} sensors_subfeature;
|
||||
|
||||
/* 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 *
|
||||
const sensors_subfeature *
|
||||
sensors_get_features(const sensors_chip_name *name, int *nr);
|
||||
|
||||
/* This returns all subfeatures of a given main feature (including that
|
||||
@@ -197,7 +197,7 @@ sensors_get_features(const sensors_chip_name *name, int *nr);
|
||||
features are found NULL is returned.
|
||||
Do not try to change the returned structure; you will corrupt internal
|
||||
data structures. */
|
||||
const sensors_feature_data *
|
||||
const sensors_subfeature *
|
||||
sensors_get_all_subfeatures(const sensors_chip_name *name, int feature, int *nr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
+17
-17
@@ -161,8 +161,8 @@ static int sensors_read_dynamic_chip(sensors_chip_features *chip,
|
||||
int i, type, fnum = 0;
|
||||
struct sysfs_attribute *attr;
|
||||
struct dlist *attrs;
|
||||
sensors_feature_data *features;
|
||||
sensors_feature_data *dyn_features;
|
||||
sensors_subfeature *features;
|
||||
sensors_subfeature *dyn_subfeatures;
|
||||
|
||||
attrs = sysfs_get_device_attributes(sysdir);
|
||||
|
||||
@@ -172,7 +172,7 @@ static int sensors_read_dynamic_chip(sensors_chip_features *chip,
|
||||
/* We use a large sparse table at first to store all found features,
|
||||
so that we can store them sorted at type and index and then later
|
||||
create a dense sorted table. */
|
||||
features = calloc(ALL_POSSIBLE_FEATURES, sizeof(sensors_feature_data));
|
||||
features = calloc(ALL_POSSIBLE_FEATURES, sizeof(sensors_subfeature));
|
||||
if (!features)
|
||||
sensors_fatal_error(__FUNCTION__, "Out of memory");
|
||||
|
||||
@@ -253,41 +253,41 @@ static int sensors_read_dynamic_chip(sensors_chip_features *chip,
|
||||
}
|
||||
|
||||
if (!fnum) { /* No feature */
|
||||
chip->feature = NULL;
|
||||
chip->subfeature = NULL;
|
||||
goto exit_free;
|
||||
}
|
||||
|
||||
dyn_features = calloc(fnum, sizeof(sensors_feature_data));
|
||||
if (dyn_features == NULL) {
|
||||
dyn_subfeatures = calloc(fnum, sizeof(sensors_subfeature));
|
||||
if (dyn_subfeatures == NULL) {
|
||||
sensors_fatal_error(__FUNCTION__, "Out of memory");
|
||||
}
|
||||
|
||||
fnum = 0;
|
||||
for (i = 0; i < ALL_POSSIBLE_FEATURES; i++) {
|
||||
if (features[i].name) {
|
||||
dyn_features[fnum] = features[i];
|
||||
dyn_subfeatures[fnum] = features[i];
|
||||
fnum++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Number the features linearly, so that feature number N is at
|
||||
/* Number the subfeatures linearly, so that feature number N is at
|
||||
position N in the array. This allows for O(1) look-ups. */
|
||||
for (i = 0; i < fnum; i++) {
|
||||
int j;
|
||||
|
||||
dyn_features[i].number = i;
|
||||
if (dyn_features[i].mapping == SENSORS_NO_MAPPING) {
|
||||
dyn_subfeatures[i].number = i;
|
||||
if (dyn_subfeatures[i].mapping == SENSORS_NO_MAPPING) {
|
||||
/* Main feature, set the mapping field of all its
|
||||
subfeatures */
|
||||
for (j = i + 1; j < fnum &&
|
||||
dyn_features[j].mapping != SENSORS_NO_MAPPING;
|
||||
dyn_subfeatures[j].mapping != SENSORS_NO_MAPPING;
|
||||
j++)
|
||||
dyn_features[j].mapping = i;
|
||||
dyn_subfeatures[j].mapping = i;
|
||||
}
|
||||
}
|
||||
|
||||
chip->feature = dyn_features;
|
||||
chip->feature_count = fnum;
|
||||
chip->subfeature = dyn_subfeatures;
|
||||
chip->subfeature_count = fnum;
|
||||
|
||||
exit_free:
|
||||
free(features);
|
||||
@@ -375,7 +375,7 @@ static int sensors_read_one_sysfs_chip(struct sysfs_device *dev)
|
||||
|
||||
if (sensors_read_dynamic_chip(&entry, dev) < 0)
|
||||
goto exit_free;
|
||||
if (!entry.feature) { /* No feature, discard chip */
|
||||
if (!entry.subfeature) { /* No feature, discard chip */
|
||||
err = 0;
|
||||
goto exit_free;
|
||||
}
|
||||
@@ -513,7 +513,7 @@ exit0:
|
||||
int sensors_read_sysfs_attr(const sensors_chip_name *name, int feature,
|
||||
double *value)
|
||||
{
|
||||
const sensors_feature_data *the_feature;
|
||||
const sensors_subfeature *the_feature;
|
||||
char n[NAME_MAX];
|
||||
FILE *f;
|
||||
const char *suffix = "";
|
||||
@@ -544,7 +544,7 @@ int sensors_read_sysfs_attr(const sensors_chip_name *name, int feature,
|
||||
int sensors_write_sysfs_attr(const sensors_chip_name *name, int feature,
|
||||
double value)
|
||||
{
|
||||
const sensors_feature_data *the_feature;
|
||||
const sensors_subfeature *the_feature;
|
||||
char n[NAME_MAX];
|
||||
FILE *f;
|
||||
const char *suffix = "";
|
||||
|
||||
Reference in new issue
Block a user