Changeset 4836

Show
Ignore:
Timestamp:
09/23/07 14:07:53 (6 years ago)
Author:
khali
Message:

Update the comments and symbols in the whole library code to refer to
features and subfeatures as appropriate.

Location:
lm-sensors/branches/lm-sensors-3.0.0/lib
Files:
9 modified

Legend:

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

    r4835 r4836  
    8787} 
    8888 
    89 /* Look up a resource in the intern chip list, and return a pointer to it.  
     89/* Look up a subfeature in the intern chip list, and return a pointer to it. 
    9090   Do not modify the struct the return value points to! Returns NULL if  
    9191   not found.*/ 
    92 const sensors_subfeature *sensors_lookup_feature_nr(const sensors_chip_name *chip, 
    93                                                       int feature) 
     92const sensors_subfeature * 
     93sensors_lookup_subfeature_nr(const sensors_chip_name *chip, 
     94                             int subfeat_nr) 
    9495{ 
    9596        int i; 
     
    9798        for (i = 0; i < sensors_proc_chips_count; i++) 
    9899                if (sensors_match_chip(&sensors_proc_chips[i].chip, chip)) { 
    99                         if (feature < 0 || 
    100                             feature >= sensors_proc_chips[i].subfeature_count) 
     100                        if (subfeat_nr < 0 || 
     101                            subfeat_nr >= sensors_proc_chips[i].subfeature_count) 
    101102                                return NULL; 
    102                         return sensors_proc_chips[i].subfeature + feature; 
     103                        return sensors_proc_chips[i].subfeature + subfeat_nr; 
    103104                } 
    104105        return NULL; 
     
    109110   not found.*/ 
    110111static const sensors_subfeature * 
    111 sensors_lookup_feature_name(const sensors_chip_name *chip, const char *feature) 
     112sensors_lookup_subfeature_name(const sensors_chip_name *chip, 
     113                               const char *name) 
    112114{ 
    113115        int i, j; 
     
    118120                        subfeatures = sensors_proc_chips[i].subfeature; 
    119121                        for (j = 0; j < sensors_proc_chips[i].subfeature_count; j++) 
    120                                 if (!strcmp(subfeatures[j].name, feature)) 
     122                                if (!strcmp(subfeatures[j].name, name)) 
    121123                                        return subfeatures + j; 
    122124                } 
     
    138140} 
    139141 
    140 /* Look up the label which belongs to this chip. Note that chip should not 
     142/* Look up the label for a given feature. Note that chip should not 
    141143   contain wildcard values! The returned string is newly allocated (free it 
    142144   yourself). On failure, NULL is returned. 
     
    200202} 
    201203 
    202 /* Read the value of a feature of a certain chip. Note that chip should not 
     204/* Read the value of a subfeature of a certain chip. Note that chip should not 
    203205   contain wildcard values! This function will return 0 on success, and <0 
    204206   on failure. */ 
    205 int sensors_get_value(const sensors_chip_name *name, int feature, 
     207int sensors_get_value(const sensors_chip_name *name, int subfeat_nr, 
    206208                      double *result) 
    207209{ 
    208         const sensors_subfeature *main_feature; 
     210        const sensors_subfeature *subfeature; 
    209211        const sensors_subfeature *alt_feature; 
    210212        const sensors_chip *chip; 
     
    216218        if (sensors_chip_name_has_wildcards(name)) 
    217219                return -SENSORS_ERR_WILDCARDS; 
    218         if (!(main_feature = sensors_lookup_feature_nr(name, feature))) 
     220        if (!(subfeature = sensors_lookup_subfeature_nr(name, subfeat_nr))) 
    219221                return -SENSORS_ERR_NO_ENTRY; 
    220222 
    221         if (main_feature->flags & SENSORS_COMPUTE_MAPPING) 
    222                 alt_feature = sensors_lookup_feature_nr(name, 
    223                                         main_feature->mapping); 
     223        if (subfeature->flags & SENSORS_COMPUTE_MAPPING) 
     224                alt_feature = sensors_lookup_subfeature_nr(name, 
     225                                        subfeature->mapping); 
    224226        else 
    225227                alt_feature = NULL; 
    226228 
    227         if (!(main_feature->flags & SENSORS_MODE_R)) 
     229        if (!(subfeature->flags & SENSORS_MODE_R)) 
    228230                return -SENSORS_ERR_ACCESS_R; 
    229231        for (chip = NULL; 
    230232             !expr && (chip = sensors_for_all_config_chips(name, chip));) 
    231233                for (i = 0; !final_expr && (i < chip->computes_count); i++) { 
    232                         if (!strcmp(main_feature->name, chip->computes[i].name)) { 
     234                        if (!strcmp(subfeature->name, chip->computes[i].name)) { 
    233235                                expr = chip->computes[i].from_proc; 
    234236                                final_expr = 1; 
     
    238240                        } 
    239241                } 
    240         if (sensors_read_sysfs_attr(name, feature, &val)) 
     242        if (sensors_read_sysfs_attr(name, subfeat_nr, &val)) 
    241243                return -SENSORS_ERR_PROC; 
    242244        if (!expr) 
     
    247249} 
    248250 
    249 /* Set the value of a feature of a certain chip. Note that chip should not 
     251/* Set the value of a subfeature of a certain chip. Note that chip should not 
    250252   contain wildcard values! This function will return 0 on success, and <0 
    251253   on failure. */ 
    252 int sensors_set_value(const sensors_chip_name *name, int feature, 
     254int sensors_set_value(const sensors_chip_name *name, int subfeat_nr, 
    253255                      double value) 
    254256{ 
    255         const sensors_subfeature *main_feature; 
     257        const sensors_subfeature *subfeature; 
    256258        const sensors_subfeature *alt_feature; 
    257259        const sensors_chip *chip; 
     
    263265        if (sensors_chip_name_has_wildcards(name)) 
    264266                return -SENSORS_ERR_WILDCARDS; 
    265         if (!(main_feature = sensors_lookup_feature_nr(name, feature))) 
     267        if (!(subfeature = sensors_lookup_subfeature_nr(name, subfeat_nr))) 
    266268                return -SENSORS_ERR_NO_ENTRY; 
    267269 
    268         if (main_feature->flags & SENSORS_COMPUTE_MAPPING) 
    269                 alt_feature = sensors_lookup_feature_nr(name, 
    270                                         main_feature->mapping); 
     270        if (subfeature->flags & SENSORS_COMPUTE_MAPPING) 
     271                alt_feature = sensors_lookup_subfeature_nr(name, 
     272                                        subfeature->mapping); 
    271273        else 
    272274                alt_feature = NULL; 
    273275 
    274         if (!(main_feature->flags & SENSORS_MODE_W)) 
     276        if (!(subfeature->flags & SENSORS_MODE_W)) 
    275277                return -SENSORS_ERR_ACCESS_W; 
    276278        for (chip = NULL; 
    277279             !expr && (chip = sensors_for_all_config_chips(name, chip));) 
    278280                for (i = 0; !final_expr && (i < chip->computes_count); i++) 
    279                         if (!strcmp(main_feature->name, chip->computes[i].name)) { 
     281                        if (!strcmp(subfeature->name, chip->computes[i].name)) { 
    280282                                expr = chip->computes->to_proc; 
    281283                                final_expr = 1; 
     
    289291                if ((res = sensors_eval_expr(name, expr, value, &to_write))) 
    290292                        return res; 
    291         if (sensors_write_sysfs_attr(name, feature, to_write)) 
     293        if (sensors_write_sysfs_attr(name, subfeat_nr, to_write)) 
    292294                return -SENSORS_ERR_PROC; 
    293295        return 0; 
     
    381383        double res1, res2; 
    382384        int res; 
    383         const sensors_subfeature *feature; 
     385        const sensors_subfeature *subfeature; 
    384386 
    385387        if (expr->kind == sensors_kind_val) { 
     
    392394        } 
    393395        if (expr->kind == sensors_kind_var) { 
    394                 if (!(feature = sensors_lookup_feature_name(name, 
     396                if (!(subfeature = sensors_lookup_subfeature_name(name, 
    395397                                                            expr->data.var))) 
    396398                        return SENSORS_ERR_NO_ENTRY; 
    397                 if (!(res = sensors_get_value(name, feature->number, result))) 
     399                if (!(res = sensors_get_value(name, subfeature->number, 
     400                                              result))) 
    398401                        return res; 
    399402                return 0; 
     
    443446        int i, j; 
    444447        int err = 0, res; 
    445         const sensors_subfeature *feature; 
     448        const sensors_subfeature *subfeature; 
    446449        int *feature_list = NULL; 
    447450        int feature_count = 0; 
    448451        int feature_max = 0; 
    449         int feature_nr; 
     452        int subfeat_nr; 
    450453 
    451454        for (chip = NULL; (chip = sensors_for_all_config_chips(name, chip));) 
    452455                for (i = 0; i < chip->sets_count; i++) { 
    453                         feature = sensors_lookup_feature_name(name, 
     456                        subfeature = sensors_lookup_subfeature_name(name, 
    454457                                                        chip->sets[i].name); 
    455                         if (!feature) { 
     458                        if (!subfeature) { 
    456459                                sensors_parse_error("Unknown feature name", 
    457460                                                    chip->sets[i].lineno); 
     
    459462                                continue; 
    460463                        } 
    461                         feature_nr = feature->number; 
     464                        subfeat_nr = subfeature->number; 
    462465 
    463466                        /* Check whether we already set this feature */ 
    464467                        for (j = 0; j < feature_count; j++) 
    465                                 if (feature_list[j] == feature_nr) 
     468                                if (feature_list[j] == subfeat_nr) 
    466469                                        break; 
    467470                        if (j != feature_count) 
    468471                                continue; 
    469                         sensors_add_array_el(&feature_nr, &feature_list, 
     472                        sensors_add_array_el(&subfeat_nr, &feature_list, 
    470473                                             &feature_count, &feature_max, 
    471474                                             sizeof(int)); 
     
    479482                                continue; 
    480483                        } 
    481                         if ((res = sensors_set_value(name, feature_nr, value))) { 
    482                                 sensors_parse_error("Failed to set feature", 
     484                        if ((res = sensors_set_value(name, subfeat_nr, value))) { 
     485                                sensors_parse_error("Failed to set value", 
    483486                                                chip->sets[i].lineno); 
    484487                                err = res; 
  • lm-sensors/branches/lm-sensors-3.0.0/lib/access.h

    r4832 r4836  
    2424#include "data.h" 
    2525 
    26 /* Look up a resource in the intern chip list, and return a pointer to it. 
     26/* Look up a subfeature in the intern chip list, and return a pointer to it. 
    2727   Do not modify the struct the return value points to! Returns NULL if 
    2828   not found. */ 
    29 const sensors_subfeature *sensors_lookup_feature_nr(const sensors_chip_name *chip, 
    30                                                       int feature); 
     29const sensors_subfeature * 
     30sensors_lookup_subfeature_nr(const sensors_chip_name *chip, 
     31                             int subfeat_nr); 
    3132 
    3233/* Check whether the chip name is an 'absolute' name, which can only match 
  • lm-sensors/branches/lm-sensors-3.0.0/lib/data.h

    r4834 r4836  
    6666} sensors_label; 
    6767 
    68 /* Config file set declaration: a feature name, combined with an expression */ 
     68/* Config file set declaration: a subfeature name, combined with an 
     69   expression */ 
    6970typedef struct sensors_set { 
    7071        char *name; 
     
    121122} sensors_bus; 
    122123 
    123 /* Internal data about all features of a type of chip */ 
     124/* Internal data about all features and subfeatures of a chip */ 
    124125typedef struct sensors_chip_features { 
    125126        struct sensors_chip_name chip; 
  • lm-sensors/branches/lm-sensors-3.0.0/lib/error.c

    r4736 r4836  
    3434        /* Unknown error         */ "sensors_strerror: Unknown error!", 
    3535        /* SENSORS_ERR_WILDCARDS */ "Wildcard found in chip name", 
    36         /* SENSORS_ERR_NO_ENTRY  */ "No such feature known", 
     36        /* SENSORS_ERR_NO_ENTRY  */ "No such subfeature known", 
    3737        /* SENSORS_ERR_ACCESS    */ "Can't read or write", 
    3838        /* SENSORS_ERR_PROC      */ "Can't access sysfs file", 
  • lm-sensors/branches/lm-sensors-3.0.0/lib/error.h

    r4736 r4836  
    2222 
    2323#define SENSORS_ERR_WILDCARDS 1 /* Wildcard found in chip name */ 
    24 #define SENSORS_ERR_NO_ENTRY 2  /* No such feature known */ 
     24#define SENSORS_ERR_NO_ENTRY 2  /* No such subfeature known */ 
    2525#define SENSORS_ERR_ACCESS 3    /* Can't read or write */ 
    2626#define SENSORS_ERR_PROC 4      /* Can't access /proc file */ 
  • lm-sensors/branches/lm-sensors-3.0.0/lib/libsensors.3

    r4834 r4836  
    3838.B const char *sensors_get_adapter_name(int bus_nr); 
    3939.B char *sensors_get_label(const sensors_chip_name *name, const sensors_feature *feature);\fP 
    40 .B int sensors_get_value(const sensors_chip_name *name, int feature, 
     40.B int sensors_get_value(const sensors_chip_name *name, int subfeat_nr, 
    4141                      \fBdouble *value);\fP 
    42 .B int sensors_set_value(const sensors_chip_name *name, int feature, 
     42.B int sensors_set_value(const sensors_chip_name *name, int subfeat_nr, 
    4343                      \fBdouble value);\fP 
    4444.B int sensors_do_chip_sets(const sensors_chip_name *name); 
     
    7979If no label exists for this feature, its name is returned itself. 
    8080 
    81 \fBint sensors_get_value(const sensors_chip_name *name, 
    82                       int feature, double *value);\fP 
     81\fBint sensors_get_value(const sensors_chip_name *name, int subfeat_nr, double *value);\fP 
    8382.br 
    84 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. 
     83Read the value of a subfeature of a certain chip. Note that chip should not 
     84contain wildcard values! This function will return 0 on success, and <0 on 
     85failure. 
    8586 
    86 \fBint sensors_set_value(const sensors_chip_name *name, 
    87                       int feature, double value);\fP 
     87\fBint sensors_set_value(const sensors_chip_name *name, int subfeat_nr, double value);\fP 
    8888.br 
    89 Set 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. 
     89Set the value of a subfeature of a certain chip. Note that chip should not 
     90contain wildcard values! This function will return 0 on success, and <0 on 
     91failure. 
    9092 
    9193.B int sensors_do_chip_sets(const sensors_chip_name *name); 
  • lm-sensors/branches/lm-sensors-3.0.0/lib/sensors.h

    r4834 r4836  
    8585typedef struct sensors_feature sensors_feature; 
    8686 
    87 /* Look up the label which belongs to this chip. Note that chip should not 
     87/* Look up the label for a given feature. Note that chip should not 
    8888   contain wildcard values! The returned string is newly allocated (free it 
    8989   yourself). On failure, NULL is returned. 
     
    9292                        const sensors_feature *feature); 
    9393 
    94 /* Read the value of a feature of a certain chip. Note that chip should not 
     94/* Read the value of a subfeature of a certain chip. Note that chip should not 
    9595   contain wildcard values! This function will return 0 on success, and <0 
    9696   on failure.  */ 
    97 int sensors_get_value(const sensors_chip_name *name, int feature, 
     97int sensors_get_value(const sensors_chip_name *name, int subfeat_nr, 
    9898                      double *value); 
    9999 
    100 /* Set the value of a feature of a certain chip. Note that chip should not 
     100/* Set the value of a subfeature of a certain chip. Note that chip should not 
    101101   contain wildcard values! This function will return 0 on success, and <0 
    102102   on failure. */ 
    103 int sensors_set_value(const sensors_chip_name *name, int feature, 
     103int sensors_set_value(const sensors_chip_name *name, int subfeat_nr, 
    104104                      double value); 
    105105 
     
    127127/* This enum contains some "magic" used by sensors_read_dynamic_chip() from 
    128128   lib/sysfs.c. All the sensor types (in, fan, temp, vid) are a multiple of 
    129    0x100 apart, and sensor features which should not have a compute mapping to 
    130    the _input feature start at 0x?10. */ 
     129   0x100 apart, and sensor subfeatures which should not have a compute 
     130   mapping to the _input subfeature start at 0x?10. */ 
    131131typedef enum sensors_feature_type { 
    132132        SENSORS_FEATURE_IN = 0x000, 
     
    177177   name is the string name used to refer to this subfeature (in config files) 
    178178   number is the internal subfeature number, used in many functions to refer 
    179      to this feature 
     179     to this subfeature 
    180180   type is the subfeature type 
    181181   mapping is either SENSORS_NO_MAPPING if this subfeature is the 
  • lm-sensors/branches/lm-sensors-3.0.0/lib/sysfs.c

    r4834 r4836  
    3939 
    4040#define MAX_SENSORS_PER_TYPE    20 
    41 #define MAX_SUB_FEATURES        8 
     41#define MAX_SUBFEATURES         8 
    4242/* Room for all 3 types (in, fan, temp) with all their subfeatures + VID 
    4343   + misc features */ 
    44 #define ALL_POSSIBLE_FEATURES   (MAX_SENSORS_PER_TYPE * MAX_SUB_FEATURES * 6 \ 
     44#define ALL_POSSIBLE_SUBFEATURES \ 
     45                                (MAX_SENSORS_PER_TYPE * MAX_SUBFEATURES * 6 \ 
    4546                                 + MAX_SENSORS_PER_TYPE + 1) 
    4647 
     
    6566} 
    6667 
    67 /* Static mappings for use by sensors_feature_get_type() */ 
     68/* Static mappings for use by sensors_subfeature_get_type() */ 
    6869struct feature_subtype_match 
    6970{ 
     
    126127}; 
    127128 
    128 /* Return the feature type and channel number based on the feature name */ 
     129/* Return the subfeature type and channel number based on the subfeature 
     130   name */ 
    129131static 
    130 sensors_feature_type sensors_feature_get_type(const char *name, int *nr) 
     132sensors_feature_type sensors_subfeature_get_type(const char *name, int *nr) 
    131133{ 
    132134        char c; 
     
    162164        struct sysfs_attribute *attr; 
    163165        struct dlist *attrs; 
    164         sensors_subfeature *features; 
     166        sensors_subfeature *all_subfeatures; 
    165167        sensors_subfeature *dyn_subfeatures; 
    166168        sensors_feature *dyn_features; 
     
    171173                return -ENOENT; 
    172174 
    173         /* We use a large sparse table at first to store all found features, 
    174            so that we can store them sorted at type and index and then later 
    175            create a dense sorted table. */ 
    176         features = calloc(ALL_POSSIBLE_FEATURES, sizeof(sensors_subfeature)); 
    177         if (!features) 
     175        /* We use a large sparse table at first to store all found 
     176           subfeatures, so that we can store them sorted at type and index 
     177           and then later create a dense sorted table. */ 
     178        all_subfeatures = calloc(ALL_POSSIBLE_SUBFEATURES, 
     179                                 sizeof(sensors_subfeature)); 
     180        if (!all_subfeatures) 
    178181                sensors_fatal_error(__FUNCTION__, "Out of memory"); 
    179182 
     
    182185                int nr; 
    183186 
    184                 type = sensors_feature_get_type(name, &nr); 
     187                type = sensors_subfeature_get_type(name, &nr); 
    185188                if (type == SENSORS_FEATURE_UNKNOWN) 
    186189                        continue; 
     
    198201                        fprintf(stderr, "libsensors error, more sensors of one" 
    199202                                " type then MAX_SENSORS_PER_TYPE, ignoring " 
    200                                 "feature: %s\n", name); 
     203                                "subfeature: %s\n", name); 
    201204                        continue; 
    202205                } 
    203206 
    204                 /* "calculate" a place to store the feature in our sparse, 
     207                /* "calculate" a place to store the subfeature in our sparse, 
    205208                   sorted table */ 
    206209                switch (type) { 
    207210                case SENSORS_FEATURE_VID: 
    208                         i = nr + MAX_SENSORS_PER_TYPE * MAX_SUB_FEATURES * 6; 
     211                        i = nr + MAX_SENSORS_PER_TYPE * MAX_SUBFEATURES * 6; 
    209212                        break; 
    210213                case SENSORS_FEATURE_BEEP_ENABLE: 
    211                         i = MAX_SENSORS_PER_TYPE * MAX_SUB_FEATURES * 6 + 
     214                        i = MAX_SENSORS_PER_TYPE * MAX_SUBFEATURES * 6 + 
    212215                            MAX_SENSORS_PER_TYPE; 
    213216                        break; 
    214217                default: 
    215218                        i = (type >> 8) * MAX_SENSORS_PER_TYPE * 
    216                             MAX_SUB_FEATURES * 2 + nr * MAX_SUB_FEATURES * 2 + 
    217                             ((type & 0x10) >> 4) * MAX_SUB_FEATURES + 
     219                            MAX_SUBFEATURES * 2 + nr * MAX_SUBFEATURES * 2 + 
     220                            ((type & 0x10) >> 4) * MAX_SUBFEATURES + 
    218221                            (type & 0x0F); 
    219222                } 
    220223 
    221                 if (features[i].name) { 
     224                if (all_subfeatures[i].name) { 
    222225                        fprintf(stderr, "libsensors error, trying to add dupli" 
    223                                 "cate feature: %s to dynamic feature table\n", 
     226                                "cate subfeature: %s to dynamic feature table\n", 
    224227                                name); 
    225228                        continue; 
    226229                } 
    227230 
    228                 /* fill in the feature members */ 
    229                 features[i].type = type; 
     231                /* fill in the subfeature members */ 
     232                all_subfeatures[i].type = type; 
    230233 
    231234                /* check for _input extension and remove */ 
    232235                nr = strlen(name); 
    233236                if (nr > 6 && !strcmp(name + nr - 6, "_input")) 
    234                         features[i].name = strndup(name, nr - 6); 
     237                        all_subfeatures[i].name = strndup(name, nr - 6); 
    235238                else 
    236                         features[i].name = strdup(name); 
     239                        all_subfeatures[i].name = strdup(name); 
    237240 
    238241                if ((type & 0x00FF) == 0) { 
    239                         /* main feature */ 
    240                         features[i].mapping = SENSORS_NO_MAPPING; 
     242                        /* main subfeature */ 
     243                        all_subfeatures[i].mapping = SENSORS_NO_MAPPING; 
    241244                } else { 
    242                         /* sub feature */ 
    243245                        /* The mapping is set below after numbering */ 
    244246                        if (!(type & 0x10)) 
    245                                 features[i].flags |= SENSORS_COMPUTE_MAPPING; 
     247                                all_subfeatures[i].flags |= SENSORS_COMPUTE_MAPPING; 
    246248                } 
    247249 
    248250                if (attr->method & SYSFS_METHOD_SHOW) 
    249                         features[i].flags |= SENSORS_MODE_R; 
     251                        all_subfeatures[i].flags |= SENSORS_MODE_R; 
    250252                if (attr->method & SYSFS_METHOD_STORE) 
    251                         features[i].flags |= SENSORS_MODE_W; 
     253                        all_subfeatures[i].flags |= SENSORS_MODE_W; 
    252254 
    253255                fnum++; 
    254256        } 
    255257 
    256         if (!fnum) { /* No feature */ 
     258        if (!fnum) { /* No subfeature */ 
    257259                chip->subfeature = NULL; 
    258260                goto exit_free; 
     
    265267 
    266268        fnum = 0; 
    267         for (i = 0; i < ALL_POSSIBLE_FEATURES; i++) { 
    268                 if (features[i].name) { 
    269                         dyn_subfeatures[fnum] = features[i]; 
     269        for (i = 0; i < ALL_POSSIBLE_SUBFEATURES; i++) { 
     270                if (all_subfeatures[i].name) { 
     271                        dyn_subfeatures[fnum] = all_subfeatures[i]; 
    270272                        fnum++; 
    271273                } 
    272274        } 
    273275 
    274         /* Number the subfeatures linearly, so that feature number N is at 
     276        /* Number the subfeatures linearly, so that subfeature number N is at 
    275277           position N in the array. This allows for O(1) look-ups. */ 
    276278        for (i = 0; i < fnum; i++) { 
     
    317319 
    318320exit_free: 
    319         free(features); 
     321        free(all_subfeatures); 
    320322        return 0; 
    321323} 
     
    402404        if (sensors_read_dynamic_chip(&entry, dev) < 0) 
    403405                goto exit_free; 
    404         if (!entry.subfeature) { /* No feature, discard chip */ 
     406        if (!entry.subfeature) { /* No subfeature, discard chip */ 
    405407                err = 0; 
    406408                goto exit_free; 
     
    537539} 
    538540 
    539 int sensors_read_sysfs_attr(const sensors_chip_name *name, int feature, 
     541int sensors_read_sysfs_attr(const sensors_chip_name *name, int subfeat_nr, 
    540542                            double *value) 
    541543{ 
    542         const sensors_subfeature *the_feature; 
     544        const sensors_subfeature *subfeature; 
    543545        char n[NAME_MAX]; 
    544546        FILE *f; 
    545547        const char *suffix = ""; 
    546548 
    547         if (!(the_feature = sensors_lookup_feature_nr(name, feature))) 
     549        if (!(subfeature = sensors_lookup_subfeature_nr(name, subfeat_nr))) 
    548550                return -SENSORS_ERR_NO_ENTRY; 
    549551 
    550552        /* REVISIT: this is a ugly hack */ 
    551         if (the_feature->type == SENSORS_FEATURE_IN 
    552          || the_feature->type == SENSORS_FEATURE_FAN 
    553          || the_feature->type == SENSORS_FEATURE_TEMP) 
     553        if (subfeature->type == SENSORS_FEATURE_IN 
     554         || subfeature->type == SENSORS_FEATURE_FAN 
     555         || subfeature->type == SENSORS_FEATURE_TEMP) 
    554556                suffix = "_input"; 
    555557 
    556         snprintf(n, NAME_MAX, "%s/%s%s", name->path, the_feature->name, 
     558        snprintf(n, NAME_MAX, "%s/%s%s", name->path, subfeature->name, 
    557559                 suffix); 
    558560        if ((f = fopen(n, "r"))) { 
     
    561563                if (res != 1) 
    562564                        return -SENSORS_ERR_PROC; 
    563                 *value /= get_type_scaling(the_feature->type); 
     565                *value /= get_type_scaling(subfeature->type); 
    564566        } else 
    565567                return -SENSORS_ERR_PROC; 
     
    568570} 
    569571 
    570 int sensors_write_sysfs_attr(const sensors_chip_name *name, int feature, 
     572int sensors_write_sysfs_attr(const sensors_chip_name *name, int subfeat_nr, 
    571573                             double value) 
    572574{ 
    573         const sensors_subfeature *the_feature; 
     575        const sensors_subfeature *subfeature; 
    574576        char n[NAME_MAX]; 
    575577        FILE *f; 
    576578        const char *suffix = ""; 
    577579 
    578         if (!(the_feature = sensors_lookup_feature_nr(name, feature))) 
     580        if (!(subfeature = sensors_lookup_subfeature_nr(name, subfeat_nr))) 
    579581                return -SENSORS_ERR_NO_ENTRY; 
    580582 
    581583        /* REVISIT: this is a ugly hack */ 
    582         if (the_feature->type == SENSORS_FEATURE_IN 
    583          || the_feature->type == SENSORS_FEATURE_FAN 
    584          || the_feature->type == SENSORS_FEATURE_TEMP) 
     584        if (subfeature->type == SENSORS_FEATURE_IN 
     585         || subfeature->type == SENSORS_FEATURE_FAN 
     586         || subfeature->type == SENSORS_FEATURE_TEMP) 
    585587                suffix = "_input"; 
    586588 
    587         snprintf(n, NAME_MAX, "%s/%s%s", name->path, the_feature->name, 
     589        snprintf(n, NAME_MAX, "%s/%s%s", name->path, subfeature->name, 
    588590                 suffix); 
    589591        if ((f = fopen(n, "w"))) { 
    590                 value *= get_type_scaling(the_feature->type); 
     592                value *= get_type_scaling(subfeature->type); 
    591593                fprintf(f, "%d", (int) value); 
    592594                fclose(f); 
  • lm-sensors/branches/lm-sensors-3.0.0/lib/sysfs.h

    r4736 r4836  
    3030 
    3131/* Read a value out of a sysfs attribute file */ 
    32 int sensors_read_sysfs_attr(const sensors_chip_name *name, int feature, 
     32int sensors_read_sysfs_attr(const sensors_chip_name *name, int subfeat_nr, 
    3333                            double *value); 
    3434 
    3535/* Write a value to a sysfs attribute file */ 
    36 int sensors_write_sysfs_attr(const sensors_chip_name *name, int feature, 
     36int sensors_write_sysfs_attr(const sensors_chip_name *name, int subfeat_nr, 
    3737                             double value); 
    3838