aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/hwmon/smsc47m192.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/hwmon/smsc47m192.c b/drivers/hwmon/smsc47m192.c
index 6ac7cda72d4c..15650f247679 100644
--- a/drivers/hwmon/smsc47m192.c
+++ b/drivers/hwmon/smsc47m192.c
@@ -77,14 +77,15 @@ static inline unsigned int IN_FROM_REG(u8 reg, int n)
77 77
78static inline u8 IN_TO_REG(unsigned long val, int n) 78static inline u8 IN_TO_REG(unsigned long val, int n)
79{ 79{
80 return clamp_val(SCALE(val, 192, nom_mv[n]), 0, 255); 80 val = clamp_val(val, 0, nom_mv[n] * 255 / 192);
81 return SCALE(val, 192, nom_mv[n]);
81} 82}
82 83
83/* 84/*
84 * TEMP: 0.001 degC units (-128C to +127C) 85 * TEMP: 0.001 degC units (-128C to +127C)
85 * REG: 1C/bit, two's complement 86 * REG: 1C/bit, two's complement
86 */ 87 */
87static inline s8 TEMP_TO_REG(int val) 88static inline s8 TEMP_TO_REG(long val)
88{ 89{
89 return SCALE(clamp_val(val, -128000, 127000), 1, 1000); 90 return SCALE(clamp_val(val, -128000, 127000), 1, 1000);
90} 91}