diff options
author | Chris D Schimp <silverchris@gmail.com> | 2012-02-20 16:59:24 -0500 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2012-02-21 17:30:12 -0500 |
commit | b63d97a36edb1aecf8c13e5f5783feff4d64c24b (patch) | |
tree | cc84e698347ae3aa26ff88f7adfe5f505edc7b83 /drivers/hwmon/max6639.c | |
parent | b01543dfe67bb1d191998e90d20534dc354de059 (diff) |
hwmon: (max6639) Fix FAN_FROM_REG calculation
RPM calculation from tachometer value does not depend on PPR.
Also, do not report negative RPM values.
Signed-off-by: Chris D Schimp <silverchris@gmail.com>
[guenter.roeck@ericsson.com: do not report negative RPM values]
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Cc: stable@vger.kernel.org # 3.0+
Acked-by: Roland Stigge <stigge@antcom.de>
Diffstat (limited to 'drivers/hwmon/max6639.c')
-rw-r--r-- | drivers/hwmon/max6639.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/hwmon/max6639.c b/drivers/hwmon/max6639.c index e10a092c603c..13e58a1992cf 100644 --- a/drivers/hwmon/max6639.c +++ b/drivers/hwmon/max6639.c | |||
@@ -72,8 +72,8 @@ static unsigned short normal_i2c[] = { 0x2c, 0x2e, 0x2f, I2C_CLIENT_END }; | |||
72 | 72 | ||
73 | static const int rpm_ranges[] = { 2000, 4000, 8000, 16000 }; | 73 | static const int rpm_ranges[] = { 2000, 4000, 8000, 16000 }; |
74 | 74 | ||
75 | #define FAN_FROM_REG(val, div, rpm_range) ((val) == 0 ? -1 : \ | 75 | #define FAN_FROM_REG(val, rpm_range) ((val) == 0 || (val) == 255 ? \ |
76 | (val) == 255 ? 0 : (rpm_ranges[rpm_range] * 30) / ((div + 1) * (val))) | 76 | 0 : (rpm_ranges[rpm_range] * 30) / (val)) |
77 | #define TEMP_LIMIT_TO_REG(val) SENSORS_LIMIT((val) / 1000, 0, 255) | 77 | #define TEMP_LIMIT_TO_REG(val) SENSORS_LIMIT((val) / 1000, 0, 255) |
78 | 78 | ||
79 | /* | 79 | /* |
@@ -333,7 +333,7 @@ static ssize_t show_fan_input(struct device *dev, | |||
333 | return PTR_ERR(data); | 333 | return PTR_ERR(data); |
334 | 334 | ||
335 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[attr->index], | 335 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[attr->index], |
336 | data->ppr, data->rpm_range)); | 336 | data->rpm_range)); |
337 | } | 337 | } |
338 | 338 | ||
339 | static ssize_t show_alarm(struct device *dev, | 339 | static ssize_t show_alarm(struct device *dev, |