Changeset 4836
- Timestamp:
- 09/23/07 14:07:53 (6 years ago)
- 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 87 87 } 88 88 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. 90 90 Do not modify the struct the return value points to! Returns NULL if 91 91 not found.*/ 92 const sensors_subfeature *sensors_lookup_feature_nr(const sensors_chip_name *chip, 93 int feature) 92 const sensors_subfeature * 93 sensors_lookup_subfeature_nr(const sensors_chip_name *chip, 94 int subfeat_nr) 94 95 { 95 96 int i; … … 97 98 for (i = 0; i < sensors_proc_chips_count; i++) 98 99 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) 101 102 return NULL; 102 return sensors_proc_chips[i].subfeature + feature;103 return sensors_proc_chips[i].subfeature + subfeat_nr; 103 104 } 104 105 return NULL; … … 109 110 not found.*/ 110 111 static const sensors_subfeature * 111 sensors_lookup_feature_name(const sensors_chip_name *chip, const char *feature) 112 sensors_lookup_subfeature_name(const sensors_chip_name *chip, 113 const char *name) 112 114 { 113 115 int i, j; … … 118 120 subfeatures = sensors_proc_chips[i].subfeature; 119 121 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)) 121 123 return subfeatures + j; 122 124 } … … 138 140 } 139 141 140 /* Look up the label which belongs to this chip. Note that chip should not142 /* Look up the label for a given feature. Note that chip should not 141 143 contain wildcard values! The returned string is newly allocated (free it 142 144 yourself). On failure, NULL is returned. … … 200 202 } 201 203 202 /* Read the value of a feature of a certain chip. Note that chip should not204 /* Read the value of a subfeature of a certain chip. Note that chip should not 203 205 contain wildcard values! This function will return 0 on success, and <0 204 206 on failure. */ 205 int sensors_get_value(const sensors_chip_name *name, int feature,207 int sensors_get_value(const sensors_chip_name *name, int subfeat_nr, 206 208 double *result) 207 209 { 208 const sensors_subfeature * main_feature;210 const sensors_subfeature *subfeature; 209 211 const sensors_subfeature *alt_feature; 210 212 const sensors_chip *chip; … … 216 218 if (sensors_chip_name_has_wildcards(name)) 217 219 return -SENSORS_ERR_WILDCARDS; 218 if (!( main_feature = sensors_lookup_feature_nr(name, feature)))220 if (!(subfeature = sensors_lookup_subfeature_nr(name, subfeat_nr))) 219 221 return -SENSORS_ERR_NO_ENTRY; 220 222 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); 224 226 else 225 227 alt_feature = NULL; 226 228 227 if (!( main_feature->flags & SENSORS_MODE_R))229 if (!(subfeature->flags & SENSORS_MODE_R)) 228 230 return -SENSORS_ERR_ACCESS_R; 229 231 for (chip = NULL; 230 232 !expr && (chip = sensors_for_all_config_chips(name, chip));) 231 233 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)) { 233 235 expr = chip->computes[i].from_proc; 234 236 final_expr = 1; … … 238 240 } 239 241 } 240 if (sensors_read_sysfs_attr(name, feature, &val))242 if (sensors_read_sysfs_attr(name, subfeat_nr, &val)) 241 243 return -SENSORS_ERR_PROC; 242 244 if (!expr) … … 247 249 } 248 250 249 /* Set the value of a feature of a certain chip. Note that chip should not251 /* Set the value of a subfeature of a certain chip. Note that chip should not 250 252 contain wildcard values! This function will return 0 on success, and <0 251 253 on failure. */ 252 int sensors_set_value(const sensors_chip_name *name, int feature,254 int sensors_set_value(const sensors_chip_name *name, int subfeat_nr, 253 255 double value) 254 256 { 255 const sensors_subfeature * main_feature;257 const sensors_subfeature *subfeature; 256 258 const sensors_subfeature *alt_feature; 257 259 const sensors_chip *chip; … … 263 265 if (sensors_chip_name_has_wildcards(name)) 264 266 return -SENSORS_ERR_WILDCARDS; 265 if (!( main_feature = sensors_lookup_feature_nr(name, feature)))267 if (!(subfeature = sensors_lookup_subfeature_nr(name, subfeat_nr))) 266 268 return -SENSORS_ERR_NO_ENTRY; 267 269 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); 271 273 else 272 274 alt_feature = NULL; 273 275 274 if (!( main_feature->flags & SENSORS_MODE_W))276 if (!(subfeature->flags & SENSORS_MODE_W)) 275 277 return -SENSORS_ERR_ACCESS_W; 276 278 for (chip = NULL; 277 279 !expr && (chip = sensors_for_all_config_chips(name, chip));) 278 280 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)) { 280 282 expr = chip->computes->to_proc; 281 283 final_expr = 1; … … 289 291 if ((res = sensors_eval_expr(name, expr, value, &to_write))) 290 292 return res; 291 if (sensors_write_sysfs_attr(name, feature, to_write))293 if (sensors_write_sysfs_attr(name, subfeat_nr, to_write)) 292 294 return -SENSORS_ERR_PROC; 293 295 return 0; … … 381 383 double res1, res2; 382 384 int res; 383 const sensors_subfeature * feature;385 const sensors_subfeature *subfeature; 384 386 385 387 if (expr->kind == sensors_kind_val) { … … 392 394 } 393 395 if (expr->kind == sensors_kind_var) { 394 if (!( feature = sensors_lookup_feature_name(name,396 if (!(subfeature = sensors_lookup_subfeature_name(name, 395 397 expr->data.var))) 396 398 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))) 398 401 return res; 399 402 return 0; … … 443 446 int i, j; 444 447 int err = 0, res; 445 const sensors_subfeature * feature;448 const sensors_subfeature *subfeature; 446 449 int *feature_list = NULL; 447 450 int feature_count = 0; 448 451 int feature_max = 0; 449 int feature_nr;452 int subfeat_nr; 450 453 451 454 for (chip = NULL; (chip = sensors_for_all_config_chips(name, chip));) 452 455 for (i = 0; i < chip->sets_count; i++) { 453 feature = sensors_lookup_feature_name(name,456 subfeature = sensors_lookup_subfeature_name(name, 454 457 chip->sets[i].name); 455 if (! feature) {458 if (!subfeature) { 456 459 sensors_parse_error("Unknown feature name", 457 460 chip->sets[i].lineno); … … 459 462 continue; 460 463 } 461 feature_nr =feature->number;464 subfeat_nr = subfeature->number; 462 465 463 466 /* Check whether we already set this feature */ 464 467 for (j = 0; j < feature_count; j++) 465 if (feature_list[j] == feature_nr)468 if (feature_list[j] == subfeat_nr) 466 469 break; 467 470 if (j != feature_count) 468 471 continue; 469 sensors_add_array_el(& feature_nr, &feature_list,472 sensors_add_array_el(&subfeat_nr, &feature_list, 470 473 &feature_count, &feature_max, 471 474 sizeof(int)); … … 479 482 continue; 480 483 } 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", 483 486 chip->sets[i].lineno); 484 487 err = res; -
lm-sensors/branches/lm-sensors-3.0.0/lib/access.h
r4832 r4836 24 24 #include "data.h" 25 25 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. 27 27 Do not modify the struct the return value points to! Returns NULL if 28 28 not found. */ 29 const sensors_subfeature *sensors_lookup_feature_nr(const sensors_chip_name *chip, 30 int feature); 29 const sensors_subfeature * 30 sensors_lookup_subfeature_nr(const sensors_chip_name *chip, 31 int subfeat_nr); 31 32 32 33 /* 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 66 66 } sensors_label; 67 67 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 */ 69 70 typedef struct sensors_set { 70 71 char *name; … … 121 122 } sensors_bus; 122 123 123 /* Internal data about all features of a type ofchip */124 /* Internal data about all features and subfeatures of a chip */ 124 125 typedef struct sensors_chip_features { 125 126 struct sensors_chip_name chip; -
lm-sensors/branches/lm-sensors-3.0.0/lib/error.c
r4736 r4836 34 34 /* Unknown error */ "sensors_strerror: Unknown error!", 35 35 /* 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", 37 37 /* SENSORS_ERR_ACCESS */ "Can't read or write", 38 38 /* SENSORS_ERR_PROC */ "Can't access sysfs file", -
lm-sensors/branches/lm-sensors-3.0.0/lib/error.h
r4736 r4836 22 22 23 23 #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 */ 25 25 #define SENSORS_ERR_ACCESS 3 /* Can't read or write */ 26 26 #define SENSORS_ERR_PROC 4 /* Can't access /proc file */ -
lm-sensors/branches/lm-sensors-3.0.0/lib/libsensors.3
r4834 r4836 38 38 .B const char *sensors_get_adapter_name(int bus_nr); 39 39 .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, 41 41 \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, 43 43 \fBdouble value);\fP 44 44 .B int sensors_do_chip_sets(const sensors_chip_name *name); … … 79 79 If no label exists for this feature, its name is returned itself. 80 80 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 83 82 .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. 83 Read the value of a subfeature of a certain chip. Note that chip should not 84 contain wildcard values! This function will return 0 on success, and <0 on 85 failure. 85 86 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 88 88 .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. 89 Set the value of a subfeature of a certain chip. Note that chip should not 90 contain wildcard values! This function will return 0 on success, and <0 on 91 failure. 90 92 91 93 .B int sensors_do_chip_sets(const sensors_chip_name *name); -
lm-sensors/branches/lm-sensors-3.0.0/lib/sensors.h
r4834 r4836 85 85 typedef struct sensors_feature sensors_feature; 86 86 87 /* Look up the label which belongs to this chip. Note that chip should not87 /* Look up the label for a given feature. Note that chip should not 88 88 contain wildcard values! The returned string is newly allocated (free it 89 89 yourself). On failure, NULL is returned. … … 92 92 const sensors_feature *feature); 93 93 94 /* Read the value of a feature of a certain chip. Note that chip should not94 /* Read the value of a subfeature of a certain chip. Note that chip should not 95 95 contain wildcard values! This function will return 0 on success, and <0 96 96 on failure. */ 97 int sensors_get_value(const sensors_chip_name *name, int feature,97 int sensors_get_value(const sensors_chip_name *name, int subfeat_nr, 98 98 double *value); 99 99 100 /* Set the value of a feature of a certain chip. Note that chip should not100 /* Set the value of a subfeature of a certain chip. Note that chip should not 101 101 contain wildcard values! This function will return 0 on success, and <0 102 102 on failure. */ 103 int sensors_set_value(const sensors_chip_name *name, int feature,103 int sensors_set_value(const sensors_chip_name *name, int subfeat_nr, 104 104 double value); 105 105 … … 127 127 /* This enum contains some "magic" used by sensors_read_dynamic_chip() from 128 128 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 to130 the _inputfeature 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. */ 131 131 typedef enum sensors_feature_type { 132 132 SENSORS_FEATURE_IN = 0x000, … … 177 177 name is the string name used to refer to this subfeature (in config files) 178 178 number is the internal subfeature number, used in many functions to refer 179 to this feature179 to this subfeature 180 180 type is the subfeature type 181 181 mapping is either SENSORS_NO_MAPPING if this subfeature is the -
lm-sensors/branches/lm-sensors-3.0.0/lib/sysfs.c
r4834 r4836 39 39 40 40 #define MAX_SENSORS_PER_TYPE 20 41 #define MAX_SUB _FEATURES841 #define MAX_SUBFEATURES 8 42 42 /* Room for all 3 types (in, fan, temp) with all their subfeatures + VID 43 43 + 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 \ 45 46 + MAX_SENSORS_PER_TYPE + 1) 46 47 … … 65 66 } 66 67 67 /* Static mappings for use by sensors_ feature_get_type() */68 /* Static mappings for use by sensors_subfeature_get_type() */ 68 69 struct feature_subtype_match 69 70 { … … 126 127 }; 127 128 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 */ 129 131 static 130 sensors_feature_type sensors_ feature_get_type(const char *name, int *nr)132 sensors_feature_type sensors_subfeature_get_type(const char *name, int *nr) 131 133 { 132 134 char c; … … 162 164 struct sysfs_attribute *attr; 163 165 struct dlist *attrs; 164 sensors_subfeature * features;166 sensors_subfeature *all_subfeatures; 165 167 sensors_subfeature *dyn_subfeatures; 166 168 sensors_feature *dyn_features; … … 171 173 return -ENOENT; 172 174 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) 178 181 sensors_fatal_error(__FUNCTION__, "Out of memory"); 179 182 … … 182 185 int nr; 183 186 184 type = sensors_ feature_get_type(name, &nr);187 type = sensors_subfeature_get_type(name, &nr); 185 188 if (type == SENSORS_FEATURE_UNKNOWN) 186 189 continue; … … 198 201 fprintf(stderr, "libsensors error, more sensors of one" 199 202 " type then MAX_SENSORS_PER_TYPE, ignoring " 200 " feature: %s\n", name);203 "subfeature: %s\n", name); 201 204 continue; 202 205 } 203 206 204 /* "calculate" a place to store the feature in our sparse,207 /* "calculate" a place to store the subfeature in our sparse, 205 208 sorted table */ 206 209 switch (type) { 207 210 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; 209 212 break; 210 213 case SENSORS_FEATURE_BEEP_ENABLE: 211 i = MAX_SENSORS_PER_TYPE * MAX_SUB _FEATURES * 6 +214 i = MAX_SENSORS_PER_TYPE * MAX_SUBFEATURES * 6 + 212 215 MAX_SENSORS_PER_TYPE; 213 216 break; 214 217 default: 215 218 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 + 218 221 (type & 0x0F); 219 222 } 220 223 221 if ( features[i].name) {224 if (all_subfeatures[i].name) { 222 225 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", 224 227 name); 225 228 continue; 226 229 } 227 230 228 /* fill in the feature members */229 features[i].type = type;231 /* fill in the subfeature members */ 232 all_subfeatures[i].type = type; 230 233 231 234 /* check for _input extension and remove */ 232 235 nr = strlen(name); 233 236 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); 235 238 else 236 features[i].name = strdup(name);239 all_subfeatures[i].name = strdup(name); 237 240 238 241 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; 241 244 } else { 242 /* sub feature */243 245 /* The mapping is set below after numbering */ 244 246 if (!(type & 0x10)) 245 features[i].flags |= SENSORS_COMPUTE_MAPPING;247 all_subfeatures[i].flags |= SENSORS_COMPUTE_MAPPING; 246 248 } 247 249 248 250 if (attr->method & SYSFS_METHOD_SHOW) 249 features[i].flags |= SENSORS_MODE_R;251 all_subfeatures[i].flags |= SENSORS_MODE_R; 250 252 if (attr->method & SYSFS_METHOD_STORE) 251 features[i].flags |= SENSORS_MODE_W;253 all_subfeatures[i].flags |= SENSORS_MODE_W; 252 254 253 255 fnum++; 254 256 } 255 257 256 if (!fnum) { /* No feature */258 if (!fnum) { /* No subfeature */ 257 259 chip->subfeature = NULL; 258 260 goto exit_free; … … 265 267 266 268 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]; 270 272 fnum++; 271 273 } 272 274 } 273 275 274 /* Number the subfeatures linearly, so that feature number N is at276 /* Number the subfeatures linearly, so that subfeature number N is at 275 277 position N in the array. This allows for O(1) look-ups. */ 276 278 for (i = 0; i < fnum; i++) { … … 317 319 318 320 exit_free: 319 free( features);321 free(all_subfeatures); 320 322 return 0; 321 323 } … … 402 404 if (sensors_read_dynamic_chip(&entry, dev) < 0) 403 405 goto exit_free; 404 if (!entry.subfeature) { /* No feature, discard chip */406 if (!entry.subfeature) { /* No subfeature, discard chip */ 405 407 err = 0; 406 408 goto exit_free; … … 537 539 } 538 540 539 int sensors_read_sysfs_attr(const sensors_chip_name *name, int feature,541 int sensors_read_sysfs_attr(const sensors_chip_name *name, int subfeat_nr, 540 542 double *value) 541 543 { 542 const sensors_subfeature * the_feature;544 const sensors_subfeature *subfeature; 543 545 char n[NAME_MAX]; 544 546 FILE *f; 545 547 const char *suffix = ""; 546 548 547 if (!( the_feature = sensors_lookup_feature_nr(name, feature)))549 if (!(subfeature = sensors_lookup_subfeature_nr(name, subfeat_nr))) 548 550 return -SENSORS_ERR_NO_ENTRY; 549 551 550 552 /* REVISIT: this is a ugly hack */ 551 if ( the_feature->type == SENSORS_FEATURE_IN552 || the_feature->type == SENSORS_FEATURE_FAN553 || 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) 554 556 suffix = "_input"; 555 557 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, 557 559 suffix); 558 560 if ((f = fopen(n, "r"))) { … … 561 563 if (res != 1) 562 564 return -SENSORS_ERR_PROC; 563 *value /= get_type_scaling( the_feature->type);565 *value /= get_type_scaling(subfeature->type); 564 566 } else 565 567 return -SENSORS_ERR_PROC; … … 568 570 } 569 571 570 int sensors_write_sysfs_attr(const sensors_chip_name *name, int feature,572 int sensors_write_sysfs_attr(const sensors_chip_name *name, int subfeat_nr, 571 573 double value) 572 574 { 573 const sensors_subfeature * the_feature;575 const sensors_subfeature *subfeature; 574 576 char n[NAME_MAX]; 575 577 FILE *f; 576 578 const char *suffix = ""; 577 579 578 if (!( the_feature = sensors_lookup_feature_nr(name, feature)))580 if (!(subfeature = sensors_lookup_subfeature_nr(name, subfeat_nr))) 579 581 return -SENSORS_ERR_NO_ENTRY; 580 582 581 583 /* REVISIT: this is a ugly hack */ 582 if ( the_feature->type == SENSORS_FEATURE_IN583 || the_feature->type == SENSORS_FEATURE_FAN584 || 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) 585 587 suffix = "_input"; 586 588 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, 588 590 suffix); 589 591 if ((f = fopen(n, "w"))) { 590 value *= get_type_scaling( the_feature->type);592 value *= get_type_scaling(subfeature->type); 591 593 fprintf(f, "%d", (int) value); 592 594 fclose(f); -
lm-sensors/branches/lm-sensors-3.0.0/lib/sysfs.h
r4736 r4836 30 30 31 31 /* Read a value out of a sysfs attribute file */ 32 int sensors_read_sysfs_attr(const sensors_chip_name *name, int feature,32 int sensors_read_sysfs_attr(const sensors_chip_name *name, int subfeat_nr, 33 33 double *value); 34 34 35 35 /* Write a value to a sysfs attribute file */ 36 int sensors_write_sysfs_attr(const sensors_chip_name *name, int feature,36 int sensors_write_sysfs_attr(const sensors_chip_name *name, int subfeat_nr, 37 37 double value); 38 38
