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/amc6821.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/amc6821.c')
-rw-r--r-- | drivers/hwmon/amc6821.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/drivers/hwmon/amc6821.c b/drivers/hwmon/amc6821.c index ae482e3afdac..4fe49d2bfe1d 100644 --- a/drivers/hwmon/amc6821.c +++ b/drivers/hwmon/amc6821.c | |||
@@ -241,7 +241,7 @@ static ssize_t set_temp( | |||
241 | int ret = kstrtol(buf, 10, &val); | 241 | int ret = kstrtol(buf, 10, &val); |
242 | if (ret) | 242 | if (ret) |
243 | return ret; | 243 | return ret; |
244 | val = SENSORS_LIMIT(val / 1000, -128, 127); | 244 | val = clamp_val(val / 1000, -128, 127); |
245 | 245 | ||
246 | mutex_lock(&data->update_lock); | 246 | mutex_lock(&data->update_lock); |
247 | data->temp[ix] = val; | 247 | data->temp[ix] = val; |
@@ -332,7 +332,7 @@ static ssize_t set_pwm1( | |||
332 | return ret; | 332 | return ret; |
333 | 333 | ||
334 | mutex_lock(&data->update_lock); | 334 | mutex_lock(&data->update_lock); |
335 | data->pwm1 = SENSORS_LIMIT(val , 0, 255); | 335 | data->pwm1 = clamp_val(val , 0, 255); |
336 | i2c_smbus_write_byte_data(client, AMC6821_REG_DCY, data->pwm1); | 336 | i2c_smbus_write_byte_data(client, AMC6821_REG_DCY, data->pwm1); |
337 | mutex_unlock(&data->update_lock); | 337 | mutex_unlock(&data->update_lock); |
338 | return count; | 338 | return count; |
@@ -499,11 +499,11 @@ static ssize_t set_temp_auto_point_temp( | |||
499 | mutex_lock(&data->update_lock); | 499 | mutex_lock(&data->update_lock); |
500 | switch (ix) { | 500 | switch (ix) { |
501 | case 0: | 501 | case 0: |
502 | ptemp[0] = SENSORS_LIMIT(val / 1000, 0, | 502 | ptemp[0] = clamp_val(val / 1000, 0, |
503 | data->temp1_auto_point_temp[1]); | 503 | data->temp1_auto_point_temp[1]); |
504 | ptemp[0] = SENSORS_LIMIT(ptemp[0], 0, | 504 | ptemp[0] = clamp_val(ptemp[0], 0, |
505 | data->temp2_auto_point_temp[1]); | 505 | data->temp2_auto_point_temp[1]); |
506 | ptemp[0] = SENSORS_LIMIT(ptemp[0], 0, 63); | 506 | ptemp[0] = clamp_val(ptemp[0], 0, 63); |
507 | if (i2c_smbus_write_byte_data( | 507 | if (i2c_smbus_write_byte_data( |
508 | client, | 508 | client, |
509 | AMC6821_REG_PSV_TEMP, | 509 | AMC6821_REG_PSV_TEMP, |
@@ -515,20 +515,12 @@ static ssize_t set_temp_auto_point_temp( | |||
515 | goto EXIT; | 515 | goto EXIT; |
516 | break; | 516 | break; |
517 | case 1: | 517 | case 1: |
518 | ptemp[1] = SENSORS_LIMIT( | 518 | ptemp[1] = clamp_val(val / 1000, (ptemp[0] & 0x7C) + 4, 124); |
519 | val / 1000, | ||
520 | (ptemp[0] & 0x7C) + 4, | ||
521 | 124); | ||
522 | ptemp[1] &= 0x7C; | 519 | ptemp[1] &= 0x7C; |
523 | ptemp[2] = SENSORS_LIMIT( | 520 | ptemp[2] = clamp_val(ptemp[2], ptemp[1] + 1, 255); |
524 | ptemp[2], ptemp[1] + 1, | ||
525 | 255); | ||
526 | break; | 521 | break; |
527 | case 2: | 522 | case 2: |
528 | ptemp[2] = SENSORS_LIMIT( | 523 | ptemp[2] = clamp_val(val / 1000, ptemp[1]+1, 255); |
529 | val / 1000, | ||
530 | ptemp[1]+1, | ||
531 | 255); | ||
532 | break; | 524 | break; |
533 | default: | 525 | default: |
534 | dev_dbg(dev, "Unknown attr->index (%d).\n", ix); | 526 | dev_dbg(dev, "Unknown attr->index (%d).\n", ix); |
@@ -561,7 +553,7 @@ static ssize_t set_pwm1_auto_point_pwm( | |||
561 | return ret; | 553 | return ret; |
562 | 554 | ||
563 | mutex_lock(&data->update_lock); | 555 | mutex_lock(&data->update_lock); |
564 | data->pwm1_auto_point_pwm[1] = SENSORS_LIMIT(val, 0, 254); | 556 | data->pwm1_auto_point_pwm[1] = clamp_val(val, 0, 254); |
565 | if (i2c_smbus_write_byte_data(client, AMC6821_REG_DCY_LOW_TEMP, | 557 | if (i2c_smbus_write_byte_data(client, AMC6821_REG_DCY_LOW_TEMP, |
566 | data->pwm1_auto_point_pwm[1])) { | 558 | data->pwm1_auto_point_pwm[1])) { |
567 | dev_err(&client->dev, "Register write error, aborting.\n"); | 559 | dev_err(&client->dev, "Register write error, aborting.\n"); |
@@ -629,7 +621,7 @@ static ssize_t set_fan( | |||
629 | val = 1 > val ? 0xFFFF : 6000000/val; | 621 | val = 1 > val ? 0xFFFF : 6000000/val; |
630 | 622 | ||
631 | mutex_lock(&data->update_lock); | 623 | mutex_lock(&data->update_lock); |
632 | data->fan[ix] = (u16) SENSORS_LIMIT(val, 1, 0xFFFF); | 624 | data->fan[ix] = (u16) clamp_val(val, 1, 0xFFFF); |
633 | if (i2c_smbus_write_byte_data(client, fan_reg_low[ix], | 625 | if (i2c_smbus_write_byte_data(client, fan_reg_low[ix], |
634 | data->fan[ix] & 0xFF)) { | 626 | data->fan[ix] & 0xFF)) { |
635 | dev_err(&client->dev, "Register write error, aborting.\n"); | 627 | dev_err(&client->dev, "Register write error, aborting.\n"); |