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/adm1031.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/adm1031.c')
-rw-r--r-- | drivers/hwmon/adm1031.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c index c6a4631e833f..253ea396106d 100644 --- a/drivers/hwmon/adm1031.c +++ b/drivers/hwmon/adm1031.c | |||
@@ -162,13 +162,13 @@ adm1031_write_value(struct i2c_client *client, u8 reg, unsigned int value) | |||
162 | static int FAN_TO_REG(int reg, int div) | 162 | static int FAN_TO_REG(int reg, int div) |
163 | { | 163 | { |
164 | int tmp; | 164 | int tmp; |
165 | tmp = FAN_FROM_REG(SENSORS_LIMIT(reg, 0, 65535), div); | 165 | tmp = FAN_FROM_REG(clamp_val(reg, 0, 65535), div); |
166 | return tmp > 255 ? 255 : tmp; | 166 | return tmp > 255 ? 255 : tmp; |
167 | } | 167 | } |
168 | 168 | ||
169 | #define FAN_DIV_FROM_REG(reg) (1<<(((reg)&0xc0)>>6)) | 169 | #define FAN_DIV_FROM_REG(reg) (1<<(((reg)&0xc0)>>6)) |
170 | 170 | ||
171 | #define PWM_TO_REG(val) (SENSORS_LIMIT((val), 0, 255) >> 4) | 171 | #define PWM_TO_REG(val) (clamp_val((val), 0, 255) >> 4) |
172 | #define PWM_FROM_REG(val) ((val) << 4) | 172 | #define PWM_FROM_REG(val) ((val) << 4) |
173 | 173 | ||
174 | #define FAN_CHAN_FROM_REG(reg) (((reg) >> 5) & 7) | 174 | #define FAN_CHAN_FROM_REG(reg) (((reg) >> 5) & 7) |
@@ -675,7 +675,7 @@ static ssize_t set_temp_offset(struct device *dev, | |||
675 | if (ret) | 675 | if (ret) |
676 | return ret; | 676 | return ret; |
677 | 677 | ||
678 | val = SENSORS_LIMIT(val, -15000, 15000); | 678 | val = clamp_val(val, -15000, 15000); |
679 | mutex_lock(&data->update_lock); | 679 | mutex_lock(&data->update_lock); |
680 | data->temp_offset[nr] = TEMP_OFFSET_TO_REG(val); | 680 | data->temp_offset[nr] = TEMP_OFFSET_TO_REG(val); |
681 | adm1031_write_value(client, ADM1031_REG_TEMP_OFFSET(nr), | 681 | adm1031_write_value(client, ADM1031_REG_TEMP_OFFSET(nr), |
@@ -696,7 +696,7 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | |||
696 | if (ret) | 696 | if (ret) |
697 | return ret; | 697 | return ret; |
698 | 698 | ||
699 | val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); | 699 | val = clamp_val(val, -55000, nr == 0 ? 127750 : 127875); |
700 | mutex_lock(&data->update_lock); | 700 | mutex_lock(&data->update_lock); |
701 | data->temp_min[nr] = TEMP_TO_REG(val); | 701 | data->temp_min[nr] = TEMP_TO_REG(val); |
702 | adm1031_write_value(client, ADM1031_REG_TEMP_MIN(nr), | 702 | adm1031_write_value(client, ADM1031_REG_TEMP_MIN(nr), |
@@ -717,7 +717,7 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, | |||
717 | if (ret) | 717 | if (ret) |
718 | return ret; | 718 | return ret; |
719 | 719 | ||
720 | val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); | 720 | val = clamp_val(val, -55000, nr == 0 ? 127750 : 127875); |
721 | mutex_lock(&data->update_lock); | 721 | mutex_lock(&data->update_lock); |
722 | data->temp_max[nr] = TEMP_TO_REG(val); | 722 | data->temp_max[nr] = TEMP_TO_REG(val); |
723 | adm1031_write_value(client, ADM1031_REG_TEMP_MAX(nr), | 723 | adm1031_write_value(client, ADM1031_REG_TEMP_MAX(nr), |
@@ -738,7 +738,7 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr, | |||
738 | if (ret) | 738 | if (ret) |
739 | return ret; | 739 | return ret; |
740 | 740 | ||
741 | val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875); | 741 | val = clamp_val(val, -55000, nr == 0 ? 127750 : 127875); |
742 | mutex_lock(&data->update_lock); | 742 | mutex_lock(&data->update_lock); |
743 | data->temp_crit[nr] = TEMP_TO_REG(val); | 743 | data->temp_crit[nr] = TEMP_TO_REG(val); |
744 | adm1031_write_value(client, ADM1031_REG_TEMP_CRIT(nr), | 744 | adm1031_write_value(client, ADM1031_REG_TEMP_CRIT(nr), |