Skip to content

Commit

Permalink
hwmon: (max6639) Fix FAN_FROM_REG calculation
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
silverchris authored and Guenter Roeck committed Feb 21, 2012
1 parent b01543d commit b63d97a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/hwmon/max6639.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ static unsigned short normal_i2c[] = { 0x2c, 0x2e, 0x2f, I2C_CLIENT_END };

static const int rpm_ranges[] = { 2000, 4000, 8000, 16000 };

#define FAN_FROM_REG(val, div, rpm_range) ((val) == 0 ? -1 : \
(val) == 255 ? 0 : (rpm_ranges[rpm_range] * 30) / ((div + 1) * (val)))
#define FAN_FROM_REG(val, rpm_range) ((val) == 0 || (val) == 255 ? \
0 : (rpm_ranges[rpm_range] * 30) / (val))
#define TEMP_LIMIT_TO_REG(val) SENSORS_LIMIT((val) / 1000, 0, 255)

/*
Expand Down Expand Up @@ -333,7 +333,7 @@ static ssize_t show_fan_input(struct device *dev,
return PTR_ERR(data);

return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[attr->index],
data->ppr, data->rpm_range));
data->rpm_range));
}

static ssize_t show_alarm(struct device *dev,
Expand Down

0 comments on commit b63d97a

Please sign in to comment.