Changeset 5896
- Timestamp:
- 12/14/10 10:06:19 (2 years ago)
- Location:
- lm-sensors/trunk
- Files:
-
- 2 modified
-
CHANGES (modified) (1 diff)
-
lib/sysfs.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/CHANGES
r5895 r5896 5 5 Makefile: Check for bison and flex 6 6 libsensors: Add support for intrusion detection (#2370) 7 Compute MAX_SUBFEATURES at run-time (#2378) 7 8 sensors.conf.defauit: Add a section for the W83627THF 8 9 Add a section for the SCH5127 -
lm-sensors/trunk/lib/sysfs.c
r5879 r5896 140 140 #define MAX_OTHER_SENSOR_TYPES 2 141 141 #define MAX_SENSORS_PER_TYPE 24 142 #define MAX_SUBFEATURES 8 143 #define FEATURE_SIZE ( MAX_SUBFEATURES* 2)142 /* max_subfeatures is now computed dynamically */ 143 #define FEATURE_SIZE (max_subfeatures * 2) 144 144 #define FEATURE_TYPE_SIZE (MAX_SENSORS_PER_TYPE * FEATURE_SIZE) 145 145 … … 338 338 } 339 339 340 static int sensors_compute_max(void) 341 { 342 int i, j, max, offset; 343 const struct subfeature_type_match *submatches; 344 sensors_feature_type ftype; 345 346 max = 0; 347 for (i = 0; i < ARRAY_SIZE(matches); i++) { 348 submatches = matches[i].submatches; 349 for (j = 0; submatches[j].name != NULL; j++) { 350 ftype = submatches[j].type >> 8; 351 352 if (ftype < SENSORS_FEATURE_VID) { 353 offset = submatches[j].type & 0x7F; 354 if (offset >= max) 355 max = offset + 1; 356 } else { 357 offset = submatches[j].type & 0xFF; 358 if (offset >= max * 2) 359 max = ((offset + 1) + 1) / 2; 360 } 361 } 362 } 363 364 return max; 365 } 366 340 367 static int sensors_get_attr_mode(const char *device, const char *attr) 341 368 { … … 358 385 { 359 386 int i, fnum = 0, sfnum = 0, prev_slot; 387 static int max_subfeatures; 360 388 DIR *dir; 361 389 struct dirent *ent; … … 368 396 if (!(dir = opendir(dev_path))) 369 397 return -errno; 398 399 /* Dynamically figure out the max number of subfeatures */ 400 if (!max_subfeatures) 401 max_subfeatures = sensors_compute_max(); 370 402 371 403 /* We use a large sparse table at first to store all found … … 431 463 i = ftype * FEATURE_TYPE_SIZE + 432 464 nr * FEATURE_SIZE + 433 ((sftype & 0x80) >> 7) * MAX_SUBFEATURES+465 ((sftype & 0x80) >> 7) * max_subfeatures + 434 466 (sftype & 0x7F); 435 467 }
