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/asc7621.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/asc7621.c')
-rw-r--r-- | drivers/hwmon/asc7621.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/drivers/hwmon/asc7621.c b/drivers/hwmon/asc7621.c index b867aab78049..da7f5b5d5db5 100644 --- a/drivers/hwmon/asc7621.c +++ b/drivers/hwmon/asc7621.c | |||
@@ -191,7 +191,7 @@ static ssize_t store_u8(struct device *dev, struct device_attribute *attr, | |||
191 | if (kstrtol(buf, 10, &reqval)) | 191 | if (kstrtol(buf, 10, &reqval)) |
192 | return -EINVAL; | 192 | return -EINVAL; |
193 | 193 | ||
194 | reqval = SENSORS_LIMIT(reqval, 0, 255); | 194 | reqval = clamp_val(reqval, 0, 255); |
195 | 195 | ||
196 | mutex_lock(&data->update_lock); | 196 | mutex_lock(&data->update_lock); |
197 | data->reg[param->msb[0]] = reqval; | 197 | data->reg[param->msb[0]] = reqval; |
@@ -224,7 +224,7 @@ static ssize_t store_bitmask(struct device *dev, | |||
224 | if (kstrtol(buf, 10, &reqval)) | 224 | if (kstrtol(buf, 10, &reqval)) |
225 | return -EINVAL; | 225 | return -EINVAL; |
226 | 226 | ||
227 | reqval = SENSORS_LIMIT(reqval, 0, param->mask[0]); | 227 | reqval = clamp_val(reqval, 0, param->mask[0]); |
228 | 228 | ||
229 | reqval = (reqval & param->mask[0]) << param->shift[0]; | 229 | reqval = (reqval & param->mask[0]) << param->shift[0]; |
230 | 230 | ||
@@ -274,7 +274,7 @@ static ssize_t store_fan16(struct device *dev, | |||
274 | * generating an alarm. | 274 | * generating an alarm. |
275 | */ | 275 | */ |
276 | reqval = | 276 | reqval = |
277 | (reqval <= 0 ? 0xffff : SENSORS_LIMIT(5400000 / reqval, 0, 0xfffe)); | 277 | (reqval <= 0 ? 0xffff : clamp_val(5400000 / reqval, 0, 0xfffe)); |
278 | 278 | ||
279 | mutex_lock(&data->update_lock); | 279 | mutex_lock(&data->update_lock); |
280 | data->reg[param->msb[0]] = (reqval >> 8) & 0xff; | 280 | data->reg[param->msb[0]] = (reqval >> 8) & 0xff; |
@@ -343,11 +343,11 @@ static ssize_t store_in8(struct device *dev, struct device_attribute *attr, | |||
343 | if (kstrtol(buf, 10, &reqval)) | 343 | if (kstrtol(buf, 10, &reqval)) |
344 | return -EINVAL; | 344 | return -EINVAL; |
345 | 345 | ||
346 | reqval = SENSORS_LIMIT(reqval, 0, 0xffff); | 346 | reqval = clamp_val(reqval, 0, 0xffff); |
347 | 347 | ||
348 | reqval = reqval * 0xc0 / asc7621_in_scaling[nr]; | 348 | reqval = reqval * 0xc0 / asc7621_in_scaling[nr]; |
349 | 349 | ||
350 | reqval = SENSORS_LIMIT(reqval, 0, 0xff); | 350 | reqval = clamp_val(reqval, 0, 0xff); |
351 | 351 | ||
352 | mutex_lock(&data->update_lock); | 352 | mutex_lock(&data->update_lock); |
353 | data->reg[param->msb[0]] = reqval; | 353 | data->reg[param->msb[0]] = reqval; |
@@ -376,7 +376,7 @@ static ssize_t store_temp8(struct device *dev, | |||
376 | if (kstrtol(buf, 10, &reqval)) | 376 | if (kstrtol(buf, 10, &reqval)) |
377 | return -EINVAL; | 377 | return -EINVAL; |
378 | 378 | ||
379 | reqval = SENSORS_LIMIT(reqval, -127000, 127000); | 379 | reqval = clamp_val(reqval, -127000, 127000); |
380 | 380 | ||
381 | temp = reqval / 1000; | 381 | temp = reqval / 1000; |
382 | 382 | ||
@@ -432,7 +432,7 @@ static ssize_t store_temp62(struct device *dev, | |||
432 | if (kstrtol(buf, 10, &reqval)) | 432 | if (kstrtol(buf, 10, &reqval)) |
433 | return -EINVAL; | 433 | return -EINVAL; |
434 | 434 | ||
435 | reqval = SENSORS_LIMIT(reqval, -32000, 31750); | 435 | reqval = clamp_val(reqval, -32000, 31750); |
436 | i = reqval / 1000; | 436 | i = reqval / 1000; |
437 | f = reqval - (i * 1000); | 437 | f = reqval - (i * 1000); |
438 | temp = i << 2; | 438 | temp = i << 2; |
@@ -468,7 +468,7 @@ static ssize_t show_ap2_temp(struct device *dev, | |||
468 | auto_point1 = ((s8) data->reg[param->msb[1]]) * 1000; | 468 | auto_point1 = ((s8) data->reg[param->msb[1]]) * 1000; |
469 | regval = | 469 | regval = |
470 | ((data->reg[param->msb[0]] >> param->shift[0]) & param->mask[0]); | 470 | ((data->reg[param->msb[0]] >> param->shift[0]) & param->mask[0]); |
471 | temp = auto_point1 + asc7621_range_map[SENSORS_LIMIT(regval, 0, 15)]; | 471 | temp = auto_point1 + asc7621_range_map[clamp_val(regval, 0, 15)]; |
472 | mutex_unlock(&data->update_lock); | 472 | mutex_unlock(&data->update_lock); |
473 | 473 | ||
474 | return sprintf(buf, "%d\n", temp); | 474 | return sprintf(buf, "%d\n", temp); |
@@ -489,7 +489,7 @@ static ssize_t store_ap2_temp(struct device *dev, | |||
489 | 489 | ||
490 | mutex_lock(&data->update_lock); | 490 | mutex_lock(&data->update_lock); |
491 | auto_point1 = data->reg[param->msb[1]] * 1000; | 491 | auto_point1 = data->reg[param->msb[1]] * 1000; |
492 | reqval = SENSORS_LIMIT(reqval, auto_point1 + 2000, auto_point1 + 80000); | 492 | reqval = clamp_val(reqval, auto_point1 + 2000, auto_point1 + 80000); |
493 | 493 | ||
494 | for (i = ARRAY_SIZE(asc7621_range_map) - 1; i >= 0; i--) { | 494 | for (i = ARRAY_SIZE(asc7621_range_map) - 1; i >= 0; i--) { |
495 | if (reqval >= auto_point1 + asc7621_range_map[i]) { | 495 | if (reqval >= auto_point1 + asc7621_range_map[i]) { |
@@ -523,7 +523,7 @@ static ssize_t show_pwm_ac(struct device *dev, | |||
523 | regval = config | (altbit << 3); | 523 | regval = config | (altbit << 3); |
524 | mutex_unlock(&data->update_lock); | 524 | mutex_unlock(&data->update_lock); |
525 | 525 | ||
526 | return sprintf(buf, "%u\n", map[SENSORS_LIMIT(regval, 0, 15)]); | 526 | return sprintf(buf, "%u\n", map[clamp_val(regval, 0, 15)]); |
527 | } | 527 | } |
528 | 528 | ||
529 | static ssize_t store_pwm_ac(struct device *dev, | 529 | static ssize_t store_pwm_ac(struct device *dev, |
@@ -663,7 +663,7 @@ static ssize_t show_pwm_freq(struct device *dev, | |||
663 | u8 regval = | 663 | u8 regval = |
664 | (data->reg[param->msb[0]] >> param->shift[0]) & param->mask[0]; | 664 | (data->reg[param->msb[0]] >> param->shift[0]) & param->mask[0]; |
665 | 665 | ||
666 | regval = SENSORS_LIMIT(regval, 0, 15); | 666 | regval = clamp_val(regval, 0, 15); |
667 | 667 | ||
668 | return sprintf(buf, "%u\n", asc7621_pwm_freq_map[regval]); | 668 | return sprintf(buf, "%u\n", asc7621_pwm_freq_map[regval]); |
669 | } | 669 | } |
@@ -711,7 +711,7 @@ static ssize_t show_pwm_ast(struct device *dev, | |||
711 | u8 regval = | 711 | u8 regval = |
712 | (data->reg[param->msb[0]] >> param->shift[0]) & param->mask[0]; | 712 | (data->reg[param->msb[0]] >> param->shift[0]) & param->mask[0]; |
713 | 713 | ||
714 | regval = SENSORS_LIMIT(regval, 0, 7); | 714 | regval = clamp_val(regval, 0, 7); |
715 | 715 | ||
716 | return sprintf(buf, "%u\n", asc7621_pwm_auto_spinup_map[regval]); | 716 | return sprintf(buf, "%u\n", asc7621_pwm_auto_spinup_map[regval]); |
717 | 717 | ||
@@ -759,7 +759,7 @@ static ssize_t show_temp_st(struct device *dev, | |||
759 | SETUP_SHOW_data_param(dev, attr); | 759 | SETUP_SHOW_data_param(dev, attr); |
760 | u8 regval = | 760 | u8 regval = |
761 | (data->reg[param->msb[0]] >> param->shift[0]) & param->mask[0]; | 761 | (data->reg[param->msb[0]] >> param->shift[0]) & param->mask[0]; |
762 | regval = SENSORS_LIMIT(regval, 0, 7); | 762 | regval = clamp_val(regval, 0, 7); |
763 | 763 | ||
764 | return sprintf(buf, "%u\n", asc7621_temp_smoothing_time_map[regval]); | 764 | return sprintf(buf, "%u\n", asc7621_temp_smoothing_time_map[regval]); |
765 | } | 765 | } |