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/w83795.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/w83795.c')
-rw-r--r-- | drivers/hwmon/w83795.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/hwmon/w83795.c b/drivers/hwmon/w83795.c index 55a4f4894531..e226096148eb 100644 --- a/drivers/hwmon/w83795.c +++ b/drivers/hwmon/w83795.c | |||
@@ -262,7 +262,7 @@ static inline u16 fan_to_reg(long rpm) | |||
262 | { | 262 | { |
263 | if (rpm <= 0) | 263 | if (rpm <= 0) |
264 | return 0x0fff; | 264 | return 0x0fff; |
265 | return SENSORS_LIMIT((1350000 + (rpm >> 1)) / rpm, 1, 0xffe); | 265 | return clamp_val((1350000 + (rpm >> 1)) / rpm, 1, 0xffe); |
266 | } | 266 | } |
267 | 267 | ||
268 | static inline unsigned long time_from_reg(u8 reg) | 268 | static inline unsigned long time_from_reg(u8 reg) |
@@ -272,7 +272,7 @@ static inline unsigned long time_from_reg(u8 reg) | |||
272 | 272 | ||
273 | static inline u8 time_to_reg(unsigned long val) | 273 | static inline u8 time_to_reg(unsigned long val) |
274 | { | 274 | { |
275 | return SENSORS_LIMIT((val + 50) / 100, 0, 0xff); | 275 | return clamp_val((val + 50) / 100, 0, 0xff); |
276 | } | 276 | } |
277 | 277 | ||
278 | static inline long temp_from_reg(s8 reg) | 278 | static inline long temp_from_reg(s8 reg) |
@@ -282,7 +282,7 @@ static inline long temp_from_reg(s8 reg) | |||
282 | 282 | ||
283 | static inline s8 temp_to_reg(long val, s8 min, s8 max) | 283 | static inline s8 temp_to_reg(long val, s8 min, s8 max) |
284 | { | 284 | { |
285 | return SENSORS_LIMIT(val / 1000, min, max); | 285 | return clamp_val(val / 1000, min, max); |
286 | } | 286 | } |
287 | 287 | ||
288 | static const u16 pwm_freq_cksel0[16] = { | 288 | static const u16 pwm_freq_cksel0[16] = { |
@@ -319,7 +319,7 @@ static u8 pwm_freq_to_reg(unsigned long val, u16 clkin) | |||
319 | 319 | ||
320 | /* Best fit for cksel = 1 */ | 320 | /* Best fit for cksel = 1 */ |
321 | base_clock = clkin * 1000 / ((clkin == 48000) ? 384 : 256); | 321 | base_clock = clkin * 1000 / ((clkin == 48000) ? 384 : 256); |
322 | reg1 = SENSORS_LIMIT(DIV_ROUND_CLOSEST(base_clock, val), 1, 128); | 322 | reg1 = clamp_val(DIV_ROUND_CLOSEST(base_clock, val), 1, 128); |
323 | best1 = base_clock / reg1; | 323 | best1 = base_clock / reg1; |
324 | reg1 = 0x80 | (reg1 - 1); | 324 | reg1 = 0x80 | (reg1 - 1); |
325 | 325 | ||
@@ -889,7 +889,7 @@ store_pwm(struct device *dev, struct device_attribute *attr, | |||
889 | val = pwm_freq_to_reg(val, data->clkin); | 889 | val = pwm_freq_to_reg(val, data->clkin); |
890 | break; | 890 | break; |
891 | default: | 891 | default: |
892 | val = SENSORS_LIMIT(val, 0, 0xff); | 892 | val = clamp_val(val, 0, 0xff); |
893 | break; | 893 | break; |
894 | } | 894 | } |
895 | w83795_write(client, W83795_REG_PWM(index, nr), val); | 895 | w83795_write(client, W83795_REG_PWM(index, nr), val); |
@@ -1126,7 +1126,7 @@ store_temp_pwm_enable(struct device *dev, struct device_attribute *attr, | |||
1126 | break; | 1126 | break; |
1127 | case TEMP_PWM_FAN_MAP: | 1127 | case TEMP_PWM_FAN_MAP: |
1128 | mutex_lock(&data->update_lock); | 1128 | mutex_lock(&data->update_lock); |
1129 | tmp = SENSORS_LIMIT(tmp, 0, 0xff); | 1129 | tmp = clamp_val(tmp, 0, 0xff); |
1130 | w83795_write(client, W83795_REG_TFMR(index), tmp); | 1130 | w83795_write(client, W83795_REG_TFMR(index), tmp); |
1131 | data->pwm_tfmr[index] = tmp; | 1131 | data->pwm_tfmr[index] = tmp; |
1132 | mutex_unlock(&data->update_lock); | 1132 | mutex_unlock(&data->update_lock); |
@@ -1177,13 +1177,13 @@ store_fanin(struct device *dev, struct device_attribute *attr, | |||
1177 | mutex_lock(&data->update_lock); | 1177 | mutex_lock(&data->update_lock); |
1178 | switch (nr) { | 1178 | switch (nr) { |
1179 | case FANIN_TARGET: | 1179 | case FANIN_TARGET: |
1180 | val = fan_to_reg(SENSORS_LIMIT(val, 0, 0xfff)); | 1180 | val = fan_to_reg(clamp_val(val, 0, 0xfff)); |
1181 | w83795_write(client, W83795_REG_FTSH(index), val >> 4); | 1181 | w83795_write(client, W83795_REG_FTSH(index), val >> 4); |
1182 | w83795_write(client, W83795_REG_FTSL(index), (val << 4) & 0xf0); | 1182 | w83795_write(client, W83795_REG_FTSL(index), (val << 4) & 0xf0); |
1183 | data->target_speed[index] = val; | 1183 | data->target_speed[index] = val; |
1184 | break; | 1184 | break; |
1185 | case FANIN_TOL: | 1185 | case FANIN_TOL: |
1186 | val = SENSORS_LIMIT(val, 0, 0x3f); | 1186 | val = clamp_val(val, 0, 0x3f); |
1187 | w83795_write(client, W83795_REG_TFTS, val); | 1187 | w83795_write(client, W83795_REG_TFTS, val); |
1188 | data->tol_speed = val; | 1188 | data->tol_speed = val; |
1189 | break; | 1189 | break; |
@@ -1227,22 +1227,22 @@ store_temp_pwm(struct device *dev, struct device_attribute *attr, | |||
1227 | mutex_lock(&data->update_lock); | 1227 | mutex_lock(&data->update_lock); |
1228 | switch (nr) { | 1228 | switch (nr) { |
1229 | case TEMP_PWM_TTTI: | 1229 | case TEMP_PWM_TTTI: |
1230 | val = SENSORS_LIMIT(val, 0, 0x7f); | 1230 | val = clamp_val(val, 0, 0x7f); |
1231 | w83795_write(client, W83795_REG_TTTI(index), val); | 1231 | w83795_write(client, W83795_REG_TTTI(index), val); |
1232 | break; | 1232 | break; |
1233 | case TEMP_PWM_CTFS: | 1233 | case TEMP_PWM_CTFS: |
1234 | val = SENSORS_LIMIT(val, 0, 0x7f); | 1234 | val = clamp_val(val, 0, 0x7f); |
1235 | w83795_write(client, W83795_REG_CTFS(index), val); | 1235 | w83795_write(client, W83795_REG_CTFS(index), val); |
1236 | break; | 1236 | break; |
1237 | case TEMP_PWM_HCT: | 1237 | case TEMP_PWM_HCT: |
1238 | val = SENSORS_LIMIT(val, 0, 0x0f); | 1238 | val = clamp_val(val, 0, 0x0f); |
1239 | tmp = w83795_read(client, W83795_REG_HT(index)); | 1239 | tmp = w83795_read(client, W83795_REG_HT(index)); |
1240 | tmp &= 0x0f; | 1240 | tmp &= 0x0f; |
1241 | tmp |= (val << 4) & 0xf0; | 1241 | tmp |= (val << 4) & 0xf0; |
1242 | w83795_write(client, W83795_REG_HT(index), tmp); | 1242 | w83795_write(client, W83795_REG_HT(index), tmp); |
1243 | break; | 1243 | break; |
1244 | case TEMP_PWM_HOT: | 1244 | case TEMP_PWM_HOT: |
1245 | val = SENSORS_LIMIT(val, 0, 0x0f); | 1245 | val = clamp_val(val, 0, 0x0f); |
1246 | tmp = w83795_read(client, W83795_REG_HT(index)); | 1246 | tmp = w83795_read(client, W83795_REG_HT(index)); |
1247 | tmp &= 0xf0; | 1247 | tmp &= 0xf0; |
1248 | tmp |= val & 0x0f; | 1248 | tmp |= val & 0x0f; |
@@ -1541,7 +1541,7 @@ store_in(struct device *dev, struct device_attribute *attr, | |||
1541 | if ((index >= 17) && | 1541 | if ((index >= 17) && |
1542 | !((data->has_gain >> (index - 17)) & 1)) | 1542 | !((data->has_gain >> (index - 17)) & 1)) |
1543 | val /= 8; | 1543 | val /= 8; |
1544 | val = SENSORS_LIMIT(val, 0, 0x3FF); | 1544 | val = clamp_val(val, 0, 0x3FF); |
1545 | mutex_lock(&data->update_lock); | 1545 | mutex_lock(&data->update_lock); |
1546 | 1546 | ||
1547 | lsb_idx = IN_LSB_SHIFT_IDX[index][IN_LSB_IDX]; | 1547 | lsb_idx = IN_LSB_SHIFT_IDX[index][IN_LSB_IDX]; |
@@ -1596,7 +1596,7 @@ store_sf_setup(struct device *dev, struct device_attribute *attr, | |||
1596 | 1596 | ||
1597 | switch (nr) { | 1597 | switch (nr) { |
1598 | case SETUP_PWM_DEFAULT: | 1598 | case SETUP_PWM_DEFAULT: |
1599 | val = SENSORS_LIMIT(val, 0, 0xff); | 1599 | val = clamp_val(val, 0, 0xff); |
1600 | break; | 1600 | break; |
1601 | case SETUP_PWM_UPTIME: | 1601 | case SETUP_PWM_UPTIME: |
1602 | case SETUP_PWM_DOWNTIME: | 1602 | case SETUP_PWM_DOWNTIME: |