diff options
author | Jean Delvare <khali@linux-fr.org> | 2007-11-29 17:46:42 -0500 |
---|---|---|
committer | Mark M. Hoffman <mhoffman@lightlink.com> | 2008-02-07 20:39:42 -0500 |
commit | cb01a2312f56c93d2740e827718966b92b7cbb91 (patch) | |
tree | dfbc86f540a011171b8ee77781d6b32166abfbbb | |
parent | a9273cb8eea503f6b8e28bd5f613962ecba278c5 (diff) |
hwmon: (adm1026) Whitespace cleanups
Whitespace cleanups only:
* Trim trailing whitespace.
* Use tabs for indentation and alignment.
* Add missing space after commas.
* Remove extra spaces.
No functional change, binary is identical before and after this patch.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
-rw-r--r-- | drivers/hwmon/adm1026.c | 451 |
1 files changed, 227 insertions, 224 deletions
diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c index 69b7bc411c1f..9f44ed7ebb7b 100644 --- a/drivers/hwmon/adm1026.c +++ b/drivers/hwmon/adm1026.c | |||
@@ -40,8 +40,8 @@ static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | |||
40 | /* Insmod parameters */ | 40 | /* Insmod parameters */ |
41 | I2C_CLIENT_INSMOD_1(adm1026); | 41 | I2C_CLIENT_INSMOD_1(adm1026); |
42 | 42 | ||
43 | static int gpio_input[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, | 43 | static int gpio_input[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, |
44 | -1, -1, -1, -1, -1, -1, -1, -1 }; | 44 | -1, -1, -1, -1, -1, -1, -1, -1 }; |
45 | static int gpio_output[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, | 45 | static int gpio_output[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, |
46 | -1, -1, -1, -1, -1, -1, -1, -1 }; | 46 | -1, -1, -1, -1, -1, -1, -1, -1 }; |
47 | static int gpio_inverted[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, | 47 | static int gpio_inverted[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, |
@@ -49,46 +49,49 @@ static int gpio_inverted[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
49 | static int gpio_normal[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, | 49 | static int gpio_normal[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, |
50 | -1, -1, -1, -1, -1, -1, -1, -1 }; | 50 | -1, -1, -1, -1, -1, -1, -1, -1 }; |
51 | static int gpio_fan[8] = { -1, -1, -1, -1, -1, -1, -1, -1 }; | 51 | static int gpio_fan[8] = { -1, -1, -1, -1, -1, -1, -1, -1 }; |
52 | module_param_array(gpio_input,int,NULL,0); | 52 | module_param_array(gpio_input, int, NULL, 0); |
53 | MODULE_PARM_DESC(gpio_input,"List of GPIO pins (0-16) to program as inputs"); | 53 | MODULE_PARM_DESC(gpio_input, "List of GPIO pins (0-16) to program as inputs"); |
54 | module_param_array(gpio_output,int,NULL,0); | 54 | module_param_array(gpio_output, int, NULL, 0); |
55 | MODULE_PARM_DESC(gpio_output,"List of GPIO pins (0-16) to program as " | 55 | MODULE_PARM_DESC(gpio_output, "List of GPIO pins (0-16) to program as " |
56 | "outputs"); | 56 | "outputs"); |
57 | module_param_array(gpio_inverted,int,NULL,0); | 57 | module_param_array(gpio_inverted, int, NULL, 0); |
58 | MODULE_PARM_DESC(gpio_inverted,"List of GPIO pins (0-16) to program as " | 58 | MODULE_PARM_DESC(gpio_inverted, "List of GPIO pins (0-16) to program as " |
59 | "inverted"); | 59 | "inverted"); |
60 | module_param_array(gpio_normal,int,NULL,0); | 60 | module_param_array(gpio_normal, int, NULL, 0); |
61 | MODULE_PARM_DESC(gpio_normal,"List of GPIO pins (0-16) to program as " | 61 | MODULE_PARM_DESC(gpio_normal, "List of GPIO pins (0-16) to program as " |
62 | "normal/non-inverted"); | 62 | "normal/non-inverted"); |
63 | module_param_array(gpio_fan,int,NULL,0); | 63 | module_param_array(gpio_fan, int, NULL, 0); |
64 | MODULE_PARM_DESC(gpio_fan,"List of GPIO pins (0-7) to program as fan tachs"); | 64 | MODULE_PARM_DESC(gpio_fan, "List of GPIO pins (0-7) to program as fan tachs"); |
65 | 65 | ||
66 | /* Many ADM1026 constants specified below */ | 66 | /* Many ADM1026 constants specified below */ |
67 | 67 | ||
68 | /* The ADM1026 registers */ | 68 | /* The ADM1026 registers */ |
69 | #define ADM1026_REG_CONFIG1 0x00 | 69 | #define ADM1026_REG_CONFIG1 0x00 |
70 | #define CFG1_MONITOR 0x01 | 70 | #define CFG1_MONITOR 0x01 |
71 | #define CFG1_INT_ENABLE 0x02 | 71 | #define CFG1_INT_ENABLE 0x02 |
72 | #define CFG1_INT_CLEAR 0x04 | 72 | #define CFG1_INT_CLEAR 0x04 |
73 | #define CFG1_AIN8_9 0x08 | 73 | #define CFG1_AIN8_9 0x08 |
74 | #define CFG1_THERM_HOT 0x10 | 74 | #define CFG1_THERM_HOT 0x10 |
75 | #define CFG1_DAC_AFC 0x20 | 75 | #define CFG1_DAC_AFC 0x20 |
76 | #define CFG1_PWM_AFC 0x40 | 76 | #define CFG1_PWM_AFC 0x40 |
77 | #define CFG1_RESET 0x80 | 77 | #define CFG1_RESET 0x80 |
78 | #define ADM1026_REG_CONFIG2 0x01 | 78 | |
79 | #define ADM1026_REG_CONFIG2 0x01 | ||
79 | /* CONFIG2 controls FAN0/GPIO0 through FAN7/GPIO7 */ | 80 | /* CONFIG2 controls FAN0/GPIO0 through FAN7/GPIO7 */ |
80 | #define ADM1026_REG_CONFIG3 0x07 | 81 | |
81 | #define CFG3_GPIO16_ENABLE 0x01 | 82 | #define ADM1026_REG_CONFIG3 0x07 |
82 | #define CFG3_CI_CLEAR 0x02 | 83 | #define CFG3_GPIO16_ENABLE 0x01 |
83 | #define CFG3_VREF_250 0x04 | 84 | #define CFG3_CI_CLEAR 0x02 |
84 | #define CFG3_GPIO16_DIR 0x40 | 85 | #define CFG3_VREF_250 0x04 |
85 | #define CFG3_GPIO16_POL 0x80 | 86 | #define CFG3_GPIO16_DIR 0x40 |
86 | #define ADM1026_REG_E2CONFIG 0x13 | 87 | #define CFG3_GPIO16_POL 0x80 |
87 | #define E2CFG_READ 0x01 | 88 | |
88 | #define E2CFG_WRITE 0x02 | 89 | #define ADM1026_REG_E2CONFIG 0x13 |
89 | #define E2CFG_ERASE 0x04 | 90 | #define E2CFG_READ 0x01 |
90 | #define E2CFG_ROM 0x08 | 91 | #define E2CFG_WRITE 0x02 |
91 | #define E2CFG_CLK_EXT 0x80 | 92 | #define E2CFG_ERASE 0x04 |
93 | #define E2CFG_ROM 0x08 | ||
94 | #define E2CFG_CLK_EXT 0x80 | ||
92 | 95 | ||
93 | /* There are 10 general analog inputs and 7 dedicated inputs | 96 | /* There are 10 general analog inputs and 7 dedicated inputs |
94 | * They are: | 97 | * They are: |
@@ -129,48 +132,48 @@ static u16 ADM1026_REG_TEMP_TMIN[] = { 0x10, 0x11, 0x12 }; | |||
129 | static u16 ADM1026_REG_TEMP_THERM[] = { 0x0d, 0x0e, 0x0f }; | 132 | static u16 ADM1026_REG_TEMP_THERM[] = { 0x0d, 0x0e, 0x0f }; |
130 | static u16 ADM1026_REG_TEMP_OFFSET[] = { 0x1e, 0x6e, 0x6f }; | 133 | static u16 ADM1026_REG_TEMP_OFFSET[] = { 0x1e, 0x6e, 0x6f }; |
131 | 134 | ||
132 | #define ADM1026_REG_FAN(nr) (0x38 + (nr)) | 135 | #define ADM1026_REG_FAN(nr) (0x38 + (nr)) |
133 | #define ADM1026_REG_FAN_MIN(nr) (0x60 + (nr)) | 136 | #define ADM1026_REG_FAN_MIN(nr) (0x60 + (nr)) |
134 | #define ADM1026_REG_FAN_DIV_0_3 0x02 | 137 | #define ADM1026_REG_FAN_DIV_0_3 0x02 |
135 | #define ADM1026_REG_FAN_DIV_4_7 0x03 | 138 | #define ADM1026_REG_FAN_DIV_4_7 0x03 |
136 | 139 | ||
137 | #define ADM1026_REG_DAC 0x04 | 140 | #define ADM1026_REG_DAC 0x04 |
138 | #define ADM1026_REG_PWM 0x05 | 141 | #define ADM1026_REG_PWM 0x05 |
139 | 142 | ||
140 | #define ADM1026_REG_GPIO_CFG_0_3 0x08 | 143 | #define ADM1026_REG_GPIO_CFG_0_3 0x08 |
141 | #define ADM1026_REG_GPIO_CFG_4_7 0x09 | 144 | #define ADM1026_REG_GPIO_CFG_4_7 0x09 |
142 | #define ADM1026_REG_GPIO_CFG_8_11 0x0a | 145 | #define ADM1026_REG_GPIO_CFG_8_11 0x0a |
143 | #define ADM1026_REG_GPIO_CFG_12_15 0x0b | 146 | #define ADM1026_REG_GPIO_CFG_12_15 0x0b |
144 | /* CFG_16 in REG_CFG3 */ | 147 | /* CFG_16 in REG_CFG3 */ |
145 | #define ADM1026_REG_GPIO_STATUS_0_7 0x24 | 148 | #define ADM1026_REG_GPIO_STATUS_0_7 0x24 |
146 | #define ADM1026_REG_GPIO_STATUS_8_15 0x25 | 149 | #define ADM1026_REG_GPIO_STATUS_8_15 0x25 |
147 | /* STATUS_16 in REG_STATUS4 */ | 150 | /* STATUS_16 in REG_STATUS4 */ |
148 | #define ADM1026_REG_GPIO_MASK_0_7 0x1c | 151 | #define ADM1026_REG_GPIO_MASK_0_7 0x1c |
149 | #define ADM1026_REG_GPIO_MASK_8_15 0x1d | 152 | #define ADM1026_REG_GPIO_MASK_8_15 0x1d |
150 | /* MASK_16 in REG_MASK4 */ | 153 | /* MASK_16 in REG_MASK4 */ |
151 | 154 | ||
152 | #define ADM1026_REG_COMPANY 0x16 | 155 | #define ADM1026_REG_COMPANY 0x16 |
153 | #define ADM1026_REG_VERSTEP 0x17 | 156 | #define ADM1026_REG_VERSTEP 0x17 |
154 | /* These are the recognized values for the above regs */ | 157 | /* These are the recognized values for the above regs */ |
155 | #define ADM1026_COMPANY_ANALOG_DEV 0x41 | 158 | #define ADM1026_COMPANY_ANALOG_DEV 0x41 |
156 | #define ADM1026_VERSTEP_GENERIC 0x40 | 159 | #define ADM1026_VERSTEP_GENERIC 0x40 |
157 | #define ADM1026_VERSTEP_ADM1026 0x44 | 160 | #define ADM1026_VERSTEP_ADM1026 0x44 |
158 | 161 | ||
159 | #define ADM1026_REG_MASK1 0x18 | 162 | #define ADM1026_REG_MASK1 0x18 |
160 | #define ADM1026_REG_MASK2 0x19 | 163 | #define ADM1026_REG_MASK2 0x19 |
161 | #define ADM1026_REG_MASK3 0x1a | 164 | #define ADM1026_REG_MASK3 0x1a |
162 | #define ADM1026_REG_MASK4 0x1b | 165 | #define ADM1026_REG_MASK4 0x1b |
163 | 166 | ||
164 | #define ADM1026_REG_STATUS1 0x20 | 167 | #define ADM1026_REG_STATUS1 0x20 |
165 | #define ADM1026_REG_STATUS2 0x21 | 168 | #define ADM1026_REG_STATUS2 0x21 |
166 | #define ADM1026_REG_STATUS3 0x22 | 169 | #define ADM1026_REG_STATUS3 0x22 |
167 | #define ADM1026_REG_STATUS4 0x23 | 170 | #define ADM1026_REG_STATUS4 0x23 |
168 | 171 | ||
169 | #define ADM1026_FAN_ACTIVATION_TEMP_HYST -6 | 172 | #define ADM1026_FAN_ACTIVATION_TEMP_HYST -6 |
170 | #define ADM1026_FAN_CONTROL_TEMP_RANGE 20 | 173 | #define ADM1026_FAN_CONTROL_TEMP_RANGE 20 |
171 | #define ADM1026_PWM_MAX 255 | 174 | #define ADM1026_PWM_MAX 255 |
172 | 175 | ||
173 | /* Conversions. Rounding and limit checking is only done on the TO_REG | 176 | /* Conversions. Rounding and limit checking is only done on the TO_REG |
174 | * variants. Note that you should be a bit careful with which arguments | 177 | * variants. Note that you should be a bit careful with which arguments |
175 | * these macros are called: arguments may be evaluated more than once. | 178 | * these macros are called: arguments may be evaluated more than once. |
176 | */ | 179 | */ |
@@ -186,47 +189,47 @@ static u16 ADM1026_REG_TEMP_OFFSET[] = { 0x1e, 0x6e, 0x6f }; | |||
186 | * The values in this table are based on Table II, page 15 of the | 189 | * The values in this table are based on Table II, page 15 of the |
187 | * datasheet. | 190 | * datasheet. |
188 | */ | 191 | */ |
189 | static int adm1026_scaling[] = { /* .001 Volts */ | 192 | static int adm1026_scaling[] = { /* .001 Volts */ |
190 | 2250, 2250, 2250, 2250, 2250, 2250, | 193 | 2250, 2250, 2250, 2250, 2250, 2250, |
191 | 1875, 1875, 1875, 1875, 3000, 3330, | 194 | 1875, 1875, 1875, 1875, 3000, 3330, |
192 | 3330, 4995, 2250, 12000, 13875 | 195 | 3330, 4995, 2250, 12000, 13875 |
193 | }; | 196 | }; |
194 | #define NEG12_OFFSET 16000 | 197 | #define NEG12_OFFSET 16000 |
195 | #define SCALE(val,from,to) (((val)*(to) + ((from)/2))/(from)) | 198 | #define SCALE(val, from, to) (((val)*(to) + ((from)/2))/(from)) |
196 | #define INS_TO_REG(n,val) (SENSORS_LIMIT(SCALE(val,adm1026_scaling[n],192),\ | 199 | #define INS_TO_REG(n, val) (SENSORS_LIMIT(SCALE(val, adm1026_scaling[n], 192),\ |
197 | 0,255)) | 200 | 0, 255)) |
198 | #define INS_FROM_REG(n,val) (SCALE(val,192,adm1026_scaling[n])) | 201 | #define INS_FROM_REG(n, val) (SCALE(val, 192, adm1026_scaling[n])) |
199 | 202 | ||
200 | /* FAN speed is measured using 22.5kHz clock and counts for 2 pulses | 203 | /* FAN speed is measured using 22.5kHz clock and counts for 2 pulses |
201 | * and we assume a 2 pulse-per-rev fan tach signal | 204 | * and we assume a 2 pulse-per-rev fan tach signal |
202 | * 22500 kHz * 60 (sec/min) * 2 (pulse) / 2 (pulse/rev) == 1350000 | 205 | * 22500 kHz * 60 (sec/min) * 2 (pulse) / 2 (pulse/rev) == 1350000 |
203 | */ | 206 | */ |
204 | #define FAN_TO_REG(val,div) ((val)<=0 ? 0xff : SENSORS_LIMIT(1350000/((val)*\ | 207 | #define FAN_TO_REG(val, div) ((val) <= 0 ? 0xff : \ |
205 | (div)),1,254)) | 208 | SENSORS_LIMIT(1350000/((val)*(div)), 1, 254)) |
206 | #define FAN_FROM_REG(val,div) ((val)==0?-1:(val)==0xff ? 0 : 1350000/((val)*\ | 209 | #define FAN_FROM_REG(val, div) ((val) == 0 ? -1:(val) == 0xff ? 0 : \ |
207 | (div))) | 210 | 1350000/((val)*(div))) |
208 | #define DIV_FROM_REG(val) (1<<(val)) | 211 | #define DIV_FROM_REG(val) (1<<(val)) |
209 | #define DIV_TO_REG(val) ((val)>=8 ? 3 : (val)>=4 ? 2 : (val)>=2 ? 1 : 0) | 212 | #define DIV_TO_REG(val) ((val) >= 8 ? 3 : (val) >= 4 ? 2 : (val) >= 2 ? 1 : 0) |
210 | 213 | ||
211 | /* Temperature is reported in 1 degC increments */ | 214 | /* Temperature is reported in 1 degC increments */ |
212 | #define TEMP_TO_REG(val) (SENSORS_LIMIT(((val)+((val)<0 ? -500 : 500))/1000,\ | 215 | #define TEMP_TO_REG(val) (SENSORS_LIMIT(((val)+((val)<0 ? -500 : 500))/1000,\ |
213 | -127,127)) | 216 | -127, 127)) |
214 | #define TEMP_FROM_REG(val) ((val) * 1000) | 217 | #define TEMP_FROM_REG(val) ((val) * 1000) |
215 | #define OFFSET_TO_REG(val) (SENSORS_LIMIT(((val)+((val)<0 ? -500 : 500))/1000,\ | 218 | #define OFFSET_TO_REG(val) (SENSORS_LIMIT(((val)+((val)<0 ? -500 : 500))/1000,\ |
216 | -127,127)) | 219 | -127, 127)) |
217 | #define OFFSET_FROM_REG(val) ((val) * 1000) | 220 | #define OFFSET_FROM_REG(val) ((val) * 1000) |
218 | 221 | ||
219 | #define PWM_TO_REG(val) (SENSORS_LIMIT(val,0,255)) | 222 | #define PWM_TO_REG(val) (SENSORS_LIMIT(val, 0, 255)) |
220 | #define PWM_FROM_REG(val) (val) | 223 | #define PWM_FROM_REG(val) (val) |
221 | 224 | ||
222 | #define PWM_MIN_TO_REG(val) ((val) & 0xf0) | 225 | #define PWM_MIN_TO_REG(val) ((val) & 0xf0) |
223 | #define PWM_MIN_FROM_REG(val) (((val) & 0xf0) + ((val) >> 4)) | 226 | #define PWM_MIN_FROM_REG(val) (((val) & 0xf0) + ((val) >> 4)) |
224 | 227 | ||
225 | /* Analog output is a voltage, and scaled to millivolts. The datasheet | 228 | /* Analog output is a voltage, and scaled to millivolts. The datasheet |
226 | * indicates that the DAC could be used to drive the fans, but in our | 229 | * indicates that the DAC could be used to drive the fans, but in our |
227 | * example board (Arima HDAMA) it isn't connected to the fans at all. | 230 | * example board (Arima HDAMA) it isn't connected to the fans at all. |
228 | */ | 231 | */ |
229 | #define DAC_TO_REG(val) (SENSORS_LIMIT(((((val)*255)+500)/2500),0,255)) | 232 | #define DAC_TO_REG(val) (SENSORS_LIMIT(((((val)*255)+500)/2500), 0, 255)) |
230 | #define DAC_FROM_REG(val) (((val)*2500)/255) | 233 | #define DAC_FROM_REG(val) (((val)*2500)/255) |
231 | 234 | ||
232 | /* Typically used with systems using a v9.1 VRM spec ? */ | 235 | /* Typically used with systems using a v9.1 VRM spec ? */ |
@@ -243,8 +246,8 @@ static int adm1026_scaling[] = { /* .001 Volts */ | |||
243 | * So, we keep the config data up to date in the cache | 246 | * So, we keep the config data up to date in the cache |
244 | * when it is written and only sample it once every 5 *minutes* | 247 | * when it is written and only sample it once every 5 *minutes* |
245 | */ | 248 | */ |
246 | #define ADM1026_DATA_INTERVAL (1 * HZ) | 249 | #define ADM1026_DATA_INTERVAL (1 * HZ) |
247 | #define ADM1026_CONFIG_INTERVAL (5 * 60 * HZ) | 250 | #define ADM1026_CONFIG_INTERVAL (5 * 60 * HZ) |
248 | 251 | ||
249 | /* We allow for multiple chips in a single system. | 252 | /* We allow for multiple chips in a single system. |
250 | * | 253 | * |
@@ -268,30 +271,30 @@ struct adm1026_data { | |||
268 | unsigned long last_reading; /* In jiffies */ | 271 | unsigned long last_reading; /* In jiffies */ |
269 | unsigned long last_config; /* In jiffies */ | 272 | unsigned long last_config; /* In jiffies */ |
270 | 273 | ||
271 | u8 in[17]; /* Register value */ | 274 | u8 in[17]; /* Register value */ |
272 | u8 in_max[17]; /* Register value */ | 275 | u8 in_max[17]; /* Register value */ |
273 | u8 in_min[17]; /* Register value */ | 276 | u8 in_min[17]; /* Register value */ |
274 | s8 temp[3]; /* Register value */ | 277 | s8 temp[3]; /* Register value */ |
275 | s8 temp_min[3]; /* Register value */ | 278 | s8 temp_min[3]; /* Register value */ |
276 | s8 temp_max[3]; /* Register value */ | 279 | s8 temp_max[3]; /* Register value */ |
277 | s8 temp_tmin[3]; /* Register value */ | 280 | s8 temp_tmin[3]; /* Register value */ |
278 | s8 temp_crit[3]; /* Register value */ | 281 | s8 temp_crit[3]; /* Register value */ |
279 | s8 temp_offset[3]; /* Register value */ | 282 | s8 temp_offset[3]; /* Register value */ |
280 | u8 fan[8]; /* Register value */ | 283 | u8 fan[8]; /* Register value */ |
281 | u8 fan_min[8]; /* Register value */ | 284 | u8 fan_min[8]; /* Register value */ |
282 | u8 fan_div[8]; /* Decoded value */ | 285 | u8 fan_div[8]; /* Decoded value */ |
283 | struct pwm_data pwm1; /* Pwm control values */ | 286 | struct pwm_data pwm1; /* Pwm control values */ |
284 | int vid; /* Decoded value */ | 287 | int vid; /* Decoded value */ |
285 | u8 vrm; /* VRM version */ | 288 | u8 vrm; /* VRM version */ |
286 | u8 analog_out; /* Register value (DAC) */ | 289 | u8 analog_out; /* Register value (DAC) */ |
287 | long alarms; /* Register encoding, combined */ | 290 | long alarms; /* Register encoding, combined */ |
288 | long alarm_mask; /* Register encoding, combined */ | 291 | long alarm_mask; /* Register encoding, combined */ |
289 | long gpio; /* Register encoding, combined */ | 292 | long gpio; /* Register encoding, combined */ |
290 | long gpio_mask; /* Register encoding, combined */ | 293 | long gpio_mask; /* Register encoding, combined */ |
291 | u8 gpio_config[17]; /* Decoded value */ | 294 | u8 gpio_config[17]; /* Decoded value */ |
292 | u8 config1; /* Register value */ | 295 | u8 config1; /* Register value */ |
293 | u8 config2; /* Register value */ | 296 | u8 config2; /* Register value */ |
294 | u8 config3; /* Register value */ | 297 | u8 config3; /* Register value */ |
295 | }; | 298 | }; |
296 | 299 | ||
297 | static int adm1026_attach_adapter(struct i2c_adapter *adapter); | 300 | static int adm1026_attach_adapter(struct i2c_adapter *adapter); |
@@ -301,7 +304,7 @@ static int adm1026_detach_client(struct i2c_client *client); | |||
301 | static int adm1026_read_value(struct i2c_client *client, u8 reg); | 304 | static int adm1026_read_value(struct i2c_client *client, u8 reg); |
302 | static int adm1026_write_value(struct i2c_client *client, u8 reg, int value); | 305 | static int adm1026_write_value(struct i2c_client *client, u8 reg, int value); |
303 | static void adm1026_print_gpio(struct i2c_client *client); | 306 | static void adm1026_print_gpio(struct i2c_client *client); |
304 | static void adm1026_fixup_gpio(struct i2c_client *client); | 307 | static void adm1026_fixup_gpio(struct i2c_client *client); |
305 | static struct adm1026_data *adm1026_update_device(struct device *dev); | 308 | static struct adm1026_data *adm1026_update_device(struct device *dev); |
306 | static void adm1026_init_client(struct i2c_client *client); | 309 | static void adm1026_init_client(struct i2c_client *client); |
307 | 310 | ||
@@ -311,7 +314,7 @@ static struct i2c_driver adm1026_driver = { | |||
311 | .name = "adm1026", | 314 | .name = "adm1026", |
312 | }, | 315 | }, |
313 | .attach_adapter = adm1026_attach_adapter, | 316 | .attach_adapter = adm1026_attach_adapter, |
314 | .detach_client = adm1026_detach_client, | 317 | .detach_client = adm1026_detach_client, |
315 | }; | 318 | }; |
316 | 319 | ||
317 | static int adm1026_attach_adapter(struct i2c_adapter *adapter) | 320 | static int adm1026_attach_adapter(struct i2c_adapter *adapter) |
@@ -355,7 +358,7 @@ static void adm1026_init_client(struct i2c_client *client) | |||
355 | int value, i; | 358 | int value, i; |
356 | struct adm1026_data *data = i2c_get_clientdata(client); | 359 | struct adm1026_data *data = i2c_get_clientdata(client); |
357 | 360 | ||
358 | dev_dbg(&client->dev, "Initializing device\n"); | 361 | dev_dbg(&client->dev, "Initializing device\n"); |
359 | /* Read chip config */ | 362 | /* Read chip config */ |
360 | data->config1 = adm1026_read_value(client, ADM1026_REG_CONFIG1); | 363 | data->config1 = adm1026_read_value(client, ADM1026_REG_CONFIG1); |
361 | data->config2 = adm1026_read_value(client, ADM1026_REG_CONFIG2); | 364 | data->config2 = adm1026_read_value(client, ADM1026_REG_CONFIG2); |
@@ -426,10 +429,10 @@ static void adm1026_init_client(struct i2c_client *client) | |||
426 | * configured, we don't want to mess with them. | 429 | * configured, we don't want to mess with them. |
427 | * If they weren't, the default is 100% PWM, no | 430 | * If they weren't, the default is 100% PWM, no |
428 | * control and will suffice until 'sensors -s' | 431 | * control and will suffice until 'sensors -s' |
429 | * can be run by the user. We DO set the default | 432 | * can be run by the user. We DO set the default |
430 | * value for pwm1.auto_pwm_min to its maximum | 433 | * value for pwm1.auto_pwm_min to its maximum |
431 | * so that enabling automatic pwm fan control | 434 | * so that enabling automatic pwm fan control |
432 | * without first setting a value for pwm1.auto_pwm_min | 435 | * without first setting a value for pwm1.auto_pwm_min |
433 | * will not result in potentially dangerous fan speed decrease. | 436 | * will not result in potentially dangerous fan speed decrease. |
434 | */ | 437 | */ |
435 | data->pwm1.auto_pwm_min=255; | 438 | data->pwm1.auto_pwm_min=255; |
@@ -453,7 +456,7 @@ static void adm1026_init_client(struct i2c_client *client) | |||
453 | static void adm1026_print_gpio(struct i2c_client *client) | 456 | static void adm1026_print_gpio(struct i2c_client *client) |
454 | { | 457 | { |
455 | struct adm1026_data *data = i2c_get_clientdata(client); | 458 | struct adm1026_data *data = i2c_get_clientdata(client); |
456 | int i; | 459 | int i; |
457 | 460 | ||
458 | dev_dbg(&client->dev, "GPIO config is:"); | 461 | dev_dbg(&client->dev, "GPIO config is:"); |
459 | for (i = 0;i <= 7;++i) { | 462 | for (i = 0;i <= 7;++i) { |
@@ -477,7 +480,7 @@ static void adm1026_print_gpio(struct i2c_client *client) | |||
477 | data->gpio_config[16] & 0x02 ? "" : "!", | 480 | data->gpio_config[16] & 0x02 ? "" : "!", |
478 | data->gpio_config[16] & 0x01 ? "OUT" : "IN"); | 481 | data->gpio_config[16] & 0x01 ? "OUT" : "IN"); |
479 | } else { | 482 | } else { |
480 | /* GPIO16 is THERM */ | 483 | /* GPIO16 is THERM */ |
481 | dev_dbg(&client->dev, "\tTHERM\n"); | 484 | dev_dbg(&client->dev, "\tTHERM\n"); |
482 | } | 485 | } |
483 | } | 486 | } |
@@ -485,8 +488,8 @@ static void adm1026_print_gpio(struct i2c_client *client) | |||
485 | static void adm1026_fixup_gpio(struct i2c_client *client) | 488 | static void adm1026_fixup_gpio(struct i2c_client *client) |
486 | { | 489 | { |
487 | struct adm1026_data *data = i2c_get_clientdata(client); | 490 | struct adm1026_data *data = i2c_get_clientdata(client); |
488 | int i; | 491 | int i; |
489 | int value; | 492 | int value; |
490 | 493 | ||
491 | /* Make the changes requested. */ | 494 | /* Make the changes requested. */ |
492 | /* We may need to unlock/stop monitoring or soft-reset the | 495 | /* We may need to unlock/stop monitoring or soft-reset the |
@@ -516,14 +519,14 @@ static void adm1026_fixup_gpio(struct i2c_client *client) | |||
516 | } | 519 | } |
517 | } | 520 | } |
518 | 521 | ||
519 | /* Inverted */ | 522 | /* Inverted */ |
520 | for (i = 0;i <= 16;++i) { | 523 | for (i = 0;i <= 16;++i) { |
521 | if (gpio_inverted[i] >= 0 && gpio_inverted[i] <= 16) { | 524 | if (gpio_inverted[i] >= 0 && gpio_inverted[i] <= 16) { |
522 | data->gpio_config[gpio_inverted[i]] &= ~ 0x02; | 525 | data->gpio_config[gpio_inverted[i]] &= ~ 0x02; |
523 | } | 526 | } |
524 | } | 527 | } |
525 | 528 | ||
526 | /* Normal overrides inverted */ | 529 | /* Normal overrides inverted */ |
527 | for (i = 0;i <= 16;++i) { | 530 | for (i = 0;i <= 16;++i) { |
528 | if (gpio_normal[i] >= 0 && gpio_normal[i] <= 16) { | 531 | if (gpio_normal[i] >= 0 && gpio_normal[i] <= 16) { |
529 | data->gpio_config[gpio_normal[i]] |= 0x02; | 532 | data->gpio_config[gpio_normal[i]] |= 0x02; |
@@ -569,7 +572,7 @@ static struct adm1026_data *adm1026_update_device(struct device *dev) | |||
569 | if (!data->valid | 572 | if (!data->valid |
570 | || time_after(jiffies, data->last_reading + ADM1026_DATA_INTERVAL)) { | 573 | || time_after(jiffies, data->last_reading + ADM1026_DATA_INTERVAL)) { |
571 | /* Things that change quickly */ | 574 | /* Things that change quickly */ |
572 | dev_dbg(&client->dev,"Reading sensor values\n"); | 575 | dev_dbg(&client->dev, "Reading sensor values\n"); |
573 | for (i = 0;i <= 16;++i) { | 576 | for (i = 0;i <= 16;++i) { |
574 | data->in[i] = | 577 | data->in[i] = |
575 | adm1026_read_value(client, ADM1026_REG_IN[i]); | 578 | adm1026_read_value(client, ADM1026_REG_IN[i]); |
@@ -582,18 +585,18 @@ static struct adm1026_data *adm1026_update_device(struct device *dev) | |||
582 | 585 | ||
583 | for (i = 0;i <= 2;++i) { | 586 | for (i = 0;i <= 2;++i) { |
584 | /* NOTE: temp[] is s8 and we assume 2's complement | 587 | /* NOTE: temp[] is s8 and we assume 2's complement |
585 | * "conversion" in the assignment */ | 588 | * "conversion" in the assignment */ |
586 | data->temp[i] = | 589 | data->temp[i] = |
587 | adm1026_read_value(client, ADM1026_REG_TEMP[i]); | 590 | adm1026_read_value(client, ADM1026_REG_TEMP[i]); |
588 | } | 591 | } |
589 | 592 | ||
590 | data->pwm1.pwm = adm1026_read_value(client, | 593 | data->pwm1.pwm = adm1026_read_value(client, |
591 | ADM1026_REG_PWM); | 594 | ADM1026_REG_PWM); |
592 | data->analog_out = adm1026_read_value(client, | 595 | data->analog_out = adm1026_read_value(client, |
593 | ADM1026_REG_DAC); | 596 | ADM1026_REG_DAC); |
594 | /* GPIO16 is MSbit of alarms, move it to gpio */ | 597 | /* GPIO16 is MSbit of alarms, move it to gpio */ |
595 | alarms = adm1026_read_value(client, ADM1026_REG_STATUS4); | 598 | alarms = adm1026_read_value(client, ADM1026_REG_STATUS4); |
596 | gpio = alarms & 0x80 ? 0x0100 : 0; /* GPIO16 */ | 599 | gpio = alarms & 0x80 ? 0x0100 : 0; /* GPIO16 */ |
597 | alarms &= 0x7f; | 600 | alarms &= 0x7f; |
598 | alarms <<= 8; | 601 | alarms <<= 8; |
599 | alarms |= adm1026_read_value(client, ADM1026_REG_STATUS3); | 602 | alarms |= adm1026_read_value(client, ADM1026_REG_STATUS3); |
@@ -604,24 +607,24 @@ static struct adm1026_data *adm1026_update_device(struct device *dev) | |||
604 | data->alarms = alarms; | 607 | data->alarms = alarms; |
605 | 608 | ||
606 | /* Read the GPIO values */ | 609 | /* Read the GPIO values */ |
607 | gpio |= adm1026_read_value(client, | 610 | gpio |= adm1026_read_value(client, |
608 | ADM1026_REG_GPIO_STATUS_8_15); | 611 | ADM1026_REG_GPIO_STATUS_8_15); |
609 | gpio <<= 8; | 612 | gpio <<= 8; |
610 | gpio |= adm1026_read_value(client, | 613 | gpio |= adm1026_read_value(client, |
611 | ADM1026_REG_GPIO_STATUS_0_7); | 614 | ADM1026_REG_GPIO_STATUS_0_7); |
612 | data->gpio = gpio; | 615 | data->gpio = gpio; |
613 | 616 | ||
614 | data->last_reading = jiffies; | 617 | data->last_reading = jiffies; |
615 | }; /* last_reading */ | 618 | }; /* last_reading */ |
616 | 619 | ||
617 | if (!data->valid || | 620 | if (!data->valid || |
618 | time_after(jiffies, data->last_config + ADM1026_CONFIG_INTERVAL)) { | 621 | time_after(jiffies, data->last_config + ADM1026_CONFIG_INTERVAL)) { |
619 | /* Things that don't change often */ | 622 | /* Things that don't change often */ |
620 | dev_dbg(&client->dev, "Reading config values\n"); | 623 | dev_dbg(&client->dev, "Reading config values\n"); |
621 | for (i = 0;i <= 16;++i) { | 624 | for (i = 0;i <= 16;++i) { |
622 | data->in_min[i] = adm1026_read_value(client, | 625 | data->in_min[i] = adm1026_read_value(client, |
623 | ADM1026_REG_IN_MIN[i]); | 626 | ADM1026_REG_IN_MIN[i]); |
624 | data->in_max[i] = adm1026_read_value(client, | 627 | data->in_max[i] = adm1026_read_value(client, |
625 | ADM1026_REG_IN_MAX[i]); | 628 | ADM1026_REG_IN_MAX[i]); |
626 | } | 629 | } |
627 | 630 | ||
@@ -629,32 +632,32 @@ static struct adm1026_data *adm1026_update_device(struct device *dev) | |||
629 | | (adm1026_read_value(client, ADM1026_REG_FAN_DIV_4_7) | 632 | | (adm1026_read_value(client, ADM1026_REG_FAN_DIV_4_7) |
630 | << 8); | 633 | << 8); |
631 | for (i = 0;i <= 7;++i) { | 634 | for (i = 0;i <= 7;++i) { |
632 | data->fan_min[i] = adm1026_read_value(client, | 635 | data->fan_min[i] = adm1026_read_value(client, |
633 | ADM1026_REG_FAN_MIN(i)); | 636 | ADM1026_REG_FAN_MIN(i)); |
634 | data->fan_div[i] = DIV_FROM_REG(value & 0x03); | 637 | data->fan_div[i] = DIV_FROM_REG(value & 0x03); |
635 | value >>= 2; | 638 | value >>= 2; |
636 | } | 639 | } |
637 | 640 | ||
638 | for (i = 0; i <= 2; ++i) { | 641 | for (i = 0; i <= 2; ++i) { |
639 | /* NOTE: temp_xxx[] are s8 and we assume 2's | 642 | /* NOTE: temp_xxx[] are s8 and we assume 2's |
640 | * complement "conversion" in the assignment | 643 | * complement "conversion" in the assignment |
641 | */ | 644 | */ |
642 | data->temp_min[i] = adm1026_read_value(client, | 645 | data->temp_min[i] = adm1026_read_value(client, |
643 | ADM1026_REG_TEMP_MIN[i]); | 646 | ADM1026_REG_TEMP_MIN[i]); |
644 | data->temp_max[i] = adm1026_read_value(client, | 647 | data->temp_max[i] = adm1026_read_value(client, |
645 | ADM1026_REG_TEMP_MAX[i]); | 648 | ADM1026_REG_TEMP_MAX[i]); |
646 | data->temp_tmin[i] = adm1026_read_value(client, | 649 | data->temp_tmin[i] = adm1026_read_value(client, |
647 | ADM1026_REG_TEMP_TMIN[i]); | 650 | ADM1026_REG_TEMP_TMIN[i]); |
648 | data->temp_crit[i] = adm1026_read_value(client, | 651 | data->temp_crit[i] = adm1026_read_value(client, |
649 | ADM1026_REG_TEMP_THERM[i]); | 652 | ADM1026_REG_TEMP_THERM[i]); |
650 | data->temp_offset[i] = adm1026_read_value(client, | 653 | data->temp_offset[i] = adm1026_read_value(client, |
651 | ADM1026_REG_TEMP_OFFSET[i]); | 654 | ADM1026_REG_TEMP_OFFSET[i]); |
652 | } | 655 | } |
653 | 656 | ||
654 | /* Read the STATUS/alarm masks */ | 657 | /* Read the STATUS/alarm masks */ |
655 | alarms = adm1026_read_value(client, ADM1026_REG_MASK4); | 658 | alarms = adm1026_read_value(client, ADM1026_REG_MASK4); |
656 | gpio = alarms & 0x80 ? 0x0100 : 0; /* GPIO16 */ | 659 | gpio = alarms & 0x80 ? 0x0100 : 0; /* GPIO16 */ |
657 | alarms = (alarms & 0x7f) << 8; | 660 | alarms = (alarms & 0x7f) << 8; |
658 | alarms |= adm1026_read_value(client, ADM1026_REG_MASK3); | 661 | alarms |= adm1026_read_value(client, ADM1026_REG_MASK3); |
659 | alarms <<= 8; | 662 | alarms <<= 8; |
660 | alarms |= adm1026_read_value(client, ADM1026_REG_MASK2); | 663 | alarms |= adm1026_read_value(client, ADM1026_REG_MASK2); |
@@ -663,24 +666,24 @@ static struct adm1026_data *adm1026_update_device(struct device *dev) | |||
663 | data->alarm_mask = alarms; | 666 | data->alarm_mask = alarms; |
664 | 667 | ||
665 | /* Read the GPIO values */ | 668 | /* Read the GPIO values */ |
666 | gpio |= adm1026_read_value(client, | 669 | gpio |= adm1026_read_value(client, |
667 | ADM1026_REG_GPIO_MASK_8_15); | 670 | ADM1026_REG_GPIO_MASK_8_15); |
668 | gpio <<= 8; | 671 | gpio <<= 8; |
669 | gpio |= adm1026_read_value(client, ADM1026_REG_GPIO_MASK_0_7); | 672 | gpio |= adm1026_read_value(client, ADM1026_REG_GPIO_MASK_0_7); |
670 | data->gpio_mask = gpio; | 673 | data->gpio_mask = gpio; |
671 | 674 | ||
672 | /* Read various values from CONFIG1 */ | 675 | /* Read various values from CONFIG1 */ |
673 | data->config1 = adm1026_read_value(client, | 676 | data->config1 = adm1026_read_value(client, |
674 | ADM1026_REG_CONFIG1); | 677 | ADM1026_REG_CONFIG1); |
675 | if (data->config1 & CFG1_PWM_AFC) { | 678 | if (data->config1 & CFG1_PWM_AFC) { |
676 | data->pwm1.enable = 2; | 679 | data->pwm1.enable = 2; |
677 | data->pwm1.auto_pwm_min = | 680 | data->pwm1.auto_pwm_min = |
678 | PWM_MIN_FROM_REG(data->pwm1.pwm); | 681 | PWM_MIN_FROM_REG(data->pwm1.pwm); |
679 | } | 682 | } |
680 | /* Read the GPIO config */ | 683 | /* Read the GPIO config */ |
681 | data->config2 = adm1026_read_value(client, | 684 | data->config2 = adm1026_read_value(client, |
682 | ADM1026_REG_CONFIG2); | 685 | ADM1026_REG_CONFIG2); |
683 | data->config3 = adm1026_read_value(client, | 686 | data->config3 = adm1026_read_value(client, |
684 | ADM1026_REG_CONFIG3); | 687 | ADM1026_REG_CONFIG3); |
685 | data->gpio_config[16] = (data->config3 >> 6) & 0x03; | 688 | data->gpio_config[16] = (data->config3 >> 6) & 0x03; |
686 | 689 | ||
@@ -695,7 +698,7 @@ static struct adm1026_data *adm1026_update_device(struct device *dev) | |||
695 | } | 698 | } |
696 | 699 | ||
697 | data->last_config = jiffies; | 700 | data->last_config = jiffies; |
698 | }; /* last_config */ | 701 | }; /* last_config */ |
699 | 702 | ||
700 | dev_dbg(&client->dev, "Setting VID from GPIO11-15.\n"); | 703 | dev_dbg(&client->dev, "Setting VID from GPIO11-15.\n"); |
701 | data->vid = (data->gpio >> 11) & 0x1f; | 704 | data->vid = (data->gpio >> 11) & 0x1f; |
@@ -710,15 +713,15 @@ static ssize_t show_in(struct device *dev, struct device_attribute *attr, | |||
710 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 713 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
711 | int nr = sensor_attr->index; | 714 | int nr = sensor_attr->index; |
712 | struct adm1026_data *data = adm1026_update_device(dev); | 715 | struct adm1026_data *data = adm1026_update_device(dev); |
713 | return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in[nr])); | 716 | return sprintf(buf, "%d\n", INS_FROM_REG(nr, data->in[nr])); |
714 | } | 717 | } |
715 | static ssize_t show_in_min(struct device *dev, struct device_attribute *attr, | 718 | static ssize_t show_in_min(struct device *dev, struct device_attribute *attr, |
716 | char *buf) | 719 | char *buf) |
717 | { | 720 | { |
718 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 721 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
719 | int nr = sensor_attr->index; | 722 | int nr = sensor_attr->index; |
720 | struct adm1026_data *data = adm1026_update_device(dev); | 723 | struct adm1026_data *data = adm1026_update_device(dev); |
721 | return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in_min[nr])); | 724 | return sprintf(buf, "%d\n", INS_FROM_REG(nr, data->in_min[nr])); |
722 | } | 725 | } |
723 | static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, | 726 | static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, |
724 | const char *buf, size_t count) | 727 | const char *buf, size_t count) |
@@ -733,7 +736,7 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, | |||
733 | data->in_min[nr] = INS_TO_REG(nr, val); | 736 | data->in_min[nr] = INS_TO_REG(nr, val); |
734 | adm1026_write_value(client, ADM1026_REG_IN_MIN[nr], data->in_min[nr]); | 737 | adm1026_write_value(client, ADM1026_REG_IN_MIN[nr], data->in_min[nr]); |
735 | mutex_unlock(&data->update_lock); | 738 | mutex_unlock(&data->update_lock); |
736 | return count; | 739 | return count; |
737 | } | 740 | } |
738 | static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, | 741 | static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, |
739 | char *buf) | 742 | char *buf) |
@@ -741,7 +744,7 @@ static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, | |||
741 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 744 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
742 | int nr = sensor_attr->index; | 745 | int nr = sensor_attr->index; |
743 | struct adm1026_data *data = adm1026_update_device(dev); | 746 | struct adm1026_data *data = adm1026_update_device(dev); |
744 | return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in_max[nr])); | 747 | return sprintf(buf, "%d\n", INS_FROM_REG(nr, data->in_max[nr])); |
745 | } | 748 | } |
746 | static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, | 749 | static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, |
747 | const char *buf, size_t count) | 750 | const char *buf, size_t count) |
@@ -788,13 +791,13 @@ in_reg(15); | |||
788 | static ssize_t show_in16(struct device *dev, struct device_attribute *attr, char *buf) | 791 | static ssize_t show_in16(struct device *dev, struct device_attribute *attr, char *buf) |
789 | { | 792 | { |
790 | struct adm1026_data *data = adm1026_update_device(dev); | 793 | struct adm1026_data *data = adm1026_update_device(dev); |
791 | return sprintf(buf,"%d\n", INS_FROM_REG(16, data->in[16]) - | 794 | return sprintf(buf, "%d\n", INS_FROM_REG(16, data->in[16]) - |
792 | NEG12_OFFSET); | 795 | NEG12_OFFSET); |
793 | } | 796 | } |
794 | static ssize_t show_in16_min(struct device *dev, struct device_attribute *attr, char *buf) | 797 | static ssize_t show_in16_min(struct device *dev, struct device_attribute *attr, char *buf) |
795 | { | 798 | { |
796 | struct adm1026_data *data = adm1026_update_device(dev); | 799 | struct adm1026_data *data = adm1026_update_device(dev); |
797 | return sprintf(buf,"%d\n", INS_FROM_REG(16, data->in_min[16]) | 800 | return sprintf(buf, "%d\n", INS_FROM_REG(16, data->in_min[16]) |
798 | - NEG12_OFFSET); | 801 | - NEG12_OFFSET); |
799 | } | 802 | } |
800 | static ssize_t set_in16_min(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 803 | static ssize_t set_in16_min(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
@@ -807,12 +810,12 @@ static ssize_t set_in16_min(struct device *dev, struct device_attribute *attr, c | |||
807 | data->in_min[16] = INS_TO_REG(16, val + NEG12_OFFSET); | 810 | data->in_min[16] = INS_TO_REG(16, val + NEG12_OFFSET); |
808 | adm1026_write_value(client, ADM1026_REG_IN_MIN[16], data->in_min[16]); | 811 | adm1026_write_value(client, ADM1026_REG_IN_MIN[16], data->in_min[16]); |
809 | mutex_unlock(&data->update_lock); | 812 | mutex_unlock(&data->update_lock); |
810 | return count; | 813 | return count; |
811 | } | 814 | } |
812 | static ssize_t show_in16_max(struct device *dev, struct device_attribute *attr, char *buf) | 815 | static ssize_t show_in16_max(struct device *dev, struct device_attribute *attr, char *buf) |
813 | { | 816 | { |
814 | struct adm1026_data *data = adm1026_update_device(dev); | 817 | struct adm1026_data *data = adm1026_update_device(dev); |
815 | return sprintf(buf,"%d\n", INS_FROM_REG(16, data->in_max[16]) | 818 | return sprintf(buf, "%d\n", INS_FROM_REG(16, data->in_max[16]) |
816 | - NEG12_OFFSET); | 819 | - NEG12_OFFSET); |
817 | } | 820 | } |
818 | static ssize_t set_in16_max(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 821 | static ssize_t set_in16_max(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
@@ -843,7 +846,7 @@ static ssize_t show_fan(struct device *dev, struct device_attribute *attr, | |||
843 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 846 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
844 | int nr = sensor_attr->index; | 847 | int nr = sensor_attr->index; |
845 | struct adm1026_data *data = adm1026_update_device(dev); | 848 | struct adm1026_data *data = adm1026_update_device(dev); |
846 | return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr], | 849 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], |
847 | data->fan_div[nr])); | 850 | data->fan_div[nr])); |
848 | } | 851 | } |
849 | static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, | 852 | static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, |
@@ -852,7 +855,7 @@ static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, | |||
852 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 855 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
853 | int nr = sensor_attr->index; | 856 | int nr = sensor_attr->index; |
854 | struct adm1026_data *data = adm1026_update_device(dev); | 857 | struct adm1026_data *data = adm1026_update_device(dev); |
855 | return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan_min[nr], | 858 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr], |
856 | data->fan_div[nr])); | 859 | data->fan_div[nr])); |
857 | } | 860 | } |
858 | static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, | 861 | static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, |
@@ -872,10 +875,10 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, | |||
872 | return count; | 875 | return count; |
873 | } | 876 | } |
874 | 877 | ||
875 | #define fan_offset(offset) \ | 878 | #define fan_offset(offset) \ |
876 | static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan, NULL, \ | 879 | static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan, NULL, \ |
877 | offset - 1); \ | 880 | offset - 1); \ |
878 | static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | 881 | static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ |
879 | show_fan_min, set_fan_min, offset - 1); | 882 | show_fan_min, set_fan_min, offset - 1); |
880 | 883 | ||
881 | fan_offset(1); | 884 | fan_offset(1); |
@@ -892,8 +895,8 @@ static void fixup_fan_min(struct device *dev, int fan, int old_div) | |||
892 | { | 895 | { |
893 | struct i2c_client *client = to_i2c_client(dev); | 896 | struct i2c_client *client = to_i2c_client(dev); |
894 | struct adm1026_data *data = i2c_get_clientdata(client); | 897 | struct adm1026_data *data = i2c_get_clientdata(client); |
895 | int new_min; | 898 | int new_min; |
896 | int new_div = data->fan_div[fan]; | 899 | int new_div = data->fan_div[fan]; |
897 | 900 | ||
898 | /* 0 and 0xff are special. Don't adjust them */ | 901 | /* 0 and 0xff are special. Don't adjust them */ |
899 | if (data->fan_min[fan] == 0 || data->fan_min[fan] == 0xff) { | 902 | if (data->fan_min[fan] == 0 || data->fan_min[fan] == 0xff) { |
@@ -913,7 +916,7 @@ static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr, | |||
913 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 916 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
914 | int nr = sensor_attr->index; | 917 | int nr = sensor_attr->index; |
915 | struct adm1026_data *data = adm1026_update_device(dev); | 918 | struct adm1026_data *data = adm1026_update_device(dev); |
916 | return sprintf(buf,"%d\n", data->fan_div[nr]); | 919 | return sprintf(buf, "%d\n", data->fan_div[nr]); |
917 | } | 920 | } |
918 | static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | 921 | static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, |
919 | const char *buf, size_t count) | 922 | const char *buf, size_t count) |
@@ -922,10 +925,10 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
922 | int nr = sensor_attr->index; | 925 | int nr = sensor_attr->index; |
923 | struct i2c_client *client = to_i2c_client(dev); | 926 | struct i2c_client *client = to_i2c_client(dev); |
924 | struct adm1026_data *data = i2c_get_clientdata(client); | 927 | struct adm1026_data *data = i2c_get_clientdata(client); |
925 | int val,orig_div,new_div,shift; | 928 | int val, orig_div, new_div, shift; |
926 | 929 | ||
927 | val = simple_strtol(buf, NULL, 10); | 930 | val = simple_strtol(buf, NULL, 10); |
928 | new_div = DIV_TO_REG(val); | 931 | new_div = DIV_TO_REG(val); |
929 | if (new_div == 0) { | 932 | if (new_div == 0) { |
930 | return -EINVAL; | 933 | return -EINVAL; |
931 | } | 934 | } |
@@ -946,14 +949,14 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
946 | } | 949 | } |
947 | 950 | ||
948 | if (data->fan_div[nr] != orig_div) { | 951 | if (data->fan_div[nr] != orig_div) { |
949 | fixup_fan_min(dev,nr,orig_div); | 952 | fixup_fan_min(dev, nr, orig_div); |
950 | } | 953 | } |
951 | mutex_unlock(&data->update_lock); | 954 | mutex_unlock(&data->update_lock); |
952 | return count; | 955 | return count; |
953 | } | 956 | } |
954 | 957 | ||
955 | #define fan_offset_div(offset) \ | 958 | #define fan_offset_div(offset) \ |
956 | static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ | 959 | static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ |
957 | show_fan_div, set_fan_div, offset - 1); | 960 | show_fan_div, set_fan_div, offset - 1); |
958 | 961 | ||
959 | fan_offset_div(1); | 962 | fan_offset_div(1); |
@@ -972,7 +975,7 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *attr, | |||
972 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 975 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
973 | int nr = sensor_attr->index; | 976 | int nr = sensor_attr->index; |
974 | struct adm1026_data *data = adm1026_update_device(dev); | 977 | struct adm1026_data *data = adm1026_update_device(dev); |
975 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp[nr])); | 978 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr])); |
976 | } | 979 | } |
977 | static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr, | 980 | static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr, |
978 | char *buf) | 981 | char *buf) |
@@ -980,7 +983,7 @@ static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr, | |||
980 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 983 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
981 | int nr = sensor_attr->index; | 984 | int nr = sensor_attr->index; |
982 | struct adm1026_data *data = adm1026_update_device(dev); | 985 | struct adm1026_data *data = adm1026_update_device(dev); |
983 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_min[nr])); | 986 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[nr])); |
984 | } | 987 | } |
985 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | 988 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, |
986 | const char *buf, size_t count) | 989 | const char *buf, size_t count) |
@@ -1004,7 +1007,7 @@ static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr, | |||
1004 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 1007 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
1005 | int nr = sensor_attr->index; | 1008 | int nr = sensor_attr->index; |
1006 | struct adm1026_data *data = adm1026_update_device(dev); | 1009 | struct adm1026_data *data = adm1026_update_device(dev); |
1007 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_max[nr])); | 1010 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[nr])); |
1008 | } | 1011 | } |
1009 | static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, | 1012 | static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, |
1010 | const char *buf, size_t count) | 1013 | const char *buf, size_t count) |
@@ -1024,7 +1027,7 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, | |||
1024 | } | 1027 | } |
1025 | 1028 | ||
1026 | #define temp_reg(offset) \ | 1029 | #define temp_reg(offset) \ |
1027 | static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp, \ | 1030 | static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp, \ |
1028 | NULL, offset - 1); \ | 1031 | NULL, offset - 1); \ |
1029 | static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ | 1032 | static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ |
1030 | show_temp_min, set_temp_min, offset - 1); \ | 1033 | show_temp_min, set_temp_min, offset - 1); \ |
@@ -1042,7 +1045,7 @@ static ssize_t show_temp_offset(struct device *dev, | |||
1042 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 1045 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
1043 | int nr = sensor_attr->index; | 1046 | int nr = sensor_attr->index; |
1044 | struct adm1026_data *data = adm1026_update_device(dev); | 1047 | struct adm1026_data *data = adm1026_update_device(dev); |
1045 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_offset[nr])); | 1048 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_offset[nr])); |
1046 | } | 1049 | } |
1047 | static ssize_t set_temp_offset(struct device *dev, | 1050 | static ssize_t set_temp_offset(struct device *dev, |
1048 | struct device_attribute *attr, const char *buf, | 1051 | struct device_attribute *attr, const char *buf, |
@@ -1076,7 +1079,7 @@ static ssize_t show_temp_auto_point1_temp_hyst(struct device *dev, | |||
1076 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 1079 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
1077 | int nr = sensor_attr->index; | 1080 | int nr = sensor_attr->index; |
1078 | struct adm1026_data *data = adm1026_update_device(dev); | 1081 | struct adm1026_data *data = adm1026_update_device(dev); |
1079 | return sprintf(buf,"%d\n", TEMP_FROM_REG( | 1082 | return sprintf(buf, "%d\n", TEMP_FROM_REG( |
1080 | ADM1026_FAN_ACTIVATION_TEMP_HYST + data->temp_tmin[nr])); | 1083 | ADM1026_FAN_ACTIVATION_TEMP_HYST + data->temp_tmin[nr])); |
1081 | } | 1084 | } |
1082 | static ssize_t show_temp_auto_point2_temp(struct device *dev, | 1085 | static ssize_t show_temp_auto_point2_temp(struct device *dev, |
@@ -1085,7 +1088,7 @@ static ssize_t show_temp_auto_point2_temp(struct device *dev, | |||
1085 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 1088 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
1086 | int nr = sensor_attr->index; | 1089 | int nr = sensor_attr->index; |
1087 | struct adm1026_data *data = adm1026_update_device(dev); | 1090 | struct adm1026_data *data = adm1026_update_device(dev); |
1088 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_tmin[nr] + | 1091 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_tmin[nr] + |
1089 | ADM1026_FAN_CONTROL_TEMP_RANGE)); | 1092 | ADM1026_FAN_CONTROL_TEMP_RANGE)); |
1090 | } | 1093 | } |
1091 | static ssize_t show_temp_auto_point1_temp(struct device *dev, | 1094 | static ssize_t show_temp_auto_point1_temp(struct device *dev, |
@@ -1094,7 +1097,7 @@ static ssize_t show_temp_auto_point1_temp(struct device *dev, | |||
1094 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 1097 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
1095 | int nr = sensor_attr->index; | 1098 | int nr = sensor_attr->index; |
1096 | struct adm1026_data *data = adm1026_update_device(dev); | 1099 | struct adm1026_data *data = adm1026_update_device(dev); |
1097 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_tmin[nr])); | 1100 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_tmin[nr])); |
1098 | } | 1101 | } |
1099 | static ssize_t set_temp_auto_point1_temp(struct device *dev, | 1102 | static ssize_t set_temp_auto_point1_temp(struct device *dev, |
1100 | struct device_attribute *attr, const char *buf, size_t count) | 1103 | struct device_attribute *attr, const char *buf, size_t count) |
@@ -1113,13 +1116,13 @@ static ssize_t set_temp_auto_point1_temp(struct device *dev, | |||
1113 | return count; | 1116 | return count; |
1114 | } | 1117 | } |
1115 | 1118 | ||
1116 | #define temp_auto_point(offset) \ | 1119 | #define temp_auto_point(offset) \ |
1117 | static SENSOR_DEVICE_ATTR(temp##offset##_auto_point1_temp, S_IRUGO | S_IWUSR, \ | 1120 | static SENSOR_DEVICE_ATTR(temp##offset##_auto_point1_temp, \ |
1118 | show_temp_auto_point1_temp, set_temp_auto_point1_temp, \ | 1121 | S_IRUGO | S_IWUSR, show_temp_auto_point1_temp, \ |
1119 | offset - 1); \ | 1122 | set_temp_auto_point1_temp, offset - 1); \ |
1120 | static SENSOR_DEVICE_ATTR(temp##offset##_auto_point1_temp_hyst, S_IRUGO, \ | 1123 | static SENSOR_DEVICE_ATTR(temp##offset##_auto_point1_temp_hyst, S_IRUGO,\ |
1121 | show_temp_auto_point1_temp_hyst, NULL, offset - 1); \ | 1124 | show_temp_auto_point1_temp_hyst, NULL, offset - 1); \ |
1122 | static SENSOR_DEVICE_ATTR(temp##offset##_auto_point2_temp, S_IRUGO, \ | 1125 | static SENSOR_DEVICE_ATTR(temp##offset##_auto_point2_temp, S_IRUGO, \ |
1123 | show_temp_auto_point2_temp, NULL, offset - 1); | 1126 | show_temp_auto_point2_temp, NULL, offset - 1); |
1124 | 1127 | ||
1125 | temp_auto_point(1); | 1128 | temp_auto_point(1); |
@@ -1130,7 +1133,7 @@ static ssize_t show_temp_crit_enable(struct device *dev, | |||
1130 | struct device_attribute *attr, char *buf) | 1133 | struct device_attribute *attr, char *buf) |
1131 | { | 1134 | { |
1132 | struct adm1026_data *data = adm1026_update_device(dev); | 1135 | struct adm1026_data *data = adm1026_update_device(dev); |
1133 | return sprintf(buf,"%d\n", (data->config1 & CFG1_THERM_HOT) >> 4); | 1136 | return sprintf(buf, "%d\n", (data->config1 & CFG1_THERM_HOT) >> 4); |
1134 | } | 1137 | } |
1135 | static ssize_t set_temp_crit_enable(struct device *dev, | 1138 | static ssize_t set_temp_crit_enable(struct device *dev, |
1136 | struct device_attribute *attr, const char *buf, size_t count) | 1139 | struct device_attribute *attr, const char *buf, size_t count) |
@@ -1142,7 +1145,7 @@ static ssize_t set_temp_crit_enable(struct device *dev, | |||
1142 | if ((val == 1) || (val==0)) { | 1145 | if ((val == 1) || (val==0)) { |
1143 | mutex_lock(&data->update_lock); | 1146 | mutex_lock(&data->update_lock); |
1144 | data->config1 = (data->config1 & ~CFG1_THERM_HOT) | (val << 4); | 1147 | data->config1 = (data->config1 & ~CFG1_THERM_HOT) | (val << 4); |
1145 | adm1026_write_value(client, ADM1026_REG_CONFIG1, | 1148 | adm1026_write_value(client, ADM1026_REG_CONFIG1, |
1146 | data->config1); | 1149 | data->config1); |
1147 | mutex_unlock(&data->update_lock); | 1150 | mutex_unlock(&data->update_lock); |
1148 | } | 1151 | } |
@@ -1163,7 +1166,7 @@ static ssize_t show_temp_crit(struct device *dev, | |||
1163 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 1166 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
1164 | int nr = sensor_attr->index; | 1167 | int nr = sensor_attr->index; |
1165 | struct adm1026_data *data = adm1026_update_device(dev); | 1168 | struct adm1026_data *data = adm1026_update_device(dev); |
1166 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_crit[nr])); | 1169 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit[nr])); |
1167 | } | 1170 | } |
1168 | static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr, | 1171 | static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr, |
1169 | const char *buf, size_t count) | 1172 | const char *buf, size_t count) |
@@ -1193,7 +1196,7 @@ temp_crit_reg(3); | |||
1193 | static ssize_t show_analog_out_reg(struct device *dev, struct device_attribute *attr, char *buf) | 1196 | static ssize_t show_analog_out_reg(struct device *dev, struct device_attribute *attr, char *buf) |
1194 | { | 1197 | { |
1195 | struct adm1026_data *data = adm1026_update_device(dev); | 1198 | struct adm1026_data *data = adm1026_update_device(dev); |
1196 | return sprintf(buf,"%d\n", DAC_FROM_REG(data->analog_out)); | 1199 | return sprintf(buf, "%d\n", DAC_FROM_REG(data->analog_out)); |
1197 | } | 1200 | } |
1198 | static ssize_t set_analog_out_reg(struct device *dev, struct device_attribute *attr, const char *buf, | 1201 | static ssize_t set_analog_out_reg(struct device *dev, struct device_attribute *attr, const char *buf, |
1199 | size_t count) | 1202 | size_t count) |
@@ -1209,20 +1212,20 @@ static ssize_t set_analog_out_reg(struct device *dev, struct device_attribute *a | |||
1209 | return count; | 1212 | return count; |
1210 | } | 1213 | } |
1211 | 1214 | ||
1212 | static DEVICE_ATTR(analog_out, S_IRUGO | S_IWUSR, show_analog_out_reg, | 1215 | static DEVICE_ATTR(analog_out, S_IRUGO | S_IWUSR, show_analog_out_reg, |
1213 | set_analog_out_reg); | 1216 | set_analog_out_reg); |
1214 | 1217 | ||
1215 | static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf) | 1218 | static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf) |
1216 | { | 1219 | { |
1217 | struct adm1026_data *data = adm1026_update_device(dev); | 1220 | struct adm1026_data *data = adm1026_update_device(dev); |
1218 | return sprintf(buf,"%d\n", vid_from_reg(data->vid & 0x3f, data->vrm)); | 1221 | return sprintf(buf, "%d\n", vid_from_reg(data->vid & 0x3f, data->vrm)); |
1219 | } | 1222 | } |
1220 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); | 1223 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); |
1221 | 1224 | ||
1222 | static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) | 1225 | static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) |
1223 | { | 1226 | { |
1224 | struct adm1026_data *data = dev_get_drvdata(dev); | 1227 | struct adm1026_data *data = dev_get_drvdata(dev); |
1225 | return sprintf(buf,"%d\n", data->vrm); | 1228 | return sprintf(buf, "%d\n", data->vrm); |
1226 | } | 1229 | } |
1227 | static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, | 1230 | static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, |
1228 | size_t count) | 1231 | size_t count) |
@@ -1284,7 +1287,7 @@ static SENSOR_DEVICE_ATTR(in8_alarm, S_IRUGO, show_alarm, NULL, 26); | |||
1284 | static ssize_t show_alarm_mask(struct device *dev, struct device_attribute *attr, char *buf) | 1287 | static ssize_t show_alarm_mask(struct device *dev, struct device_attribute *attr, char *buf) |
1285 | { | 1288 | { |
1286 | struct adm1026_data *data = adm1026_update_device(dev); | 1289 | struct adm1026_data *data = adm1026_update_device(dev); |
1287 | return sprintf(buf,"%ld\n", data->alarm_mask); | 1290 | return sprintf(buf, "%ld\n", data->alarm_mask); |
1288 | } | 1291 | } |
1289 | static ssize_t set_alarm_mask(struct device *dev, struct device_attribute *attr, const char *buf, | 1292 | static ssize_t set_alarm_mask(struct device *dev, struct device_attribute *attr, const char *buf, |
1290 | size_t count) | 1293 | size_t count) |
@@ -1320,7 +1323,7 @@ static DEVICE_ATTR(alarm_mask, S_IRUGO | S_IWUSR, show_alarm_mask, | |||
1320 | static ssize_t show_gpio(struct device *dev, struct device_attribute *attr, char *buf) | 1323 | static ssize_t show_gpio(struct device *dev, struct device_attribute *attr, char *buf) |
1321 | { | 1324 | { |
1322 | struct adm1026_data *data = adm1026_update_device(dev); | 1325 | struct adm1026_data *data = adm1026_update_device(dev); |
1323 | return sprintf(buf,"%ld\n", data->gpio); | 1326 | return sprintf(buf, "%ld\n", data->gpio); |
1324 | } | 1327 | } |
1325 | static ssize_t set_gpio(struct device *dev, struct device_attribute *attr, const char *buf, | 1328 | static ssize_t set_gpio(struct device *dev, struct device_attribute *attr, const char *buf, |
1326 | size_t count) | 1329 | size_t count) |
@@ -1328,16 +1331,16 @@ static ssize_t set_gpio(struct device *dev, struct device_attribute *attr, const | |||
1328 | struct i2c_client *client = to_i2c_client(dev); | 1331 | struct i2c_client *client = to_i2c_client(dev); |
1329 | struct adm1026_data *data = i2c_get_clientdata(client); | 1332 | struct adm1026_data *data = i2c_get_clientdata(client); |
1330 | int val = simple_strtol(buf, NULL, 10); | 1333 | int val = simple_strtol(buf, NULL, 10); |
1331 | long gpio; | 1334 | long gpio; |
1332 | 1335 | ||
1333 | mutex_lock(&data->update_lock); | 1336 | mutex_lock(&data->update_lock); |
1334 | data->gpio = val & 0x1ffff; | 1337 | data->gpio = val & 0x1ffff; |
1335 | gpio = data->gpio; | 1338 | gpio = data->gpio; |
1336 | adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_0_7,gpio & 0xff); | 1339 | adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_0_7, gpio & 0xff); |
1337 | gpio >>= 8; | 1340 | gpio >>= 8; |
1338 | adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_8_15,gpio & 0xff); | 1341 | adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_8_15, gpio & 0xff); |
1339 | gpio = ((gpio >> 1) & 0x80) | (data->alarms >> 24 & 0x7f); | 1342 | gpio = ((gpio >> 1) & 0x80) | (data->alarms >> 24 & 0x7f); |
1340 | adm1026_write_value(client, ADM1026_REG_STATUS4,gpio & 0xff); | 1343 | adm1026_write_value(client, ADM1026_REG_STATUS4, gpio & 0xff); |
1341 | mutex_unlock(&data->update_lock); | 1344 | mutex_unlock(&data->update_lock); |
1342 | return count; | 1345 | return count; |
1343 | } | 1346 | } |
@@ -1348,7 +1351,7 @@ static DEVICE_ATTR(gpio, S_IRUGO | S_IWUSR, show_gpio, set_gpio); | |||
1348 | static ssize_t show_gpio_mask(struct device *dev, struct device_attribute *attr, char *buf) | 1351 | static ssize_t show_gpio_mask(struct device *dev, struct device_attribute *attr, char *buf) |
1349 | { | 1352 | { |
1350 | struct adm1026_data *data = adm1026_update_device(dev); | 1353 | struct adm1026_data *data = adm1026_update_device(dev); |
1351 | return sprintf(buf,"%ld\n", data->gpio_mask); | 1354 | return sprintf(buf, "%ld\n", data->gpio_mask); |
1352 | } | 1355 | } |
1353 | static ssize_t set_gpio_mask(struct device *dev, struct device_attribute *attr, const char *buf, | 1356 | static ssize_t set_gpio_mask(struct device *dev, struct device_attribute *attr, const char *buf, |
1354 | size_t count) | 1357 | size_t count) |
@@ -1356,16 +1359,16 @@ static ssize_t set_gpio_mask(struct device *dev, struct device_attribute *attr, | |||
1356 | struct i2c_client *client = to_i2c_client(dev); | 1359 | struct i2c_client *client = to_i2c_client(dev); |
1357 | struct adm1026_data *data = i2c_get_clientdata(client); | 1360 | struct adm1026_data *data = i2c_get_clientdata(client); |
1358 | int val = simple_strtol(buf, NULL, 10); | 1361 | int val = simple_strtol(buf, NULL, 10); |
1359 | long mask; | 1362 | long mask; |
1360 | 1363 | ||
1361 | mutex_lock(&data->update_lock); | 1364 | mutex_lock(&data->update_lock); |
1362 | data->gpio_mask = val & 0x1ffff; | 1365 | data->gpio_mask = val & 0x1ffff; |
1363 | mask = data->gpio_mask; | 1366 | mask = data->gpio_mask; |
1364 | adm1026_write_value(client, ADM1026_REG_GPIO_MASK_0_7,mask & 0xff); | 1367 | adm1026_write_value(client, ADM1026_REG_GPIO_MASK_0_7, mask & 0xff); |
1365 | mask >>= 8; | 1368 | mask >>= 8; |
1366 | adm1026_write_value(client, ADM1026_REG_GPIO_MASK_8_15,mask & 0xff); | 1369 | adm1026_write_value(client, ADM1026_REG_GPIO_MASK_8_15, mask & 0xff); |
1367 | mask = ((mask >> 1) & 0x80) | (data->alarm_mask >> 24 & 0x7f); | 1370 | mask = ((mask >> 1) & 0x80) | (data->alarm_mask >> 24 & 0x7f); |
1368 | adm1026_write_value(client, ADM1026_REG_MASK1,mask & 0xff); | 1371 | adm1026_write_value(client, ADM1026_REG_MASK1, mask & 0xff); |
1369 | mutex_unlock(&data->update_lock); | 1372 | mutex_unlock(&data->update_lock); |
1370 | return count; | 1373 | return count; |
1371 | } | 1374 | } |
@@ -1375,7 +1378,7 @@ static DEVICE_ATTR(gpio_mask, S_IRUGO | S_IWUSR, show_gpio_mask, set_gpio_mask); | |||
1375 | static ssize_t show_pwm_reg(struct device *dev, struct device_attribute *attr, char *buf) | 1378 | static ssize_t show_pwm_reg(struct device *dev, struct device_attribute *attr, char *buf) |
1376 | { | 1379 | { |
1377 | struct adm1026_data *data = adm1026_update_device(dev); | 1380 | struct adm1026_data *data = adm1026_update_device(dev); |
1378 | return sprintf(buf,"%d\n", PWM_FROM_REG(data->pwm1.pwm)); | 1381 | return sprintf(buf, "%d\n", PWM_FROM_REG(data->pwm1.pwm)); |
1379 | } | 1382 | } |
1380 | static ssize_t set_pwm_reg(struct device *dev, struct device_attribute *attr, const char *buf, | 1383 | static ssize_t set_pwm_reg(struct device *dev, struct device_attribute *attr, const char *buf, |
1381 | size_t count) | 1384 | size_t count) |
@@ -1396,7 +1399,7 @@ static ssize_t set_pwm_reg(struct device *dev, struct device_attribute *attr, co | |||
1396 | static ssize_t show_auto_pwm_min(struct device *dev, struct device_attribute *attr, char *buf) | 1399 | static ssize_t show_auto_pwm_min(struct device *dev, struct device_attribute *attr, char *buf) |
1397 | { | 1400 | { |
1398 | struct adm1026_data *data = adm1026_update_device(dev); | 1401 | struct adm1026_data *data = adm1026_update_device(dev); |
1399 | return sprintf(buf,"%d\n", data->pwm1.auto_pwm_min); | 1402 | return sprintf(buf, "%d\n", data->pwm1.auto_pwm_min); |
1400 | } | 1403 | } |
1401 | static ssize_t set_auto_pwm_min(struct device *dev, struct device_attribute *attr, const char *buf, | 1404 | static ssize_t set_auto_pwm_min(struct device *dev, struct device_attribute *attr, const char *buf, |
1402 | size_t count) | 1405 | size_t count) |
@@ -1406,10 +1409,10 @@ static ssize_t set_auto_pwm_min(struct device *dev, struct device_attribute *att | |||
1406 | int val = simple_strtol(buf, NULL, 10); | 1409 | int val = simple_strtol(buf, NULL, 10); |
1407 | 1410 | ||
1408 | mutex_lock(&data->update_lock); | 1411 | mutex_lock(&data->update_lock); |
1409 | data->pwm1.auto_pwm_min = SENSORS_LIMIT(val,0,255); | 1412 | data->pwm1.auto_pwm_min = SENSORS_LIMIT(val, 0, 255); |
1410 | if (data->pwm1.enable == 2) { /* apply immediately */ | 1413 | if (data->pwm1.enable == 2) { /* apply immediately */ |
1411 | data->pwm1.pwm = PWM_TO_REG((data->pwm1.pwm & 0x0f) | | 1414 | data->pwm1.pwm = PWM_TO_REG((data->pwm1.pwm & 0x0f) | |
1412 | PWM_MIN_TO_REG(data->pwm1.auto_pwm_min)); | 1415 | PWM_MIN_TO_REG(data->pwm1.auto_pwm_min)); |
1413 | adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); | 1416 | adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); |
1414 | } | 1417 | } |
1415 | mutex_unlock(&data->update_lock); | 1418 | mutex_unlock(&data->update_lock); |
@@ -1417,12 +1420,12 @@ static ssize_t set_auto_pwm_min(struct device *dev, struct device_attribute *att | |||
1417 | } | 1420 | } |
1418 | static ssize_t show_auto_pwm_max(struct device *dev, struct device_attribute *attr, char *buf) | 1421 | static ssize_t show_auto_pwm_max(struct device *dev, struct device_attribute *attr, char *buf) |
1419 | { | 1422 | { |
1420 | return sprintf(buf,"%d\n", ADM1026_PWM_MAX); | 1423 | return sprintf(buf, "%d\n", ADM1026_PWM_MAX); |
1421 | } | 1424 | } |
1422 | static ssize_t show_pwm_enable(struct device *dev, struct device_attribute *attr, char *buf) | 1425 | static ssize_t show_pwm_enable(struct device *dev, struct device_attribute *attr, char *buf) |
1423 | { | 1426 | { |
1424 | struct adm1026_data *data = adm1026_update_device(dev); | 1427 | struct adm1026_data *data = adm1026_update_device(dev); |
1425 | return sprintf(buf,"%d\n", data->pwm1.enable); | 1428 | return sprintf(buf, "%d\n", data->pwm1.enable); |
1426 | } | 1429 | } |
1427 | static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, const char *buf, | 1430 | static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, const char *buf, |
1428 | size_t count) | 1431 | size_t count) |
@@ -1430,7 +1433,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, | |||
1430 | struct i2c_client *client = to_i2c_client(dev); | 1433 | struct i2c_client *client = to_i2c_client(dev); |
1431 | struct adm1026_data *data = i2c_get_clientdata(client); | 1434 | struct adm1026_data *data = i2c_get_clientdata(client); |
1432 | int val = simple_strtol(buf, NULL, 10); | 1435 | int val = simple_strtol(buf, NULL, 10); |
1433 | int old_enable; | 1436 | int old_enable; |
1434 | 1437 | ||
1435 | if ((val >= 0) && (val < 3)) { | 1438 | if ((val >= 0) && (val < 3)) { |
1436 | mutex_lock(&data->update_lock); | 1439 | mutex_lock(&data->update_lock); |
@@ -1440,15 +1443,15 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, | |||
1440 | | ((val == 2) ? CFG1_PWM_AFC : 0); | 1443 | | ((val == 2) ? CFG1_PWM_AFC : 0); |
1441 | adm1026_write_value(client, ADM1026_REG_CONFIG1, | 1444 | adm1026_write_value(client, ADM1026_REG_CONFIG1, |
1442 | data->config1); | 1445 | data->config1); |
1443 | if (val == 2) { /* apply pwm1_auto_pwm_min to pwm1 */ | 1446 | if (val == 2) { /* apply pwm1_auto_pwm_min to pwm1 */ |
1444 | data->pwm1.pwm = PWM_TO_REG((data->pwm1.pwm & 0x0f) | | 1447 | data->pwm1.pwm = PWM_TO_REG((data->pwm1.pwm & 0x0f) | |
1445 | PWM_MIN_TO_REG(data->pwm1.auto_pwm_min)); | 1448 | PWM_MIN_TO_REG(data->pwm1.auto_pwm_min)); |
1446 | adm1026_write_value(client, ADM1026_REG_PWM, | 1449 | adm1026_write_value(client, ADM1026_REG_PWM, |
1447 | data->pwm1.pwm); | 1450 | data->pwm1.pwm); |
1448 | } else if (!((old_enable == 1) && (val == 1))) { | 1451 | } else if (!((old_enable == 1) && (val == 1))) { |
1449 | /* set pwm to safe value */ | 1452 | /* set pwm to safe value */ |
1450 | data->pwm1.pwm = 255; | 1453 | data->pwm1.pwm = 255; |
1451 | adm1026_write_value(client, ADM1026_REG_PWM, | 1454 | adm1026_write_value(client, ADM1026_REG_PWM, |
1452 | data->pwm1.pwm); | 1455 | data->pwm1.pwm); |
1453 | } | 1456 | } |
1454 | mutex_unlock(&data->update_lock); | 1457 | mutex_unlock(&data->update_lock); |
@@ -1457,20 +1460,20 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, | |||
1457 | } | 1460 | } |
1458 | 1461 | ||
1459 | /* enable PWM fan control */ | 1462 | /* enable PWM fan control */ |
1460 | static DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm_reg, set_pwm_reg); | 1463 | static DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm_reg, set_pwm_reg); |
1461 | static DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, show_pwm_reg, set_pwm_reg); | 1464 | static DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, show_pwm_reg, set_pwm_reg); |
1462 | static DEVICE_ATTR(pwm3, S_IRUGO | S_IWUSR, show_pwm_reg, set_pwm_reg); | 1465 | static DEVICE_ATTR(pwm3, S_IRUGO | S_IWUSR, show_pwm_reg, set_pwm_reg); |
1463 | static DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, show_pwm_enable, | 1466 | static DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, show_pwm_enable, |
1464 | set_pwm_enable); | 1467 | set_pwm_enable); |
1465 | static DEVICE_ATTR(pwm2_enable, S_IRUGO | S_IWUSR, show_pwm_enable, | 1468 | static DEVICE_ATTR(pwm2_enable, S_IRUGO | S_IWUSR, show_pwm_enable, |
1466 | set_pwm_enable); | 1469 | set_pwm_enable); |
1467 | static DEVICE_ATTR(pwm3_enable, S_IRUGO | S_IWUSR, show_pwm_enable, | 1470 | static DEVICE_ATTR(pwm3_enable, S_IRUGO | S_IWUSR, show_pwm_enable, |
1468 | set_pwm_enable); | 1471 | set_pwm_enable); |
1469 | static DEVICE_ATTR(temp1_auto_point1_pwm, S_IRUGO | S_IWUSR, | 1472 | static DEVICE_ATTR(temp1_auto_point1_pwm, S_IRUGO | S_IWUSR, |
1470 | show_auto_pwm_min, set_auto_pwm_min); | 1473 | show_auto_pwm_min, set_auto_pwm_min); |
1471 | static DEVICE_ATTR(temp2_auto_point1_pwm, S_IRUGO | S_IWUSR, | 1474 | static DEVICE_ATTR(temp2_auto_point1_pwm, S_IRUGO | S_IWUSR, |
1472 | show_auto_pwm_min, set_auto_pwm_min); | 1475 | show_auto_pwm_min, set_auto_pwm_min); |
1473 | static DEVICE_ATTR(temp3_auto_point1_pwm, S_IRUGO | S_IWUSR, | 1476 | static DEVICE_ATTR(temp3_auto_point1_pwm, S_IRUGO | S_IWUSR, |
1474 | show_auto_pwm_min, set_auto_pwm_min); | 1477 | show_auto_pwm_min, set_auto_pwm_min); |
1475 | 1478 | ||
1476 | static DEVICE_ATTR(temp1_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL); | 1479 | static DEVICE_ATTR(temp1_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL); |
@@ -1695,7 +1698,7 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address, | |||
1695 | dev_dbg(&new_client->dev, ": Autodetection " | 1698 | dev_dbg(&new_client->dev, ": Autodetection " |
1696 | "failed\n"); | 1699 | "failed\n"); |
1697 | /* Not an ADM1026 ... */ | 1700 | /* Not an ADM1026 ... */ |
1698 | if (kind == 0) { /* User used force=x,y */ | 1701 | if (kind == 0) { /* User used force=x,y */ |
1699 | dev_err(&adapter->dev, "Generic ADM1026 not " | 1702 | dev_err(&adapter->dev, "Generic ADM1026 not " |
1700 | "found at %d,0x%02x. Try " | 1703 | "found at %d,0x%02x. Try " |
1701 | "force_adm1026.\n", | 1704 | "force_adm1026.\n", |
@@ -1775,14 +1778,14 @@ static int __init sm_adm1026_init(void) | |||
1775 | return i2c_add_driver(&adm1026_driver); | 1778 | return i2c_add_driver(&adm1026_driver); |
1776 | } | 1779 | } |
1777 | 1780 | ||
1778 | static void __exit sm_adm1026_exit(void) | 1781 | static void __exit sm_adm1026_exit(void) |
1779 | { | 1782 | { |
1780 | i2c_del_driver(&adm1026_driver); | 1783 | i2c_del_driver(&adm1026_driver); |
1781 | } | 1784 | } |
1782 | 1785 | ||
1783 | MODULE_LICENSE("GPL"); | 1786 | MODULE_LICENSE("GPL"); |
1784 | MODULE_AUTHOR("Philip Pokorny <ppokorny@penguincomputing.com>, " | 1787 | MODULE_AUTHOR("Philip Pokorny <ppokorny@penguincomputing.com>, " |
1785 | "Justin Thiessen <jthiessen@penguincomputing.com>"); | 1788 | "Justin Thiessen <jthiessen@penguincomputing.com>"); |
1786 | MODULE_DESCRIPTION("ADM1026 driver"); | 1789 | MODULE_DESCRIPTION("ADM1026 driver"); |
1787 | 1790 | ||
1788 | module_init(sm_adm1026_init); | 1791 | module_init(sm_adm1026_init); |