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/it87.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/it87.c')
-rw-r--r-- | drivers/hwmon/it87.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index 117d66fcded6..29632e849285 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c | |||
@@ -384,7 +384,7 @@ static int adc_lsb(const struct it87_data *data, int nr) | |||
384 | static u8 in_to_reg(const struct it87_data *data, int nr, long val) | 384 | static u8 in_to_reg(const struct it87_data *data, int nr, long val) |
385 | { | 385 | { |
386 | val = DIV_ROUND_CLOSEST(val, adc_lsb(data, nr)); | 386 | val = DIV_ROUND_CLOSEST(val, adc_lsb(data, nr)); |
387 | return SENSORS_LIMIT(val, 0, 255); | 387 | return clamp_val(val, 0, 255); |
388 | } | 388 | } |
389 | 389 | ||
390 | static int in_from_reg(const struct it87_data *data, int nr, int val) | 390 | static int in_from_reg(const struct it87_data *data, int nr, int val) |
@@ -396,16 +396,15 @@ static inline u8 FAN_TO_REG(long rpm, int div) | |||
396 | { | 396 | { |
397 | if (rpm == 0) | 397 | if (rpm == 0) |
398 | return 255; | 398 | return 255; |
399 | rpm = SENSORS_LIMIT(rpm, 1, 1000000); | 399 | rpm = clamp_val(rpm, 1, 1000000); |
400 | return SENSORS_LIMIT((1350000 + rpm * div / 2) / (rpm * div), 1, | 400 | return clamp_val((1350000 + rpm * div / 2) / (rpm * div), 1, 254); |
401 | 254); | ||
402 | } | 401 | } |
403 | 402 | ||
404 | static inline u16 FAN16_TO_REG(long rpm) | 403 | static inline u16 FAN16_TO_REG(long rpm) |
405 | { | 404 | { |
406 | if (rpm == 0) | 405 | if (rpm == 0) |
407 | return 0xffff; | 406 | return 0xffff; |
408 | return SENSORS_LIMIT((1350000 + rpm) / (rpm * 2), 1, 0xfffe); | 407 | return clamp_val((1350000 + rpm) / (rpm * 2), 1, 0xfffe); |
409 | } | 408 | } |
410 | 409 | ||
411 | #define FAN_FROM_REG(val, div) ((val) == 0 ? -1 : (val) == 255 ? 0 : \ | 410 | #define FAN_FROM_REG(val, div) ((val) == 0 ? -1 : (val) == 255 ? 0 : \ |
@@ -414,8 +413,8 @@ static inline u16 FAN16_TO_REG(long rpm) | |||
414 | #define FAN16_FROM_REG(val) ((val) == 0 ? -1 : (val) == 0xffff ? 0 : \ | 413 | #define FAN16_FROM_REG(val) ((val) == 0 ? -1 : (val) == 0xffff ? 0 : \ |
415 | 1350000 / ((val) * 2)) | 414 | 1350000 / ((val) * 2)) |
416 | 415 | ||
417 | #define TEMP_TO_REG(val) (SENSORS_LIMIT(((val) < 0 ? (((val) - 500) / 1000) : \ | 416 | #define TEMP_TO_REG(val) (clamp_val(((val) < 0 ? (((val) - 500) / 1000) : \ |
418 | ((val) + 500) / 1000), -128, 127)) | 417 | ((val) + 500) / 1000), -128, 127)) |
419 | #define TEMP_FROM_REG(val) ((val) * 1000) | 418 | #define TEMP_FROM_REG(val) ((val) * 1000) |
420 | 419 | ||
421 | static u8 pwm_to_reg(const struct it87_data *data, long val) | 420 | static u8 pwm_to_reg(const struct it87_data *data, long val) |