From b491ba49d43739a4ff75bcf661451db602c7469d Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Thu, 30 Aug 2007 21:21:15 +0000 Subject: [PATCH] Make SENSORS_FEATURE_MAX_SUB_FEATURES private (and rename it to MAX_SUB_FEATURES in the process.) This value could change in the future so it's not safe to make it part of the libsensors API. And it isn't needed either, applications shouldn't need to use this value. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4732 7894878c-1315-0410-8ee3-d5d059ff63e0 --- lib/sensors.h | 4 ---- lib/sysfs.c | 16 ++++++---------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/lib/sensors.h b/lib/sensors.h index 59455ffa..60633f23 100644 --- a/lib/sensors.h +++ b/lib/sensors.h @@ -154,10 +154,6 @@ typedef enum sensors_feature_type { SENSORS_FEATURE_VID = 0x300, SENSORS_FEATURE_UNKNOWN = INT_MAX, - - /* special the largest number of subfeatures used, iow the - highest ## from all the 0x?## above + 1*/ - SENSORS_FEATURE_MAX_SUB_FEATURES = 22 } sensors_feature_type; /* This structure is used when you want to get all features of a specific diff --git a/lib/sysfs.c b/lib/sysfs.c index 2aa6f59b..fcc93ced 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -37,9 +37,9 @@ char sensors_sysfs_mount[NAME_MAX]; #define MAX_SENSORS_PER_TYPE 16 +#define MAX_SUB_FEATURES 22 /* Room for all 3 types (in, fan, temp) with all their subfeatures + VID */ -#define ALL_POSSIBLE_FEATURES (MAX_SENSORS_PER_TYPE * \ - SENSORS_FEATURE_MAX_SUB_FEATURES * 3 \ +#define ALL_POSSIBLE_FEATURES (MAX_SENSORS_PER_TYPE * MAX_SUB_FEATURES * 3 \ + MAX_SENSORS_PER_TYPE) static @@ -122,12 +122,10 @@ static int sensors_read_dynamic_chip(sensors_chip_features *chip, /* "calculate" a place to store the feature in our sparse, sorted table */ if (type == SENSORS_FEATURE_VID) { - i = nr + MAX_SENSORS_PER_TYPE * - SENSORS_FEATURE_MAX_SUB_FEATURES * 3; + i = nr + MAX_SENSORS_PER_TYPE * MAX_SUB_FEATURES * 3; } else { i = (type >> 8) * MAX_SENSORS_PER_TYPE * - SENSORS_FEATURE_MAX_SUB_FEATURES + - nr * SENSORS_FEATURE_MAX_SUB_FEATURES + + MAX_SUB_FEATURES + nr * MAX_SUB_FEATURES + (type & 0xFF); } @@ -149,12 +147,10 @@ static int sensors_read_dynamic_chip(sensors_chip_features *chip, feature.data.compute_mapping = SENSORS_NO_MAPPING; } else if (type & 0x10) { /* sub feature without compute mapping */ - feature.data.mapping = i - - i % SENSORS_FEATURE_MAX_SUB_FEATURES + 1; + feature.data.mapping = i - i % MAX_SUB_FEATURES + 1; feature.data.compute_mapping = SENSORS_NO_MAPPING; } else { - feature.data.mapping = i - - i % SENSORS_FEATURE_MAX_SUB_FEATURES + 1; + feature.data.mapping = i - i % MAX_SUB_FEATURES + 1; feature.data.compute_mapping = feature.data.mapping; }