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/lm93.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/lm93.c')
-rw-r--r-- | drivers/hwmon/lm93.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/hwmon/lm93.c b/drivers/hwmon/lm93.c index 1a003f73e4e4..b40f34cdb3ca 100644 --- a/drivers/hwmon/lm93.c +++ b/drivers/hwmon/lm93.c | |||
@@ -371,8 +371,8 @@ static unsigned LM93_IN_FROM_REG(int nr, u8 reg) | |||
371 | static u8 LM93_IN_TO_REG(int nr, unsigned val) | 371 | static u8 LM93_IN_TO_REG(int nr, unsigned val) |
372 | { | 372 | { |
373 | /* range limit */ | 373 | /* range limit */ |
374 | const long mV = SENSORS_LIMIT(val, | 374 | const long mV = clamp_val(val, |
375 | lm93_vin_val_min[nr], lm93_vin_val_max[nr]); | 375 | lm93_vin_val_min[nr], lm93_vin_val_max[nr]); |
376 | 376 | ||
377 | /* try not to lose too much precision here */ | 377 | /* try not to lose too much precision here */ |
378 | const long uV = mV * 1000; | 378 | const long uV = mV * 1000; |
@@ -385,8 +385,8 @@ static u8 LM93_IN_TO_REG(int nr, unsigned val) | |||
385 | const long intercept = uV_min - slope * lm93_vin_reg_min[nr]; | 385 | const long intercept = uV_min - slope * lm93_vin_reg_min[nr]; |
386 | 386 | ||
387 | u8 result = ((uV - intercept + (slope/2)) / slope); | 387 | u8 result = ((uV - intercept + (slope/2)) / slope); |
388 | result = SENSORS_LIMIT(result, | 388 | result = clamp_val(result, |
389 | lm93_vin_reg_min[nr], lm93_vin_reg_max[nr]); | 389 | lm93_vin_reg_min[nr], lm93_vin_reg_max[nr]); |
390 | return result; | 390 | return result; |
391 | } | 391 | } |
392 | 392 | ||
@@ -411,10 +411,10 @@ static u8 LM93_IN_REL_TO_REG(unsigned val, int upper, int vid) | |||
411 | { | 411 | { |
412 | long uV_offset = vid * 1000 - val * 10000; | 412 | long uV_offset = vid * 1000 - val * 10000; |
413 | if (upper) { | 413 | if (upper) { |
414 | uV_offset = SENSORS_LIMIT(uV_offset, 12500, 200000); | 414 | uV_offset = clamp_val(uV_offset, 12500, 200000); |
415 | return (u8)((uV_offset / 12500 - 1) << 4); | 415 | return (u8)((uV_offset / 12500 - 1) << 4); |
416 | } else { | 416 | } else { |
417 | uV_offset = SENSORS_LIMIT(uV_offset, -400000, -25000); | 417 | uV_offset = clamp_val(uV_offset, -400000, -25000); |
418 | return (u8)((uV_offset / -25000 - 1) << 0); | 418 | return (u8)((uV_offset / -25000 - 1) << 0); |
419 | } | 419 | } |
420 | } | 420 | } |
@@ -437,7 +437,7 @@ static int LM93_TEMP_FROM_REG(u8 reg) | |||
437 | */ | 437 | */ |
438 | static u8 LM93_TEMP_TO_REG(long temp) | 438 | static u8 LM93_TEMP_TO_REG(long temp) |
439 | { | 439 | { |
440 | int ntemp = SENSORS_LIMIT(temp, LM93_TEMP_MIN, LM93_TEMP_MAX); | 440 | int ntemp = clamp_val(temp, LM93_TEMP_MIN, LM93_TEMP_MAX); |
441 | ntemp += (ntemp < 0 ? -500 : 500); | 441 | ntemp += (ntemp < 0 ? -500 : 500); |
442 | return (u8)(ntemp / 1000); | 442 | return (u8)(ntemp / 1000); |
443 | } | 443 | } |
@@ -472,7 +472,7 @@ static u8 LM93_TEMP_OFFSET_TO_REG(int off, int mode) | |||
472 | { | 472 | { |
473 | int factor = mode ? 5 : 10; | 473 | int factor = mode ? 5 : 10; |
474 | 474 | ||
475 | off = SENSORS_LIMIT(off, LM93_TEMP_OFFSET_MIN, | 475 | off = clamp_val(off, LM93_TEMP_OFFSET_MIN, |
476 | mode ? LM93_TEMP_OFFSET_MAX1 : LM93_TEMP_OFFSET_MAX0); | 476 | mode ? LM93_TEMP_OFFSET_MAX1 : LM93_TEMP_OFFSET_MAX0); |
477 | return (u8)((off + factor/2) / factor); | 477 | return (u8)((off + factor/2) / factor); |
478 | } | 478 | } |
@@ -620,8 +620,8 @@ static u16 LM93_FAN_TO_REG(long rpm) | |||
620 | if (rpm == 0) { | 620 | if (rpm == 0) { |
621 | count = 0x3fff; | 621 | count = 0x3fff; |
622 | } else { | 622 | } else { |
623 | rpm = SENSORS_LIMIT(rpm, 1, 1000000); | 623 | rpm = clamp_val(rpm, 1, 1000000); |
624 | count = SENSORS_LIMIT((1350000 + rpm) / rpm, 1, 0x3ffe); | 624 | count = clamp_val((1350000 + rpm) / rpm, 1, 0x3ffe); |
625 | } | 625 | } |
626 | 626 | ||
627 | regs = count << 2; | 627 | regs = count << 2; |
@@ -692,7 +692,7 @@ static int LM93_RAMP_FROM_REG(u8 reg) | |||
692 | */ | 692 | */ |
693 | static u8 LM93_RAMP_TO_REG(int ramp) | 693 | static u8 LM93_RAMP_TO_REG(int ramp) |
694 | { | 694 | { |
695 | ramp = SENSORS_LIMIT(ramp, LM93_RAMP_MIN, LM93_RAMP_MAX); | 695 | ramp = clamp_val(ramp, LM93_RAMP_MIN, LM93_RAMP_MAX); |
696 | return (u8)((ramp + 2) / 5); | 696 | return (u8)((ramp + 2) / 5); |
697 | } | 697 | } |
698 | 698 | ||
@@ -702,7 +702,7 @@ static u8 LM93_RAMP_TO_REG(int ramp) | |||
702 | */ | 702 | */ |
703 | static u8 LM93_PROCHOT_TO_REG(long prochot) | 703 | static u8 LM93_PROCHOT_TO_REG(long prochot) |
704 | { | 704 | { |
705 | prochot = SENSORS_LIMIT(prochot, 0, 255); | 705 | prochot = clamp_val(prochot, 0, 255); |
706 | return (u8)prochot; | 706 | return (u8)prochot; |
707 | } | 707 | } |
708 | 708 | ||
@@ -2052,7 +2052,7 @@ static ssize_t store_pwm_auto_channels(struct device *dev, | |||
2052 | return err; | 2052 | return err; |
2053 | 2053 | ||
2054 | mutex_lock(&data->update_lock); | 2054 | mutex_lock(&data->update_lock); |
2055 | data->block9[nr][LM93_PWM_CTL1] = SENSORS_LIMIT(val, 0, 255); | 2055 | data->block9[nr][LM93_PWM_CTL1] = clamp_val(val, 0, 255); |
2056 | lm93_write_byte(client, LM93_REG_PWM_CTL(nr, LM93_PWM_CTL1), | 2056 | lm93_write_byte(client, LM93_REG_PWM_CTL(nr, LM93_PWM_CTL1), |
2057 | data->block9[nr][LM93_PWM_CTL1]); | 2057 | data->block9[nr][LM93_PWM_CTL1]); |
2058 | mutex_unlock(&data->update_lock); | 2058 | mutex_unlock(&data->update_lock); |
@@ -2397,7 +2397,7 @@ static ssize_t store_prochot_override_duty_cycle(struct device *dev, | |||
2397 | 2397 | ||
2398 | mutex_lock(&data->update_lock); | 2398 | mutex_lock(&data->update_lock); |
2399 | data->prochot_override = (data->prochot_override & 0xf0) | | 2399 | data->prochot_override = (data->prochot_override & 0xf0) | |
2400 | SENSORS_LIMIT(val, 0, 15); | 2400 | clamp_val(val, 0, 15); |
2401 | lm93_write_byte(client, LM93_REG_PROCHOT_OVERRIDE, | 2401 | lm93_write_byte(client, LM93_REG_PROCHOT_OVERRIDE, |
2402 | data->prochot_override); | 2402 | data->prochot_override); |
2403 | mutex_unlock(&data->update_lock); | 2403 | mutex_unlock(&data->update_lock); |