diff options
author | khali <khali@7894878c-1315-0410-8ee3-d5d059ff63e0> | 2010-11-02 12:59:31 +0000 |
---|---|---|
committer | khali <khali@7894878c-1315-0410-8ee3-d5d059ff63e0> | 2010-11-02 12:59:31 +0000 |
commit | 8a664ff6b371992dff19041753d9900465895ab0 (patch) | |
tree | f806b5ee86107991a31b910e80c4c310cb041102 /lib/sysfs.c | |
parent | 3f8fb505238c38251130d0201c106c9f7f72bb5e (diff) | |
download | lm-sensors-8a664ff6b371992dff19041753d9900465895ab0.tar.gz |
Work with the feature type instead of the shifted subfeature type where
possible. This makes the code more readable.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5875 7894878c-1315-0410-8ee3-d5d059ff63e0
Diffstat (limited to 'lib/sysfs.c')
-rw-r--r-- | lib/sysfs.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/sysfs.c b/lib/sysfs.c index 79cf559f..1e1f790b 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -382,16 +382,19 @@ static int sensors_read_dynamic_chip(sensors_chip_features *chip, sftype = sensors_subfeature_get_type(name, &nr); if (sftype == SENSORS_SUBFEATURE_UNKNOWN) continue; + ftype = sftype >> 8; /* Adjust the channel number */ - switch (sftype & 0xFF00) { - case SENSORS_SUBFEATURE_FAN_INPUT: - case SENSORS_SUBFEATURE_TEMP_INPUT: - case SENSORS_SUBFEATURE_POWER_AVERAGE: - case SENSORS_SUBFEATURE_ENERGY_INPUT: - case SENSORS_SUBFEATURE_CURR_INPUT: + switch (ftype) { + case SENSORS_FEATURE_FAN: + case SENSORS_FEATURE_TEMP: + case SENSORS_FEATURE_POWER: + case SENSORS_FEATURE_ENERGY: + case SENSORS_FEATURE_CURR: nr--; break; + default: + break; } if (nr < 0 || nr >= MAX_SENSORS_PER_TYPE) { @@ -406,19 +409,18 @@ static int sensors_read_dynamic_chip(sensors_chip_features *chip, /* "calculate" a place to store the subfeature in our sparse, sorted table */ - switch (sftype) { - case SENSORS_SUBFEATURE_VID: + switch (ftype) { + case SENSORS_FEATURE_VID: i = SUB_OFFSET_OTHER + - ((sftype >> 8) - SENSORS_FEATURE_VID) * - FEATURE_TYPE_SIZE + + (ftype - SENSORS_FEATURE_VID) * FEATURE_TYPE_SIZE + nr * FEATURE_SIZE + (sftype & 0xFF); break; - case SENSORS_SUBFEATURE_BEEP_ENABLE: + case SENSORS_FEATURE_BEEP_ENABLE: i = SUB_OFFSET_MISC + - ((sftype >> 8) - SENSORS_FEATURE_BEEP_ENABLE); + (ftype - SENSORS_FEATURE_BEEP_ENABLE); break; default: - i = (sftype >> 8) * FEATURE_TYPE_SIZE + + i = ftype * FEATURE_TYPE_SIZE + nr * FEATURE_SIZE + ((sftype & 0x80) >> 7) * MAX_SUBFEATURES + (sftype & 0x7F); |