aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/gl518sm.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/gl518sm.c')
-rw-r--r--drivers/hwmon/gl518sm.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c
index 2c74673f48e5..e2e5909a34df 100644
--- a/drivers/hwmon/gl518sm.c
+++ b/drivers/hwmon/gl518sm.c
@@ -86,7 +86,7 @@ enum chips { gl518sm_r00, gl518sm_r80 };
86#define BOOL_FROM_REG(val) ((val) ? 0 : 1) 86#define BOOL_FROM_REG(val) ((val) ? 0 : 1)
87#define BOOL_TO_REG(val) ((val) ? 0 : 1) 87#define BOOL_TO_REG(val) ((val) ? 0 : 1)
88 88
89#define TEMP_TO_REG(val) SENSORS_LIMIT(((((val) < 0 ? \ 89#define TEMP_TO_REG(val) clamp_val(((((val) < 0 ? \
90 (val) - 500 : \ 90 (val) - 500 : \
91 (val) + 500) / 1000) + 119), 0, 255) 91 (val) + 500) / 1000) + 119), 0, 255)
92#define TEMP_FROM_REG(val) (((val) - 119) * 1000) 92#define TEMP_FROM_REG(val) (((val) - 119) * 1000)
@@ -96,15 +96,15 @@ static inline u8 FAN_TO_REG(long rpm, int div)
96 long rpmdiv; 96 long rpmdiv;
97 if (rpm == 0) 97 if (rpm == 0)
98 return 0; 98 return 0;
99 rpmdiv = SENSORS_LIMIT(rpm, 1, 960000) * div; 99 rpmdiv = clamp_val(rpm, 1, 960000) * div;
100 return SENSORS_LIMIT((480000 + rpmdiv / 2) / rpmdiv, 1, 255); 100 return clamp_val((480000 + rpmdiv / 2) / rpmdiv, 1, 255);
101} 101}
102#define FAN_FROM_REG(val, div) ((val) == 0 ? 0 : (480000 / ((val) * (div)))) 102#define FAN_FROM_REG(val, div) ((val) == 0 ? 0 : (480000 / ((val) * (div))))
103 103
104#define IN_TO_REG(val) SENSORS_LIMIT((((val) + 9) / 19), 0, 255) 104#define IN_TO_REG(val) clamp_val((((val) + 9) / 19), 0, 255)
105#define IN_FROM_REG(val) ((val) * 19) 105#define IN_FROM_REG(val) ((val) * 19)
106 106
107#define VDD_TO_REG(val) SENSORS_LIMIT((((val) * 4 + 47) / 95), 0, 255) 107#define VDD_TO_REG(val) clamp_val((((val) * 4 + 47) / 95), 0, 255)
108#define VDD_FROM_REG(val) (((val) * 95 + 2) / 4) 108#define VDD_FROM_REG(val) (((val) * 95 + 2) / 4)
109 109
110#define DIV_FROM_REG(val) (1 << (val)) 110#define DIV_FROM_REG(val) (1 << (val))