mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-10-22 11:46:03 +00:00
New sensors.conf keyword 'ignore'
This often-asked for, long-planned and somewhat-forgotten feature makes it possible to tell libsensors-linked applications (like the sensors program) that certain features should not be displayed. This is very nice for things like unconnected temperature sensors or fans. Modifications to the library code, to the sensors program and to the documentation and example sensors.conf file. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@676 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
01bad38253
commit
8199abde46
10 files changed
+648
-376
No files matched your search
+4
-3
@@ -14,7 +14,7 @@
|
||||
# quotes operate like those in C.
|
||||
|
||||
# A 'chip' line specifies what the following 'label', 'compute', 'set' and
|
||||
# (not yet implemented) 'valid' lines refer to. In this case, until the
|
||||
# 'ignore' lines refer to. In this case, until the
|
||||
# next 'chip' line, everything refers to all lm78, lm78-j and lm79
|
||||
# chips. Other examples are *-isa-* for everything on the ISA bus, and
|
||||
# lm78-j-i2c-*-4e for all lm78-j chips on address 0x4e of any I2C bus.
|
||||
@@ -101,10 +101,11 @@
|
||||
#set in0_max vid*1.05
|
||||
#set in0_min vid*0.95
|
||||
|
||||
# Invalid statements tell certain features are not wanted. User programs can
|
||||
# Ignore statements tell certain features are not wanted. User programs can
|
||||
# still read them if they really want, though; this is just an advisory
|
||||
# marking. 'in0' would also invalidate 'in0_max' and 'in0_min'.
|
||||
# The invalid keyword is not yet recognized by the parser.
|
||||
#
|
||||
#ignore in0
|
||||
|
||||
|
||||
# There is one other feature: the 'bus' statement. An example is below.
|
||||
|
||||
+2
-2
@@ -28,8 +28,8 @@ LIBMAN5DIR := $(MANDIR)/man5
|
||||
LIBMAN5FILES := $(MODULE_DIR)/sensors.conf.5
|
||||
|
||||
# The main and minor version of the library
|
||||
LIBMAINVER := 0
|
||||
LIBMINORVER := 0.2
|
||||
LIBMAINVER := 1
|
||||
LIBMINORVER := 0.0
|
||||
LIBVER := $(LIBMAINVER).$(LIBMINORVER)
|
||||
|
||||
# The static lib name, the shared lib name, and the internal ('so') name of
|
||||
|
||||
+48
-2
@@ -130,29 +130,75 @@ int sensors_chip_name_has_wildcards(sensors_chip_name chip)
|
||||
|
||||
/* Look up the label which belongs to this chip. Note that chip should not
|
||||
contain wildcard values! *result is newly allocated (free it yourself).
|
||||
This function will return 0 on success, and <0 on failure. */
|
||||
This function will return 0 on success, and <0 on failure.
|
||||
Changed behaviour as of libsensors.so.1: now we actually take notice
|
||||
of the logical class, as documented, but not done before! */
|
||||
int sensors_get_label(sensors_chip_name name, int feature, char **result)
|
||||
{
|
||||
const sensors_chip *chip;
|
||||
const sensors_chip_feature *featureptr;
|
||||
const sensors_chip_feature *alt_featureptr;
|
||||
int i;
|
||||
|
||||
*result=NULL;
|
||||
if (sensors_chip_name_has_wildcards(name))
|
||||
return -SENSORS_ERR_WILDCARDS;
|
||||
if (! (featureptr = sensors_lookup_feature_nr(name.prefix,feature)))
|
||||
return -SENSORS_ERR_NO_ENTRY;
|
||||
if (featureptr->logical_mapping == SENSORS_NO_MAPPING)
|
||||
alt_featureptr = NULL;
|
||||
else if (! (alt_featureptr =
|
||||
sensors_lookup_feature_nr(name.prefix,
|
||||
featureptr->logical_mapping)))
|
||||
return -SENSORS_ERR_NO_ENTRY;
|
||||
for (chip = NULL; (chip = sensors_for_all_config_chips(name,chip));)
|
||||
for (i = 0; i < chip->labels_count; i++)
|
||||
if (!strcmp(featureptr->name, chip->labels[i].name)) {
|
||||
if (*result)
|
||||
free(*result);
|
||||
if (! (*result = strdup(chip->labels[i].value)))
|
||||
sensors_fatal_error("sensors_get_label","Allocating label text");
|
||||
return 0; /* Exact match always overrules! */
|
||||
} else if (alt_featureptr &&
|
||||
!strcmp(alt_featureptr->name, chip->labels[i].name)) {
|
||||
if (*result)
|
||||
free(*result);
|
||||
if (! (*result = strdup(chip->labels[i].value)))
|
||||
sensors_fatal_error("sensors_get_label","Allocating label text");
|
||||
return 0;
|
||||
}
|
||||
if (! (*result = strdup(featureptr->name)))
|
||||
sensors_fatal_error("sensors_get_label","Allocating label text");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sensors_get_ignored(sensors_chip_name name, int feature)
|
||||
{
|
||||
const sensors_chip *chip;
|
||||
const sensors_chip_feature *featureptr;
|
||||
const sensors_chip_feature *alt_featureptr;
|
||||
int i,res;
|
||||
|
||||
res = 1; /* Default: valid */
|
||||
if (sensors_chip_name_has_wildcards(name))
|
||||
return -SENSORS_ERR_WILDCARDS;
|
||||
if (! (featureptr = sensors_lookup_feature_nr(name.prefix,feature)))
|
||||
return -SENSORS_ERR_NO_ENTRY;
|
||||
if (featureptr->logical_mapping == SENSORS_NO_MAPPING)
|
||||
alt_featureptr = NULL;
|
||||
else if (! (alt_featureptr =
|
||||
sensors_lookup_feature_nr(name.prefix,
|
||||
featureptr->logical_mapping)))
|
||||
return -SENSORS_ERR_NO_ENTRY;
|
||||
for (chip = NULL; (chip = sensors_for_all_config_chips(name,chip));)
|
||||
for (i = 0; i < chip->ignores_count; i++)
|
||||
if (!strcmp(featureptr->name, chip->ignores[i].name))
|
||||
return 0; /* Exact match always overrules! */
|
||||
else if (alt_featureptr &&
|
||||
!strcmp(alt_featureptr->name, chip->ignores[i].name))
|
||||
res = 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Read the value of a feature of a certain chip. Note that chip should not
|
||||
contain wildcard values! This function will return 0 on success, and <0
|
||||
on failure. */
|
||||
|
||||
@@ -124,6 +124,11 @@ OCTESC (1[0-7]{0,2})|([2-7][0-7]?)|(0[1-7][0-7]?)|(00[1-7])
|
||||
BEGIN(MIDDLE);
|
||||
return CHIP;
|
||||
}
|
||||
<INITIAL>"ignore" {
|
||||
sensors_yylval.line = sensors_yylineno;
|
||||
BEGIN(MIDDLE);
|
||||
return IGNORE;
|
||||
}
|
||||
|
||||
/* Anything else at the beginning of a line is an error */
|
||||
<INITIAL>. {
|
||||
|
||||
@@ -60,6 +60,11 @@ static sensors_chip *current_chip = NULL;
|
||||
¤t_chip->computes_count,\
|
||||
¤t_chip->computes_max,\
|
||||
sizeof(sensors_compute));
|
||||
#define ignore_add_el(el) sensors_add_array_el(el,\
|
||||
(void **) ¤t_chip->ignores,\
|
||||
¤t_chip->ignores_count,\
|
||||
¤t_chip->ignores_max,\
|
||||
sizeof(sensors_ignore));
|
||||
#define chip_add_el(el) sensors_add_array_el(el,\
|
||||
(void **) &sensors_config_chips,\
|
||||
&sensors_config_chips_count,\
|
||||
@@ -105,6 +110,7 @@ static sensors_chip *current_chip = NULL;
|
||||
%token <line> SET
|
||||
%token <line> CHIP
|
||||
%token <line> COMPUTE
|
||||
%token <line> IGNORE
|
||||
%token <value> FLOAT
|
||||
%token <name> NAME
|
||||
%token <nothing> ERROR
|
||||
@@ -131,6 +137,7 @@ line: bus_statement EOL
|
||||
| set_statement EOL
|
||||
| chip_statement EOL
|
||||
| compute_statement EOL
|
||||
| ignore_statement EOL
|
||||
| error EOL
|
||||
;
|
||||
|
||||
@@ -175,15 +182,25 @@ compute_statement: COMPUTE function_name expression ',' expression
|
||||
}
|
||||
;
|
||||
|
||||
ignore_statement: IGNORE function_name
|
||||
{ sensors_ignore new_el;
|
||||
check_current_chip();
|
||||
new_el.lineno = $1;
|
||||
new_el.name = $2;
|
||||
ignore_add_el(&new_el);
|
||||
}
|
||||
|
||||
chip_statement: CHIP chip_name_list
|
||||
{ sensors_chip new_el;
|
||||
new_el.lineno = $1;
|
||||
new_el.labels = NULL;
|
||||
new_el.sets = NULL;
|
||||
new_el.computes = NULL;
|
||||
new_el.ignores = NULL;
|
||||
new_el.labels_count = new_el.labels_max = 0;
|
||||
new_el.sets_count = new_el.sets_max = 0;
|
||||
new_el.computes_count = new_el.computes_max = 0;
|
||||
new_el.ignores_count = new_el.ignores_max = 0;
|
||||
new_el.chips = $2;
|
||||
chip_add_el(&new_el);
|
||||
current_chip = sensors_config_chips +
|
||||
|
||||
@@ -79,6 +79,12 @@ typedef struct sensors_compute {
|
||||
int lineno;
|
||||
} sensors_compute;
|
||||
|
||||
/* Config file ignore declaration: a feature name */
|
||||
typedef struct sensors_ignore {
|
||||
char *name;
|
||||
int lineno;
|
||||
} sensors_ignore;
|
||||
|
||||
/* A list of chip names, used to represent a config file chips declaration */
|
||||
typedef struct sensors_chip_name_list {
|
||||
sensors_chip_name *fits;
|
||||
@@ -98,6 +104,9 @@ typedef struct sensors_chip {
|
||||
sensors_compute *computes;
|
||||
int computes_count;
|
||||
int computes_max;
|
||||
sensors_ignore *ignores;
|
||||
int ignores_count;
|
||||
int ignores_max;
|
||||
int lineno;
|
||||
} sensors_chip;
|
||||
|
||||
|
||||
+11
@@ -33,6 +33,7 @@ static void free_chip(sensors_chip chip);
|
||||
static void free_label(sensors_label label);
|
||||
static void free_set(sensors_set set);
|
||||
static void free_compute(sensors_compute compute);
|
||||
static void free_ignore(sensors_ignore ignore);
|
||||
static void free_expr(sensors_expr *expr);
|
||||
|
||||
int sensors_init(FILE *input)
|
||||
@@ -114,6 +115,11 @@ void free_chip(sensors_chip chip)
|
||||
free_compute(chip.computes[i]);
|
||||
free(chip.computes);
|
||||
chip.computes_count = chip.computes_max = 0;
|
||||
|
||||
for (i = 0; i < chip.ignores_count; i++)
|
||||
free_ignore(chip.ignores[i]);
|
||||
free(chip.ignores);
|
||||
chip.ignores_count = chip.ignores_max = 0;
|
||||
}
|
||||
|
||||
void free_label(sensors_label label)
|
||||
@@ -135,6 +141,11 @@ void free_compute(sensors_compute compute)
|
||||
free_expr(compute.to_proc);
|
||||
}
|
||||
|
||||
void free_ignore(sensors_ignore ignore)
|
||||
{
|
||||
free(ignore.name);
|
||||
}
|
||||
|
||||
void free_expr(sensors_expr *expr)
|
||||
{
|
||||
if ((expr->kind) == sensors_kind_var)
|
||||
|
||||
+18
-1
@@ -57,6 +57,9 @@ compute
|
||||
,
|
||||
.B EXPR
|
||||
.sp 0
|
||||
ignore
|
||||
.B NAME
|
||||
.sp 0
|
||||
set
|
||||
.B NAME EXPR
|
||||
.RE
|
||||
@@ -239,7 +242,7 @@ lm78\-*
|
||||
.sp 0
|
||||
*\-i2c\-10\-5e
|
||||
.sp 0
|
||||
*\-i2c\-10-\*
|
||||
*\-i2c\-10\-*
|
||||
.sp 0
|
||||
*\-i2c\-*\-5e
|
||||
.sp 0
|
||||
@@ -283,6 +286,20 @@ statement applies, a one\-on\-one translation is used instead.
|
||||
The comma is an unfortunate necessity to stop the statement from becoming
|
||||
ambiguous.
|
||||
|
||||
.SS IGNORE STATEMENT
|
||||
.RS
|
||||
ignore fan1
|
||||
.RE
|
||||
|
||||
The
|
||||
.I ignore
|
||||
statement is a hint that a specific feature should be ignored - probably
|
||||
because it returns bogus values (for example, because a fan or temperature
|
||||
sensor is not connected).
|
||||
|
||||
The only argument is the feature name, which may be a feature class;
|
||||
in that case the label class is used (see below).
|
||||
|
||||
.SS LABEL STATEMENT
|
||||
.RS
|
||||
label in3 "+5V"
|
||||
|
||||
+7
-1
@@ -69,10 +69,16 @@ extern const char *sensors_get_algorithm_name(int bus_nr);
|
||||
|
||||
/* Look up the label which belongs to this chip. Note that chip should not
|
||||
contain wildcard values! *result is newly allocated (free it yourself).
|
||||
This function will return 0 on success, and <0 on failure. */
|
||||
This function will return 0 on success, and <0 on failure. This
|
||||
function takes logical mappings into account. */
|
||||
extern int sensors_get_label(sensors_chip_name name, int feature,
|
||||
char **result);
|
||||
|
||||
/* Looks up whether a feature should be ignored. Returns <0 on failure,
|
||||
0 if it should be ignored, 1 if it is valid. This function takes
|
||||
logical mappings into account. */
|
||||
extern int sensors_get_ignored(sensors_chip_name name, int fature);
|
||||
|
||||
/* Read the value of a feature of a certain chip. Note that chip should not
|
||||
contain wildcard values! This function will return 0 on success, and <0
|
||||
on failure. */
|
||||
|
||||
+527
-367
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user