diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-17 12:33:39 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-17 12:33:39 -0400 |
commit | bdbf0ac7e187b2b757216e653e64f8b808b9077e (patch) | |
tree | 54acb0bd3696249618a16a448c956e63ac6a3806 /drivers/hwmon/max1619.c | |
parent | 8eb88c80d444fd249edaa7d895666cde79e7b3b8 (diff) | |
parent | a0cf354a71bd2969b2f1868530d3fecaebd6dc3d (diff) |
Merge branch 'hwmon-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6
* 'hwmon-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6: (47 commits)
hwmon: (adm1026) Prevent log spamming
hwmon: (adm1026) Fix debug messages
hwmon: (adm1029) Use mask for fan_div value
hwmon: (adt7470) Add documentation
hwmon: (ibmaem) Automatically load on IBM systems via DMI
hwmon: (ibmpex) Automatically load on IBM systems via DMI
hwmon: (w83781d) Use new style driver binding
hwmon: (w83781d) Stop abusing struct i2c_client for ISA devices
hwmon: (w83781d) Make ISA interface depend on CONFIG_ISA
hwmon: (w83781d) Additional information about AS99127F PWM
hwmon: (w83781d) Detect alias chips
hwmon: (w83781d) Refactor beep enable handling
hwmon: Drop dead links to old National Semiconductor chip datasheets
hwmon: (w83791d) add support for thermal cruise mode
hwmon: (w83791d) add pwm_enable support
hwmon: (w83791d) add manual PWM support
hwmon: (w83791d) fan 4/5 pins can also be used for gpio
hwmon: (max1619) Use inline functions instead of macros
hwmon: (it87) Fix thermal sensor type values
hwmon: (lm78) Convert to a new-style i2c driver
...
Diffstat (limited to 'drivers/hwmon/max1619.c')
-rw-r--r-- | drivers/hwmon/max1619.c | 17 |
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) | 75 | static 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 | |||
80 | static 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 { | |||
135 | static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ | 142 | static 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 | } |
140 | show_temp(temp_input1); | 147 | show_temp(temp_input1); |
141 | show_temp(temp_input2); | 148 | show_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; \ |