diff options
author | Grant Coady <grant_lkml@dodo.com.au> | 2005-09-16 15:32:57 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-10-28 17:02:05 -0400 |
commit | c7461a6652f40ce4f8e19d7368c7a807a618fb68 (patch) | |
tree | b70812c3be404c00d6733c0cf95a8f0bcbab0ab7 /drivers/hwmon | |
parent | 205cf13e0b57500e2cc6442effa991c1a63f4db7 (diff) |
[PATCH] hwmon: adm9240 driver update - dynamic sysfs
hwmon: adm9240 update 2/2: convert to use dynamic sysfs accessors
This patch converts adm9240 to use Yani Ioannou's dynamic sysfs callbacks,
reducing driver memory footprint from 16312 to 14104 bytes on 2.6.14-rc1,
removing the old driver macro mess.
Run tested on Intel SE440BX-2 mobo.
Signed-off-by: Grant Coady <gcoady@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/adm9240.c | 342 |
1 files changed, 166 insertions, 176 deletions
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index ecef342e5fa3..8bb6d6e45ed5 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <linux/module.h> | 45 | #include <linux/module.h> |
46 | #include <linux/slab.h> | 46 | #include <linux/slab.h> |
47 | #include <linux/i2c.h> | 47 | #include <linux/i2c.h> |
48 | #include <linux/hwmon-sysfs.h> | ||
48 | #include <linux/hwmon.h> | 49 | #include <linux/hwmon.h> |
49 | #include <linux/hwmon-vid.h> | 50 | #include <linux/hwmon-vid.h> |
50 | #include <linux/err.h> | 51 | #include <linux/err.h> |
@@ -69,8 +70,7 @@ I2C_CLIENT_INSMOD_3(adm9240, ds1780, lm81); | |||
69 | #define ADM9240_REG_INT(nr) (0x41 + (nr)) | 70 | #define ADM9240_REG_INT(nr) (0x41 + (nr)) |
70 | #define ADM9240_REG_INT_MASK(nr) (0x43 + (nr)) | 71 | #define ADM9240_REG_INT_MASK(nr) (0x43 + (nr)) |
71 | #define ADM9240_REG_TEMP 0x27 | 72 | #define ADM9240_REG_TEMP 0x27 |
72 | #define ADM9240_REG_TEMP_HIGH 0x39 | 73 | #define ADM9240_REG_TEMP_MAX(nr) (0x39 + (nr)) /* 0, 1 = high, hyst */ |
73 | #define ADM9240_REG_TEMP_HYST 0x3a | ||
74 | #define ADM9240_REG_ANALOG_OUT 0x19 | 74 | #define ADM9240_REG_ANALOG_OUT 0x19 |
75 | #define ADM9240_REG_CHASSIS_CLEAR 0x46 | 75 | #define ADM9240_REG_CHASSIS_CLEAR 0x46 |
76 | #define ADM9240_REG_VID_FAN_DIV 0x47 | 76 | #define ADM9240_REG_VID_FAN_DIV 0x47 |
@@ -162,8 +162,7 @@ struct adm9240_data { | |||
162 | u8 fan_min[2]; /* rw fan1_min */ | 162 | u8 fan_min[2]; /* rw fan1_min */ |
163 | u8 fan_div[2]; /* rw fan1_div, read-only accessor */ | 163 | u8 fan_div[2]; /* rw fan1_div, read-only accessor */ |
164 | s16 temp; /* ro temp1_input, 9-bit sign-extended */ | 164 | s16 temp; /* ro temp1_input, 9-bit sign-extended */ |
165 | s8 temp_high; /* rw temp1_max */ | 165 | s8 temp_max[2]; /* rw 0 -> temp_max, 1 -> temp_max_hyst */ |
166 | s8 temp_hyst; /* rw temp1_max_hyst */ | ||
167 | u16 alarms; /* ro alarms */ | 166 | u16 alarms; /* ro alarms */ |
168 | u8 aout; /* rw aout_output */ | 167 | u8 aout; /* rw aout_output */ |
169 | u8 vid; /* ro vid */ | 168 | u8 vid; /* ro vid */ |
@@ -173,157 +172,143 @@ struct adm9240_data { | |||
173 | /*** sysfs accessors ***/ | 172 | /*** sysfs accessors ***/ |
174 | 173 | ||
175 | /* temperature */ | 174 | /* temperature */ |
176 | #define show_temp(value, scale) \ | 175 | static ssize_t show_temp(struct device *dev, struct device_attribute *dummy, |
177 | static ssize_t show_##value(struct device *dev, \ | 176 | char *buf) |
178 | struct device_attribute *attr, \ | 177 | { |
179 | char *buf) \ | 178 | struct adm9240_data *data = adm9240_update_device(dev); |
180 | { \ | 179 | return sprintf(buf, "%d\n", data->temp * 500); /* 9-bit value */ |
181 | struct adm9240_data *data = adm9240_update_device(dev); \ | 180 | } |
182 | return sprintf(buf, "%d\n", data->value * scale); \ | 181 | |
183 | } | 182 | static ssize_t show_max(struct device *dev, struct device_attribute *devattr, |
184 | show_temp(temp_high, 1000); | 183 | char *buf) |
185 | show_temp(temp_hyst, 1000); | 184 | { |
186 | show_temp(temp, 500); /* 0.5'C per bit */ | 185 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
187 | 186 | struct adm9240_data *data = adm9240_update_device(dev); | |
188 | #define set_temp(value, reg) \ | 187 | return sprintf(buf, "%d\n", data->temp_max[attr->index] * 1000); |
189 | static ssize_t set_##value(struct device *dev, \ | 188 | } |
190 | struct device_attribute *attr, \ | 189 | |
191 | const char *buf, size_t count) \ | 190 | static ssize_t set_max(struct device *dev, struct device_attribute *devattr, |
192 | { \ | 191 | const char *buf, size_t count) |
193 | struct i2c_client *client = to_i2c_client(dev); \ | 192 | { |
194 | struct adm9240_data *data = adm9240_update_device(dev); \ | 193 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
195 | long temp = simple_strtoul(buf, NULL, 10); \ | 194 | struct i2c_client *client = to_i2c_client(dev); |
196 | \ | 195 | struct adm9240_data *data = i2c_get_clientdata(client); |
197 | down(&data->update_lock); \ | 196 | long val = simple_strtol(buf, NULL, 10); |
198 | data->value = TEMP_TO_REG(temp); \ | 197 | |
199 | i2c_smbus_write_byte_data(client, reg, data->value); \ | 198 | down(&data->update_lock); |
200 | up(&data->update_lock); \ | 199 | data->temp_max[attr->index] = TEMP_TO_REG(val); |
201 | return count; \ | 200 | i2c_smbus_write_byte_data(client, ADM9240_REG_TEMP_MAX(attr->index), |
202 | } | 201 | data->temp_max[attr->index]); |
203 | 202 | up(&data->update_lock); | |
204 | set_temp(temp_high, ADM9240_REG_TEMP_HIGH); | 203 | return count; |
205 | set_temp(temp_hyst, ADM9240_REG_TEMP_HYST); | 204 | } |
206 | 205 | ||
207 | static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, | ||
208 | show_temp_high, set_temp_high); | ||
209 | static DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, | ||
210 | show_temp_hyst, set_temp_hyst); | ||
211 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL); | 206 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL); |
207 | static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, | ||
208 | show_max, set_max, 0); | ||
209 | static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, | ||
210 | show_max, set_max, 1); | ||
212 | 211 | ||
213 | /* voltage */ | 212 | /* voltage */ |
214 | static ssize_t show_in(struct device *dev, char *buf, int nr) | 213 | static ssize_t show_in(struct device *dev, struct device_attribute *devattr, |
214 | char *buf) | ||
215 | { | 215 | { |
216 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
216 | struct adm9240_data *data = adm9240_update_device(dev); | 217 | struct adm9240_data *data = adm9240_update_device(dev); |
217 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr], nr)); | 218 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in[attr->index], |
219 | attr->index)); | ||
218 | } | 220 | } |
219 | 221 | ||
220 | static ssize_t show_in_min(struct device *dev, char *buf, int nr) | 222 | static ssize_t show_in_min(struct device *dev, struct device_attribute *devattr, |
223 | char *buf) | ||
221 | { | 224 | { |
225 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
222 | struct adm9240_data *data = adm9240_update_device(dev); | 226 | struct adm9240_data *data = adm9240_update_device(dev); |
223 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr], nr)); | 227 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[attr->index], |
228 | attr->index)); | ||
224 | } | 229 | } |
225 | 230 | ||
226 | static ssize_t show_in_max(struct device *dev, char *buf, int nr) | 231 | static ssize_t show_in_max(struct device *dev, struct device_attribute *devattr, |
232 | char *buf) | ||
227 | { | 233 | { |
234 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
228 | struct adm9240_data *data = adm9240_update_device(dev); | 235 | struct adm9240_data *data = adm9240_update_device(dev); |
229 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr], nr)); | 236 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[attr->index], |
237 | attr->index)); | ||
230 | } | 238 | } |
231 | 239 | ||
232 | static ssize_t set_in_min(struct device *dev, const char *buf, | 240 | static ssize_t set_in_min(struct device *dev, struct device_attribute *devattr, |
233 | size_t count, int nr) | 241 | const char *buf, size_t count) |
234 | { | 242 | { |
243 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
235 | struct i2c_client *client = to_i2c_client(dev); | 244 | struct i2c_client *client = to_i2c_client(dev); |
236 | struct adm9240_data *data = i2c_get_clientdata(client); | 245 | struct adm9240_data *data = i2c_get_clientdata(client); |
237 | unsigned long val = simple_strtoul(buf, NULL, 10); | 246 | unsigned long val = simple_strtoul(buf, NULL, 10); |
238 | 247 | ||
239 | down(&data->update_lock); | 248 | down(&data->update_lock); |
240 | data->in_min[nr] = IN_TO_REG(val, nr); | 249 | data->in_min[attr->index] = IN_TO_REG(val, attr->index); |
241 | i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MIN(nr), | 250 | i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MIN(attr->index), |
242 | data->in_min[nr]); | 251 | data->in_min[attr->index]); |
243 | up(&data->update_lock); | 252 | up(&data->update_lock); |
244 | return count; | 253 | return count; |
245 | } | 254 | } |
246 | 255 | ||
247 | static ssize_t set_in_max(struct device *dev, const char *buf, | 256 | static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr, |
248 | size_t count, int nr) | 257 | const char *buf, size_t count) |
249 | { | 258 | { |
259 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
250 | struct i2c_client *client = to_i2c_client(dev); | 260 | struct i2c_client *client = to_i2c_client(dev); |
251 | struct adm9240_data *data = i2c_get_clientdata(client); | 261 | struct adm9240_data *data = i2c_get_clientdata(client); |
252 | unsigned long val = simple_strtoul(buf, NULL, 10); | 262 | unsigned long val = simple_strtoul(buf, NULL, 10); |
253 | 263 | ||
254 | down(&data->update_lock); | 264 | down(&data->update_lock); |
255 | data->in_max[nr] = IN_TO_REG(val, nr); | 265 | data->in_max[attr->index] = IN_TO_REG(val, attr->index); |
256 | i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MAX(nr), | 266 | i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MAX(attr->index), |
257 | data->in_max[nr]); | 267 | data->in_max[attr->index]); |
258 | up(&data->update_lock); | 268 | up(&data->update_lock); |
259 | return count; | 269 | return count; |
260 | } | 270 | } |
261 | 271 | ||
262 | #define show_in_offset(offset) \ | 272 | #define vin(nr) \ |
263 | static ssize_t show_in##offset(struct device *dev, \ | 273 | static SENSOR_DEVICE_ATTR(in##nr##_input, S_IRUGO, \ |
264 | struct device_attribute *attr, \ | 274 | show_in, NULL, nr); \ |
265 | char *buf) \ | 275 | static SENSOR_DEVICE_ATTR(in##nr##_min, S_IRUGO | S_IWUSR, \ |
266 | { \ | 276 | show_in_min, set_in_min, nr); \ |
267 | return show_in(dev, buf, offset); \ | 277 | static SENSOR_DEVICE_ATTR(in##nr##_max, S_IRUGO | S_IWUSR, \ |
268 | } \ | 278 | show_in_max, set_in_max, nr); |
269 | static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL); \ | 279 | |
270 | static ssize_t show_in##offset##_min(struct device *dev, \ | 280 | vin(0); |
271 | struct device_attribute *attr, \ | 281 | vin(1); |
272 | char *buf) \ | 282 | vin(2); |
273 | { \ | 283 | vin(3); |
274 | return show_in_min(dev, buf, offset); \ | 284 | vin(4); |
275 | } \ | 285 | vin(5); |
276 | static ssize_t show_in##offset##_max(struct device *dev, \ | ||
277 | struct device_attribute *attr, \ | ||
278 | char *buf) \ | ||
279 | { \ | ||
280 | return show_in_max(dev, buf, offset); \ | ||
281 | } \ | ||
282 | static ssize_t \ | ||
283 | set_in##offset##_min(struct device *dev, \ | ||
284 | struct device_attribute *attr, const char *buf, \ | ||
285 | size_t count) \ | ||
286 | { \ | ||
287 | return set_in_min(dev, buf, count, offset); \ | ||
288 | } \ | ||
289 | static ssize_t \ | ||
290 | set_in##offset##_max(struct device *dev, \ | ||
291 | struct device_attribute *attr, const char *buf, \ | ||
292 | size_t count) \ | ||
293 | { \ | ||
294 | return set_in_max(dev, buf, count, offset); \ | ||
295 | } \ | ||
296 | static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ | ||
297 | show_in##offset##_min, set_in##offset##_min); \ | ||
298 | static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ | ||
299 | show_in##offset##_max, set_in##offset##_max); | ||
300 | |||
301 | show_in_offset(0); | ||
302 | show_in_offset(1); | ||
303 | show_in_offset(2); | ||
304 | show_in_offset(3); | ||
305 | show_in_offset(4); | ||
306 | show_in_offset(5); | ||
307 | 286 | ||
308 | /* fans */ | 287 | /* fans */ |
309 | static ssize_t show_fan(struct device *dev, char *buf, int nr) | 288 | static ssize_t show_fan(struct device *dev, |
289 | struct device_attribute *devattr, char *buf) | ||
310 | { | 290 | { |
291 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
311 | struct adm9240_data *data = adm9240_update_device(dev); | 292 | struct adm9240_data *data = adm9240_update_device(dev); |
312 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], | 293 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[attr->index], |
313 | 1 << data->fan_div[nr])); | 294 | 1 << data->fan_div[attr->index])); |
314 | } | 295 | } |
315 | 296 | ||
316 | static ssize_t show_fan_min(struct device *dev, char *buf, int nr) | 297 | static ssize_t show_fan_min(struct device *dev, |
298 | struct device_attribute *devattr, char *buf) | ||
317 | { | 299 | { |
300 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
318 | struct adm9240_data *data = adm9240_update_device(dev); | 301 | struct adm9240_data *data = adm9240_update_device(dev); |
319 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr], | 302 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[attr->index], |
320 | 1 << data->fan_div[nr])); | 303 | 1 << data->fan_div[attr->index])); |
321 | } | 304 | } |
322 | 305 | ||
323 | static ssize_t show_fan_div(struct device *dev, char *buf, int nr) | 306 | static ssize_t show_fan_div(struct device *dev, |
307 | struct device_attribute *devattr, char *buf) | ||
324 | { | 308 | { |
309 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
325 | struct adm9240_data *data = adm9240_update_device(dev); | 310 | struct adm9240_data *data = adm9240_update_device(dev); |
326 | return sprintf(buf, "%d\n", 1 << data->fan_div[nr]); | 311 | return sprintf(buf, "%d\n", 1 << data->fan_div[attr->index]); |
327 | } | 312 | } |
328 | 313 | ||
329 | /* write new fan div, callers must hold data->update_lock */ | 314 | /* write new fan div, callers must hold data->update_lock */ |
@@ -352,12 +337,15 @@ static void adm9240_write_fan_div(struct i2c_client *client, int nr, | |||
352 | * - otherwise: select fan clock divider to suit fan speed low limit, | 337 | * - otherwise: select fan clock divider to suit fan speed low limit, |
353 | * measurement code may adjust registers to ensure fan speed reading | 338 | * measurement code may adjust registers to ensure fan speed reading |
354 | */ | 339 | */ |
355 | static ssize_t set_fan_min(struct device *dev, const char *buf, | 340 | static ssize_t set_fan_min(struct device *dev, |
356 | size_t count, int nr) | 341 | struct device_attribute *devattr, |
342 | const char *buf, size_t count) | ||
357 | { | 343 | { |
344 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
358 | struct i2c_client *client = to_i2c_client(dev); | 345 | struct i2c_client *client = to_i2c_client(dev); |
359 | struct adm9240_data *data = i2c_get_clientdata(client); | 346 | struct adm9240_data *data = i2c_get_clientdata(client); |
360 | unsigned long val = simple_strtoul(buf, NULL, 10); | 347 | unsigned long val = simple_strtoul(buf, NULL, 10); |
348 | int nr = attr->index; | ||
361 | u8 new_div; | 349 | u8 new_div; |
362 | 350 | ||
363 | down(&data->update_lock); | 351 | down(&data->update_lock); |
@@ -404,40 +392,16 @@ static ssize_t set_fan_min(struct device *dev, const char *buf, | |||
404 | return count; | 392 | return count; |
405 | } | 393 | } |
406 | 394 | ||
407 | #define show_fan_offset(offset) \ | 395 | #define fan(nr) \ |
408 | static ssize_t show_fan_##offset (struct device *dev, \ | 396 | static SENSOR_DEVICE_ATTR(fan##nr##_input, S_IRUGO, \ |
409 | struct device_attribute *attr, \ | 397 | show_fan, NULL, nr - 1); \ |
410 | char *buf) \ | 398 | static SENSOR_DEVICE_ATTR(fan##nr##_div, S_IRUGO, \ |
411 | { \ | 399 | show_fan_div, NULL, nr - 1); \ |
412 | return show_fan(dev, buf, offset - 1); \ | 400 | static SENSOR_DEVICE_ATTR(fan##nr##_min, S_IRUGO | S_IWUSR, \ |
413 | } \ | 401 | show_fan_min, set_fan_min, nr - 1); |
414 | static ssize_t show_fan_##offset##_div (struct device *dev, \ | 402 | |
415 | struct device_attribute *attr, \ | 403 | fan(1); |
416 | char *buf) \ | 404 | fan(2); |
417 | { \ | ||
418 | return show_fan_div(dev, buf, offset - 1); \ | ||
419 | } \ | ||
420 | static ssize_t show_fan_##offset##_min (struct device *dev, \ | ||
421 | struct device_attribute *attr, \ | ||
422 | char *buf) \ | ||
423 | { \ | ||
424 | return show_fan_min(dev, buf, offset - 1); \ | ||
425 | } \ | ||
426 | static ssize_t set_fan_##offset##_min (struct device *dev, \ | ||
427 | struct device_attribute *attr, \ | ||
428 | const char *buf, size_t count) \ | ||
429 | { \ | ||
430 | return set_fan_min(dev, buf, count, offset - 1); \ | ||
431 | } \ | ||
432 | static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ | ||
433 | show_fan_##offset, NULL); \ | ||
434 | static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ | ||
435 | show_fan_##offset##_div, NULL); \ | ||
436 | static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | ||
437 | show_fan_##offset##_min, set_fan_##offset##_min); | ||
438 | |||
439 | show_fan_offset(1); | ||
440 | show_fan_offset(2); | ||
441 | 405 | ||
442 | /* alarms */ | 406 | /* alarms */ |
443 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) | 407 | static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) |
@@ -580,33 +544,59 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) | |||
580 | goto exit_detach; | 544 | goto exit_detach; |
581 | } | 545 | } |
582 | 546 | ||
583 | device_create_file(&new_client->dev, &dev_attr_in0_input); | 547 | device_create_file(&new_client->dev, |
584 | device_create_file(&new_client->dev, &dev_attr_in0_min); | 548 | &sensor_dev_attr_in0_input.dev_attr); |
585 | device_create_file(&new_client->dev, &dev_attr_in0_max); | 549 | device_create_file(&new_client->dev, |
586 | device_create_file(&new_client->dev, &dev_attr_in1_input); | 550 | &sensor_dev_attr_in0_min.dev_attr); |
587 | device_create_file(&new_client->dev, &dev_attr_in1_min); | 551 | device_create_file(&new_client->dev, |
588 | device_create_file(&new_client->dev, &dev_attr_in1_max); | 552 | &sensor_dev_attr_in0_max.dev_attr); |
589 | device_create_file(&new_client->dev, &dev_attr_in2_input); | 553 | device_create_file(&new_client->dev, |
590 | device_create_file(&new_client->dev, &dev_attr_in2_min); | 554 | &sensor_dev_attr_in1_input.dev_attr); |
591 | device_create_file(&new_client->dev, &dev_attr_in2_max); | 555 | device_create_file(&new_client->dev, |
592 | device_create_file(&new_client->dev, &dev_attr_in3_input); | 556 | &sensor_dev_attr_in1_min.dev_attr); |
593 | device_create_file(&new_client->dev, &dev_attr_in3_min); | 557 | device_create_file(&new_client->dev, |
594 | device_create_file(&new_client->dev, &dev_attr_in3_max); | 558 | &sensor_dev_attr_in1_max.dev_attr); |
595 | device_create_file(&new_client->dev, &dev_attr_in4_input); | 559 | device_create_file(&new_client->dev, |
596 | device_create_file(&new_client->dev, &dev_attr_in4_min); | 560 | &sensor_dev_attr_in2_input.dev_attr); |
597 | device_create_file(&new_client->dev, &dev_attr_in4_max); | 561 | device_create_file(&new_client->dev, |
598 | device_create_file(&new_client->dev, &dev_attr_in5_input); | 562 | &sensor_dev_attr_in2_min.dev_attr); |
599 | device_create_file(&new_client->dev, &dev_attr_in5_min); | 563 | device_create_file(&new_client->dev, |
600 | device_create_file(&new_client->dev, &dev_attr_in5_max); | 564 | &sensor_dev_attr_in2_max.dev_attr); |
601 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | 565 | device_create_file(&new_client->dev, |
602 | device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); | 566 | &sensor_dev_attr_in3_input.dev_attr); |
567 | device_create_file(&new_client->dev, | ||
568 | &sensor_dev_attr_in3_min.dev_attr); | ||
569 | device_create_file(&new_client->dev, | ||
570 | &sensor_dev_attr_in3_max.dev_attr); | ||
571 | device_create_file(&new_client->dev, | ||
572 | &sensor_dev_attr_in4_input.dev_attr); | ||
573 | device_create_file(&new_client->dev, | ||
574 | &sensor_dev_attr_in4_min.dev_attr); | ||
575 | device_create_file(&new_client->dev, | ||
576 | &sensor_dev_attr_in4_max.dev_attr); | ||
577 | device_create_file(&new_client->dev, | ||
578 | &sensor_dev_attr_in5_input.dev_attr); | ||
579 | device_create_file(&new_client->dev, | ||
580 | &sensor_dev_attr_in5_min.dev_attr); | ||
581 | device_create_file(&new_client->dev, | ||
582 | &sensor_dev_attr_in5_max.dev_attr); | ||
603 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | 583 | device_create_file(&new_client->dev, &dev_attr_temp1_input); |
604 | device_create_file(&new_client->dev, &dev_attr_fan1_input); | 584 | device_create_file(&new_client->dev, |
605 | device_create_file(&new_client->dev, &dev_attr_fan1_div); | 585 | &sensor_dev_attr_temp1_max.dev_attr); |
606 | device_create_file(&new_client->dev, &dev_attr_fan1_min); | 586 | device_create_file(&new_client->dev, |
607 | device_create_file(&new_client->dev, &dev_attr_fan2_input); | 587 | &sensor_dev_attr_temp1_max_hyst.dev_attr); |
608 | device_create_file(&new_client->dev, &dev_attr_fan2_div); | 588 | device_create_file(&new_client->dev, |
609 | device_create_file(&new_client->dev, &dev_attr_fan2_min); | 589 | &sensor_dev_attr_fan1_input.dev_attr); |
590 | device_create_file(&new_client->dev, | ||
591 | &sensor_dev_attr_fan1_div.dev_attr); | ||
592 | device_create_file(&new_client->dev, | ||
593 | &sensor_dev_attr_fan1_min.dev_attr); | ||
594 | device_create_file(&new_client->dev, | ||
595 | &sensor_dev_attr_fan2_input.dev_attr); | ||
596 | device_create_file(&new_client->dev, | ||
597 | &sensor_dev_attr_fan2_div.dev_attr); | ||
598 | device_create_file(&new_client->dev, | ||
599 | &sensor_dev_attr_fan2_min.dev_attr); | ||
610 | device_create_file(&new_client->dev, &dev_attr_alarms); | 600 | device_create_file(&new_client->dev, &dev_attr_alarms); |
611 | device_create_file(&new_client->dev, &dev_attr_aout_output); | 601 | device_create_file(&new_client->dev, &dev_attr_aout_output); |
612 | device_create_file(&new_client->dev, &dev_attr_chassis_clear); | 602 | device_create_file(&new_client->dev, &dev_attr_chassis_clear); |
@@ -674,9 +664,9 @@ static void adm9240_init_client(struct i2c_client *client) | |||
674 | i2c_smbus_write_byte_data(client, | 664 | i2c_smbus_write_byte_data(client, |
675 | ADM9240_REG_FAN_MIN(1), 255); | 665 | ADM9240_REG_FAN_MIN(1), 255); |
676 | i2c_smbus_write_byte_data(client, | 666 | i2c_smbus_write_byte_data(client, |
677 | ADM9240_REG_TEMP_HIGH, 127); | 667 | ADM9240_REG_TEMP_MAX(0), 127); |
678 | i2c_smbus_write_byte_data(client, | 668 | i2c_smbus_write_byte_data(client, |
679 | ADM9240_REG_TEMP_HYST, 127); | 669 | ADM9240_REG_TEMP_MAX(1), 127); |
680 | 670 | ||
681 | /* start measurement cycle */ | 671 | /* start measurement cycle */ |
682 | i2c_smbus_write_byte_data(client, ADM9240_REG_CONFIG, 1); | 672 | i2c_smbus_write_byte_data(client, ADM9240_REG_CONFIG, 1); |
@@ -753,10 +743,10 @@ static struct adm9240_data *adm9240_update_device(struct device *dev) | |||
753 | data->fan_min[i] = i2c_smbus_read_byte_data(client, | 743 | data->fan_min[i] = i2c_smbus_read_byte_data(client, |
754 | ADM9240_REG_FAN_MIN(i)); | 744 | ADM9240_REG_FAN_MIN(i)); |
755 | } | 745 | } |
756 | data->temp_high = i2c_smbus_read_byte_data(client, | 746 | data->temp_max[0] = i2c_smbus_read_byte_data(client, |
757 | ADM9240_REG_TEMP_HIGH); | 747 | ADM9240_REG_TEMP_MAX(0)); |
758 | data->temp_hyst = i2c_smbus_read_byte_data(client, | 748 | data->temp_max[1] = i2c_smbus_read_byte_data(client, |
759 | ADM9240_REG_TEMP_HYST); | 749 | ADM9240_REG_TEMP_MAX(1)); |
760 | 750 | ||
761 | /* read fan divs and 5-bit VID */ | 751 | /* read fan divs and 5-bit VID */ |
762 | i = i2c_smbus_read_byte_data(client, ADM9240_REG_VID_FAN_DIV); | 752 | i = i2c_smbus_read_byte_data(client, ADM9240_REG_VID_FAN_DIV); |