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/w83793.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/w83793.c')
-rw-r--r-- | drivers/hwmon/w83793.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c index 99799fd1d917..660427520c53 100644 --- a/drivers/hwmon/w83793.c +++ b/drivers/hwmon/w83793.c | |||
@@ -191,7 +191,7 @@ static inline u16 FAN_TO_REG(long rpm) | |||
191 | { | 191 | { |
192 | if (rpm <= 0) | 192 | if (rpm <= 0) |
193 | return 0x0fff; | 193 | return 0x0fff; |
194 | return SENSORS_LIMIT((1350000 + (rpm >> 1)) / rpm, 1, 0xffe); | 194 | return clamp_val((1350000 + (rpm >> 1)) / rpm, 1, 0xffe); |
195 | } | 195 | } |
196 | 196 | ||
197 | static inline unsigned long TIME_FROM_REG(u8 reg) | 197 | static inline unsigned long TIME_FROM_REG(u8 reg) |
@@ -201,7 +201,7 @@ static inline unsigned long TIME_FROM_REG(u8 reg) | |||
201 | 201 | ||
202 | static inline u8 TIME_TO_REG(unsigned long val) | 202 | static inline u8 TIME_TO_REG(unsigned long val) |
203 | { | 203 | { |
204 | return SENSORS_LIMIT((val + 50) / 100, 0, 0xff); | 204 | return clamp_val((val + 50) / 100, 0, 0xff); |
205 | } | 205 | } |
206 | 206 | ||
207 | static inline long TEMP_FROM_REG(s8 reg) | 207 | static inline long TEMP_FROM_REG(s8 reg) |
@@ -211,7 +211,7 @@ static inline long TEMP_FROM_REG(s8 reg) | |||
211 | 211 | ||
212 | static inline s8 TEMP_TO_REG(long val, s8 min, s8 max) | 212 | static inline s8 TEMP_TO_REG(long val, s8 min, s8 max) |
213 | { | 213 | { |
214 | return SENSORS_LIMIT((val + (val < 0 ? -500 : 500)) / 1000, min, max); | 214 | return clamp_val((val + (val < 0 ? -500 : 500)) / 1000, min, max); |
215 | } | 215 | } |
216 | 216 | ||
217 | struct w83793_data { | 217 | struct w83793_data { |
@@ -558,7 +558,7 @@ store_pwm(struct device *dev, struct device_attribute *attr, | |||
558 | w83793_write_value(client, W83793_REG_PWM_STOP_TIME(index), | 558 | w83793_write_value(client, W83793_REG_PWM_STOP_TIME(index), |
559 | val); | 559 | val); |
560 | } else { | 560 | } else { |
561 | val = SENSORS_LIMIT(val, 0, 0xff) >> 2; | 561 | val = clamp_val(val, 0, 0xff) >> 2; |
562 | data->pwm[index][nr] = | 562 | data->pwm[index][nr] = |
563 | w83793_read_value(client, W83793_REG_PWM(index, nr)) & 0xc0; | 563 | w83793_read_value(client, W83793_REG_PWM(index, nr)) & 0xc0; |
564 | data->pwm[index][nr] |= val; | 564 | data->pwm[index][nr] |= val; |
@@ -739,7 +739,7 @@ store_sf_setup(struct device *dev, struct device_attribute *attr, | |||
739 | if (nr == SETUP_PWM_DEFAULT) { | 739 | if (nr == SETUP_PWM_DEFAULT) { |
740 | data->pwm_default = | 740 | data->pwm_default = |
741 | w83793_read_value(client, W83793_REG_PWM_DEFAULT) & 0xc0; | 741 | w83793_read_value(client, W83793_REG_PWM_DEFAULT) & 0xc0; |
742 | data->pwm_default |= SENSORS_LIMIT(val, 0, 0xff) >> 2; | 742 | data->pwm_default |= clamp_val(val, 0, 0xff) >> 2; |
743 | w83793_write_value(client, W83793_REG_PWM_DEFAULT, | 743 | w83793_write_value(client, W83793_REG_PWM_DEFAULT, |
744 | data->pwm_default); | 744 | data->pwm_default); |
745 | } else if (nr == SETUP_PWM_UPTIME) { | 745 | } else if (nr == SETUP_PWM_UPTIME) { |
@@ -838,7 +838,7 @@ store_sf_ctrl(struct device *dev, struct device_attribute *attr, | |||
838 | 838 | ||
839 | mutex_lock(&data->update_lock); | 839 | mutex_lock(&data->update_lock); |
840 | if (nr == TEMP_FAN_MAP) { | 840 | if (nr == TEMP_FAN_MAP) { |
841 | val = SENSORS_LIMIT(val, 0, 255); | 841 | val = clamp_val(val, 0, 255); |
842 | w83793_write_value(client, W83793_REG_TEMP_FAN_MAP(index), val); | 842 | w83793_write_value(client, W83793_REG_TEMP_FAN_MAP(index), val); |
843 | data->temp_fan_map[index] = val; | 843 | data->temp_fan_map[index] = val; |
844 | } else if (nr == TEMP_PWM_ENABLE) { | 844 | } else if (nr == TEMP_PWM_ENABLE) { |
@@ -907,7 +907,7 @@ store_sf2_pwm(struct device *dev, struct device_attribute *attr, | |||
907 | err = kstrtoul(buf, 10, &val); | 907 | err = kstrtoul(buf, 10, &val); |
908 | if (err) | 908 | if (err) |
909 | return err; | 909 | return err; |
910 | val = SENSORS_LIMIT(val, 0, 0xff) >> 2; | 910 | val = clamp_val(val, 0, 0xff) >> 2; |
911 | 911 | ||
912 | mutex_lock(&data->update_lock); | 912 | mutex_lock(&data->update_lock); |
913 | data->sf2_pwm[index][nr] = | 913 | data->sf2_pwm[index][nr] = |
@@ -1003,9 +1003,9 @@ store_in(struct device *dev, struct device_attribute *attr, | |||
1003 | /* fix the limit values of 5VDD and 5VSB to ALARM mechanism */ | 1003 | /* fix the limit values of 5VDD and 5VSB to ALARM mechanism */ |
1004 | if (nr == 1 || nr == 2) | 1004 | if (nr == 1 || nr == 2) |
1005 | val -= scale_in_add[index] / scale_in[index]; | 1005 | val -= scale_in_add[index] / scale_in[index]; |
1006 | val = SENSORS_LIMIT(val, 0, 255); | 1006 | val = clamp_val(val, 0, 255); |
1007 | } else { | 1007 | } else { |
1008 | val = SENSORS_LIMIT(val, 0, 0x3FF); | 1008 | val = clamp_val(val, 0, 0x3FF); |
1009 | data->in_low_bits[nr] = | 1009 | data->in_low_bits[nr] = |
1010 | w83793_read_value(client, W83793_REG_IN_LOW_BITS[nr]); | 1010 | w83793_read_value(client, W83793_REG_IN_LOW_BITS[nr]); |
1011 | data->in_low_bits[nr] &= ~(0x03 << (2 * index)); | 1011 | data->in_low_bits[nr] &= ~(0x03 << (2 * index)); |