Changeset 4644

Show
Ignore:
Timestamp:
07/24/07 10:20:53 (7 years ago)
Author:
khali
Message:

Let libsensors handle ignore statements by itself, rather than
delegating the task to the user applications.

For now, I am calling sensors_get_ignored() in
sensors_get_all_features(), because this is the least intrusive way.
This is in no way optimal though, it would be better to not add
ignored features to the feature list in the first place. However,
doing so would require that the configuration file is read before
sysfs is scanned for features, which isn't currently the case. So
this improvement is left for later.

Note that this patch adds a small cost in terms of performance. This
is because we now honor ignore statements on all features (main ones
and subfeatures) while in practice "sensors" was only checking for
main features. It would be trivial to stop checking for subfeatures,
but it seems to me that supporting ignore on subfeatures is a good
move, as the user may actually want to ignore a specific subfeature.
Individual alarms come to mind. This will also be handy to debug the
generic print code in "sensors".

Location:
lm-sensors/branches/lm-sensors-3.0.0
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/branches/lm-sensors-3.0.0/lib/access.c

    r4643 r4644  
    194194} 
    195195 
    196 int sensors_get_ignored(sensors_chip_name name, int feature) 
     196/* Looks up whether a feature should be ignored. Returns <0 on failure, 
     197   0 if it should be ignored, 1 if it is valid. This function takes 
     198   logical mappings into account. */ 
     199static int sensors_get_ignored(sensors_chip_name name, int feature) 
    197200{ 
    198201        const sensors_chip *chip; 
     
    344347                if (sensors_match_chip(sensors_proc_chips[i].chip, name)) { 
    345348                        feature_list = sensors_proc_chips[i].feature; 
     349                        while (feature_list[*nr].data.name 
     350                            && sensors_get_ignored(name, feature_list[*nr].data.number) != 1) 
     351                                (*nr)++; 
    346352                        if (!feature_list[*nr].data.name) 
    347353                                return NULL; 
  • lm-sensors/branches/lm-sensors-3.0.0/lib/sensors.h

    r4643 r4644  
    8383extern int sensors_get_label(sensors_chip_name name, int feature,  
    8484                             char **result); 
    85  
    86 /* Looks up whether a feature should be ignored. Returns <0 on failure, 
    87    0 if it should be ignored, 1 if it is valid. This function takes 
    88    logical mappings into account. */ 
    89 extern int sensors_get_ignored(sensors_chip_name name, int fature); 
    9085 
    9186/* Read the value of a feature of a certain chip. Note that chip should not 
  • lm-sensors/branches/lm-sensors-3.0.0/prog/sensors/chips.c

    r4643 r4644  
    9292  int err; 
    9393  err = sensors_get_label(name,feature,label); 
    94   if (!err) 
    95     err = sensors_get_ignored(name,feature); 
    96   if (err >= 0) { 
    97     *valid = err; 
    98     err = 0; 
    99   } 
     94  *valid = !err; 
    10095  return err; 
    10196}