aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/dme1737.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/dme1737.c')
-rw-r--r--drivers/hwmon/dme1737.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/hwmon/dme1737.c b/drivers/hwmon/dme1737.c
index 85064fb0b7c2..307f48de051f 100644
--- a/drivers/hwmon/dme1737.c
+++ b/drivers/hwmon/dme1737.c
@@ -283,14 +283,21 @@ static inline int TEMP_HYST_TO_REG(int val, int ix, int reg)
283/* Fan input RPM */ 283/* Fan input RPM */
284static inline int FAN_FROM_REG(int reg, int tpc) 284static inline int FAN_FROM_REG(int reg, int tpc)
285{ 285{
286 return (reg == 0 || reg == 0xffff) ? 0 : 286 if (tpc) {
287 (tpc == 0) ? 90000 * 60 / reg : tpc * reg; 287 return tpc * reg;
288 } else {
289 return (reg == 0 || reg == 0xffff) ? 0 : 90000 * 60 / reg;
290 }
288} 291}
289 292
290static inline int FAN_TO_REG(int val, int tpc) 293static inline int FAN_TO_REG(int val, int tpc)
291{ 294{
292 return SENSORS_LIMIT((tpc == 0) ? 90000 * 60 / val : val / tpc, 295 if (tpc) {
293 0, 0xffff); 296 return SENSORS_LIMIT(val / tpc, 0, 0xffff);
297 } else {
298 return (val <= 0) ? 0xffff :
299 SENSORS_LIMIT(90000 * 60 / val, 0, 0xfffe);
300 }
294} 301}
295 302
296/* Fan TPC (tach pulse count) 303/* Fan TPC (tach pulse count)