aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/max1619.c
diff options
context:
space:
mode:
authorAndrew Morton <akpm@linux-foundation.org>2008-10-17 11:51:16 -0400
committerJean Delvare <khali@mahadeva.delvare>2008-10-17 11:51:16 -0400
commita80e8ee66793ec2e7ce27fd0495a7b9c8e0a2a24 (patch)
tree49613f960b31f84ed56656367f1758c9cc07ee7f /drivers/hwmon/max1619.c
parent4ed1077953f531b3fef4af4b4ade48a828c48869 (diff)
hwmon: (max1619) Use inline functions instead of macros
Macros evaluating their arguments more than once are evil. Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon/max1619.c')
-rw-r--r--drivers/hwmon/max1619.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c
index 1ab1cacad598..7897754f3a5c 100644
--- a/drivers/hwmon/max1619.c
+++ b/drivers/hwmon/max1619.c
@@ -69,11 +69,18 @@ I2C_CLIENT_INSMOD_1(max1619);
69#define MAX1619_REG_W_TCRIT_HYST 0x13 69#define MAX1619_REG_W_TCRIT_HYST 0x13
70 70
71/* 71/*
72 * Conversions and various macros 72 * Conversions
73 */ 73 */
74 74
75#define TEMP_FROM_REG(val) ((val & 0x80 ? val-0x100 : val) * 1000) 75static int temp_from_reg(int val)
76#define TEMP_TO_REG(val) ((val < 0 ? val+0x100*1000 : val) / 1000) 76{
77 return (val & 0x80 ? val-0x100 : val) * 1000;
78}
79
80static int temp_to_reg(int val)
81{
82 return (val < 0 ? val+0x100*1000 : val) / 1000;
83}
77 84
78/* 85/*
79 * Functions declaration 86 * Functions declaration
@@ -135,7 +142,7 @@ struct max1619_data {
135static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ 142static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \
136{ \ 143{ \
137 struct max1619_data *data = max1619_update_device(dev); \ 144 struct max1619_data *data = max1619_update_device(dev); \
138 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->value)); \ 145 return sprintf(buf, "%d\n", temp_from_reg(data->value)); \
139} 146}
140show_temp(temp_input1); 147show_temp(temp_input1);
141show_temp(temp_input2); 148show_temp(temp_input2);
@@ -153,7 +160,7 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
153 long val = simple_strtol(buf, NULL, 10); \ 160 long val = simple_strtol(buf, NULL, 10); \
154 \ 161 \
155 mutex_lock(&data->update_lock); \ 162 mutex_lock(&data->update_lock); \
156 data->value = TEMP_TO_REG(val); \ 163 data->value = temp_to_reg(val); \
157 i2c_smbus_write_byte_data(client, reg, data->value); \ 164 i2c_smbus_write_byte_data(client, reg, data->value); \
158 mutex_unlock(&data->update_lock); \ 165 mutex_unlock(&data->update_lock); \
159 return count; \ 166 return count; \