Changeset 4646

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

Now that sensors_get_ignored() is an internal function, we can change
its prototype to suit our needs better.

* Pass the chip name by address.
* Pass the feature directly rather than its number.
* Switch to a sane convention for the returned value.
* Don't check for errors that can't happen.

Files:
1 modified

Legend:

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

    r4644 r4646  
    194194} 
    195195 
    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 
     196/* Looks up whether a feature should be ignored. Returns 
     197   1 if it should be ignored, 0 if not. This function takes 
    198198   logical mappings into account. */ 
    199 static int sensors_get_ignored(sensors_chip_name name, int feature) 
     199static int sensors_get_ignored(const sensors_chip_name *name, 
     200                               const sensors_chip_feature *feature) 
    200201{ 
    201202        const sensors_chip *chip; 
    202         const sensors_chip_feature *featureptr; 
    203         const sensors_chip_feature *alt_featureptr; 
     203        const char *main_feature_name; 
    204204        int i; 
    205205 
    206         if (sensors_chip_name_has_wildcards(name)) 
    207                 return -SENSORS_ERR_WILDCARDS; 
    208         if (!(featureptr = sensors_lookup_feature_nr(&name, feature))) 
    209                 return -SENSORS_ERR_NO_ENTRY; 
    210         if (featureptr->data.mapping == SENSORS_NO_MAPPING) 
    211                 alt_featureptr = NULL; 
    212         else if (!(alt_featureptr = 
    213                    sensors_lookup_feature_nr(&name, 
    214                                              featureptr->data.mapping))) 
    215                 return -SENSORS_ERR_NO_ENTRY; 
    216         for (chip = NULL; (chip = sensors_for_all_config_chips(name, chip));) 
     206        if (feature->data.mapping == SENSORS_NO_MAPPING) 
     207                main_feature_name = NULL; 
     208        else 
     209                main_feature_name = sensors_lookup_feature_nr(name, 
     210                                        feature->data.mapping)->data.name; 
     211 
     212        for (chip = NULL; (chip = sensors_for_all_config_chips(*name, chip));) 
    217213                for (i = 0; i < chip->ignores_count; i++) 
    218                         if (!strcasecmp(featureptr->data.name, chip->ignores[i].name) || 
    219                             (alt_featureptr && 
    220                              !strcasecmp(alt_featureptr->data.name, chip->ignores[i].name))) 
    221                                 return 0; 
    222         /* valid */ 
    223         return 1; 
     214                        if (!strcasecmp(feature->data.name, chip->ignores[i].name) || 
     215                            (main_feature_name && 
     216                             !strcasecmp(main_feature_name, chip->ignores[i].name))) 
     217                                return 1; 
     218        return 0; 
    224219} 
    225220 
     
    348343                        feature_list = sensors_proc_chips[i].feature; 
    349344                        while (feature_list[*nr].data.name 
    350                             && sensors_get_ignored(name, feature_list[*nr].data.number) != 1) 
     345                            && sensors_get_ignored(&name, &feature_list[*nr])) 
    351346                                (*nr)++; 
    352347                        if (!feature_list[*nr].data.name)