Changeset 4758

Show
Ignore:
Timestamp:
09/05/07 10:17:22 (7 years ago)
Author:
khali
Message:

The compute mapping value is either SENSORS_NO_MAPPING or the same
feature number as the logical mapping. This means that the compute
mapping can be turned into a simple boolean flag. Doing so makes
struct sensors_feature_data smaller, which saves some memory (about
17 kB in my tests.)

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

Legend:

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

    r4757 r4758  
    191191/* Looks up whether a feature should be ignored. Returns 
    192192   1 if it should be ignored, 0 if not. This function takes 
    193    logical mappings into account. */ 
     193   mappings into account. */ 
    194194static int sensors_get_ignored(const sensors_chip_name *name, 
    195195                               const sensors_chip_feature *feature) 
     
    233233                return -SENSORS_ERR_NO_ENTRY; 
    234234 
    235         if (main_feature->data.compute_mapping == SENSORS_NO_MAPPING) 
     235        if (main_feature->data.flags & SENSORS_COMPUTE_MAPPING) 
     236                alt_feature = sensors_lookup_feature_nr(name, 
     237                                        main_feature->data.mapping); 
     238        else 
    236239                alt_feature = NULL; 
    237         else 
    238                 alt_feature = sensors_lookup_feature_nr(name, 
    239                                         main_feature->data.compute_mapping); 
    240240 
    241241        if (!(main_feature->data.flags & SENSORS_MODE_R)) 
     
    280280                return -SENSORS_ERR_NO_ENTRY; 
    281281 
    282         if (main_feature->data.compute_mapping == SENSORS_NO_MAPPING) 
     282        if (main_feature->data.flags & SENSORS_COMPUTE_MAPPING) 
     283                alt_feature = sensors_lookup_feature_nr(name, 
     284                                        main_feature->data.mapping); 
     285        else 
    283286                alt_feature = NULL; 
    284         else 
    285                 alt_feature = sensors_lookup_feature_nr(name, 
    286                                         main_feature->data.compute_mapping); 
    287287 
    288288        if (!(main_feature->data.flags & SENSORS_MODE_W)) 
  • lm-sensors/branches/lm-sensors-3.0.0/lib/data.h

    r4757 r4758  
    126126   number is the internal feature number, used in many functions to refer 
    127127     to this feature 
    128    logical_mapping is either SENSORS_NO_MAPPING if this is feature is the 
     128   mapping is either SENSORS_NO_MAPPING if this is feature is the 
    129129     main element of category; or it is the number of a feature with which 
    130130     this feature is logically grouped (a group could be fan, fan_max and 
    131131     fan_div) 
    132    compute_mapping is like logical_mapping, only it refers to another 
    133      feature whose compute line will be inherited (a group could be fan and 
    134      fan_max, but not fan_div) 
    135    flags is a bitfield, its value is a combination of SENSORS_MODE_R (readable) 
    136      and SENSORS_MODE_W (writable). 
     132   flags is a bitfield, its value is a combination of SENSORS_MODE_R (readable), 
     133     SENSORS_MODE_W (writable) and SENSORS_COMPUTE_MAPPING (affected by the 
     134     computation rules of the main feature). 
    137135   scaling is the number of decimal points to scale by. 
    138136     Divide the read value by 10**scaling to get the real value. */ 
  • lm-sensors/branches/lm-sensors-3.0.0/lib/libsensors.3

    r4757 r4758  
    114114  int mapping; 
    115115.br 
    116   int compute_mapping; 
    117 .br 
    118116  unsigned int flags; 
    119117.br 
     
    121119.br 
    122120The flags field is a bitfield, its value is a combination of 
    123 SENSORS_MODE_R (readable) and SENSORS_MODE_W (writable). 
     121SENSORS_MODE_R (readable), SENSORS_MODE_W (writable) and SENSORS_COMPUTE_MAPPING 
     122(affected by the computation rules of the main feature). 
    124123 
    125124\fBconst sensors_feature_data *sensors_get_all_features 
  • lm-sensors/branches/lm-sensors-3.0.0/lib/sensors.h

    r4757 r4758  
    114114 
    115115/* These defines are used in the flags field of sensors_feature_data */ 
    116 #define SENSORS_MODE_R 1 
    117 #define SENSORS_MODE_W 2 
     116#define SENSORS_MODE_R                  1 
     117#define SENSORS_MODE_W                  2 
     118#define SENSORS_COMPUTE_MAPPING         4 
    118119 
    119120/* This define is used in the mapping field of sensors_feature_data if no 
     
    123124/* This enum contains some "magic" used by sensors_read_dynamic_chip() from 
    124125   lib/sysfs.c. All the sensor types (in, fan, temp, vid) are a multiple of 
    125    0x100 apart, and sensor features which should not have a compute_mapping to 
     126   0x100 apart, and sensor features which should not have a compute mapping to 
    126127   the _input feature start at 0x?10. */ 
    127128typedef enum sensors_feature_type { 
     
    164165        sensors_feature_type type; 
    165166        int mapping; 
    166         int compute_mapping; 
    167167        unsigned int flags; 
    168168} sensors_feature_data; 
  • lm-sensors/branches/lm-sensors-3.0.0/lib/sysfs.c

    r4757 r4758  
    143143                        /* main feature */ 
    144144                        feature.data.mapping = SENSORS_NO_MAPPING; 
    145                         feature.data.compute_mapping = SENSORS_NO_MAPPING; 
    146                 } else if (type & 0x10) { 
    147                         /* sub feature without compute mapping */ 
     145                } else { 
     146                        /* sub feature */ 
    148147                        feature.data.mapping = i - i % MAX_SUB_FEATURES; 
    149                         feature.data.compute_mapping = SENSORS_NO_MAPPING; 
    150                 } else { 
    151                         feature.data.mapping = i - i % MAX_SUB_FEATURES; 
    152                         feature.data.compute_mapping = feature.data.mapping; 
     148                        if (!(type & 0x10)) 
     149                                feature.data.flags |= SENSORS_COMPUTE_MAPPING; 
    153150                } 
    154151