diff options
author | Guenter Roeck <linux@roeck-us.net> | 2013-01-09 11:09:34 -0500 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2013-01-26 00:03:54 -0500 |
commit | 2a844c148e1f714ebf42cb96e1b172ce394c36c9 (patch) | |
tree | eb68eb8438f0470e7a81b022199abe5f6d866879 /drivers/hwmon/via686a.c | |
parent | 142c090184ac7f9763c5d22509405da3486f9801 (diff) |
hwmon: Replace SENSORS_LIMIT with clamp_val
SENSORS_LIMIT and the generic clamp_val have the same functionality,
and clamp_val is more efficient.
This patch reduces text size by 9052 bytes and bss size by 11624 bytes
for x86_64 builds.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: George Joseph <george.joseph@fairview5.com>
Acked-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon/via686a.c')
-rw-r--r-- | drivers/hwmon/via686a.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c index e0e14a9f1658..3123b30208c5 100644 --- a/drivers/hwmon/via686a.c +++ b/drivers/hwmon/via686a.c | |||
@@ -135,17 +135,14 @@ static inline u8 IN_TO_REG(long val, int inNum) | |||
135 | * for the constants. | 135 | * for the constants. |
136 | */ | 136 | */ |
137 | if (inNum <= 1) | 137 | if (inNum <= 1) |
138 | return (u8) | 138 | return (u8) clamp_val((val * 21024 - 1205000) / 250000, 0, 255); |
139 | SENSORS_LIMIT((val * 21024 - 1205000) / 250000, 0, 255); | ||
140 | else if (inNum == 2) | 139 | else if (inNum == 2) |
141 | return (u8) | 140 | return (u8) clamp_val((val * 15737 - 1205000) / 250000, 0, 255); |
142 | SENSORS_LIMIT((val * 15737 - 1205000) / 250000, 0, 255); | ||
143 | else if (inNum == 3) | 141 | else if (inNum == 3) |
144 | return (u8) | 142 | return (u8) clamp_val((val * 10108 - 1205000) / 250000, 0, 255); |
145 | SENSORS_LIMIT((val * 10108 - 1205000) / 250000, 0, 255); | ||
146 | else | 143 | else |
147 | return (u8) | 144 | return (u8) clamp_val((val * 41714 - 12050000) / 2500000, 0, |
148 | SENSORS_LIMIT((val * 41714 - 12050000) / 2500000, 0, 255); | 145 | 255); |
149 | } | 146 | } |
150 | 147 | ||
151 | static inline long IN_FROM_REG(u8 val, int inNum) | 148 | static inline long IN_FROM_REG(u8 val, int inNum) |
@@ -175,8 +172,8 @@ static inline u8 FAN_TO_REG(long rpm, int div) | |||
175 | { | 172 | { |
176 | if (rpm == 0) | 173 | if (rpm == 0) |
177 | return 0; | 174 | return 0; |
178 | rpm = SENSORS_LIMIT(rpm, 1, 1000000); | 175 | rpm = clamp_val(rpm, 1, 1000000); |
179 | return SENSORS_LIMIT((1350000 + rpm * div / 2) / (rpm * div), 1, 255); | 176 | return clamp_val((1350000 + rpm * div / 2) / (rpm * div), 1, 255); |
180 | } | 177 | } |
181 | 178 | ||
182 | #define FAN_FROM_REG(val, div) ((val) == 0 ? 0 : (val) == 255 ? 0 : 1350000 / \ | 179 | #define FAN_FROM_REG(val, div) ((val) == 0 ? 0 : (val) == 255 ? 0 : 1350000 / \ |