From 2a844c148e1f714ebf42cb96e1b172ce394c36c9 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Wed, 9 Jan 2013 08:09:34 -0800 Subject: 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 Acked-by: George Joseph Acked-by: Jean Delvare --- drivers/hwmon/adt7475.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'drivers/hwmon/adt7475.c') diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c index 989e54c39252..22d008bbdc10 100644 --- a/drivers/hwmon/adt7475.c +++ b/drivers/hwmon/adt7475.c @@ -201,10 +201,10 @@ static inline u16 temp2reg(struct adt7475_data *data, long val) u16 ret; if (!(data->config5 & CONFIG5_TWOSCOMP)) { - val = SENSORS_LIMIT(val, -64000, 191000); + val = clamp_val(val, -64000, 191000); ret = (val + 64500) / 1000; } else { - val = SENSORS_LIMIT(val, -128000, 127000); + val = clamp_val(val, -128000, 127000); if (val < -500) ret = (256500 + val) / 1000; else @@ -240,7 +240,7 @@ static inline u16 rpm2tach(unsigned long rpm) if (rpm == 0) return 0; - return SENSORS_LIMIT((90000 * 60) / rpm, 1, 0xFFFF); + return clamp_val((90000 * 60) / rpm, 1, 0xFFFF); } /* Scaling factors for voltage inputs, taken from the ADT7490 datasheet */ @@ -271,7 +271,7 @@ static inline u16 volt2reg(int channel, long volt, u8 bypass_attn) reg = (volt * 1024) / 2250; else reg = (volt * r[1] * 1024) / ((r[0] + r[1]) * 2250); - return SENSORS_LIMIT(reg, 0, 1023) & (0xff << 2); + return clamp_val(reg, 0, 1023) & (0xff << 2); } static u16 adt7475_read_word(struct i2c_client *client, int reg) @@ -451,10 +451,10 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *attr, switch (sattr->nr) { case OFFSET: if (data->config5 & CONFIG5_TEMPOFFSET) { - val = SENSORS_LIMIT(val, -63000, 127000); + val = clamp_val(val, -63000, 127000); out = data->temp[OFFSET][sattr->index] = val / 1000; } else { - val = SENSORS_LIMIT(val, -63000, 64000); + val = clamp_val(val, -63000, 64000); out = data->temp[OFFSET][sattr->index] = val / 500; } break; @@ -471,7 +471,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *attr, adt7475_read_hystersis(client); temp = reg2temp(data, data->temp[THERM][sattr->index]); - val = SENSORS_LIMIT(val, temp - 15000, temp); + val = clamp_val(val, temp - 15000, temp); val = (temp - val) / 1000; if (sattr->index != 1) { @@ -577,7 +577,7 @@ static ssize_t set_point2(struct device *dev, struct device_attribute *attr, * to figure the range */ temp = reg2temp(data, data->temp[AUTOMIN][sattr->index]); - val = SENSORS_LIMIT(val, temp + autorange_table[0], + val = clamp_val(val, temp + autorange_table[0], temp + autorange_table[ARRAY_SIZE(autorange_table) - 1]); val -= temp; @@ -701,7 +701,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, break; } - data->pwm[sattr->nr][sattr->index] = SENSORS_LIMIT(val, 0, 0xFF); + data->pwm[sattr->nr][sattr->index] = clamp_val(val, 0, 0xFF); i2c_smbus_write_byte_data(client, reg, data->pwm[sattr->nr][sattr->index]); -- cgit v1.2.3