aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2005-06-05 05:53:25 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-06-22 00:52:04 -0400
commit20ad93d4e5cf5f0616198b5919ee9f304119dd4b (patch)
treea2260af225b373435ceb4e9475dfbbe67f019832 /drivers
parentbc51ae1159c0c9a34d2400a8449e1fca3ee965b4 (diff)
[PATCH] I2C: drivers/i2c/chips/it87.c: use dynamic sysfs callbacks
This patch modifies the it87 hardware monitoring driver to take benefit of the new sysfs callback features introduced by Yani Ioannou, making the code much clearer and the resulting driver significantly smaller. From: Yani Ioannou <yani.ioannou@gmail.com> Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/i2c/chips/it87.c387
1 files changed, 183 insertions, 204 deletions
diff --git a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c
index 7984bf920d31..6a9b65a10bbc 100644
--- a/drivers/i2c/chips/it87.c
+++ b/drivers/i2c/chips/it87.c
@@ -37,6 +37,7 @@
37#include <linux/jiffies.h> 37#include <linux/jiffies.h>
38#include <linux/i2c.h> 38#include <linux/i2c.h>
39#include <linux/i2c-sensor.h> 39#include <linux/i2c-sensor.h>
40#include <linux/i2c-sysfs.h>
40#include <linux/i2c-vid.h> 41#include <linux/i2c-vid.h>
41#include <asm/io.h> 42#include <asm/io.h>
42 43
@@ -238,27 +239,42 @@ static struct i2c_driver it87_driver = {
238 .detach_client = it87_detach_client, 239 .detach_client = it87_detach_client,
239}; 240};
240 241
241static ssize_t show_in(struct device *dev, char *buf, int nr) 242static ssize_t show_in(struct device *dev, struct device_attribute *attr,
243 char *buf)
242{ 244{
245 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
246 int nr = sensor_attr->index;
247
243 struct it87_data *data = it87_update_device(dev); 248 struct it87_data *data = it87_update_device(dev);
244 return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr])); 249 return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr]));
245} 250}
246 251
247static ssize_t show_in_min(struct device *dev, char *buf, int nr) 252static ssize_t show_in_min(struct device *dev, struct device_attribute *attr,
253 char *buf)
248{ 254{
255 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
256 int nr = sensor_attr->index;
257
249 struct it87_data *data = it87_update_device(dev); 258 struct it87_data *data = it87_update_device(dev);
250 return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr])); 259 return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr]));
251} 260}
252 261
253static ssize_t show_in_max(struct device *dev, char *buf, int nr) 262static ssize_t show_in_max(struct device *dev, struct device_attribute *attr,
263 char *buf)
254{ 264{
265 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
266 int nr = sensor_attr->index;
267
255 struct it87_data *data = it87_update_device(dev); 268 struct it87_data *data = it87_update_device(dev);
256 return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr])); 269 return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr]));
257} 270}
258 271
259static ssize_t set_in_min(struct device *dev, const char *buf, 272static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
260 size_t count, int nr) 273 const char *buf, size_t count)
261{ 274{
275 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
276 int nr = sensor_attr->index;
277
262 struct i2c_client *client = to_i2c_client(dev); 278 struct i2c_client *client = to_i2c_client(dev);
263 struct it87_data *data = i2c_get_clientdata(client); 279 struct it87_data *data = i2c_get_clientdata(client);
264 unsigned long val = simple_strtoul(buf, NULL, 10); 280 unsigned long val = simple_strtoul(buf, NULL, 10);
@@ -270,9 +286,12 @@ static ssize_t set_in_min(struct device *dev, const char *buf,
270 up(&data->update_lock); 286 up(&data->update_lock);
271 return count; 287 return count;
272} 288}
273static ssize_t set_in_max(struct device *dev, const char *buf, 289static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
274 size_t count, int nr) 290 const char *buf, size_t count)
275{ 291{
292 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
293 int nr = sensor_attr->index;
294
276 struct i2c_client *client = to_i2c_client(dev); 295 struct i2c_client *client = to_i2c_client(dev);
277 struct it87_data *data = i2c_get_clientdata(client); 296 struct it87_data *data = i2c_get_clientdata(client);
278 unsigned long val = simple_strtoul(buf, NULL, 10); 297 unsigned long val = simple_strtoul(buf, NULL, 10);
@@ -286,38 +305,14 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
286} 305}
287 306
288#define show_in_offset(offset) \ 307#define show_in_offset(offset) \
289static ssize_t \ 308static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \
290 show_in##offset (struct device *dev, struct device_attribute *attr, char *buf) \ 309 show_in, NULL, offset);
291{ \
292 return show_in(dev, buf, offset); \
293} \
294static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL);
295 310
296#define limit_in_offset(offset) \ 311#define limit_in_offset(offset) \
297static ssize_t \ 312static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
298 show_in##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ 313 show_in_min, set_in_min, offset); \
299{ \ 314static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
300 return show_in_min(dev, buf, offset); \ 315 show_in_max, set_in_max, offset);
301} \
302static ssize_t \
303 show_in##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \
304{ \
305 return show_in_max(dev, buf, offset); \
306} \
307static ssize_t set_in##offset##_min (struct device *dev, struct device_attribute *attr, \
308 const char *buf, size_t count) \
309{ \
310 return set_in_min(dev, buf, count, offset); \
311} \
312static ssize_t set_in##offset##_max (struct device *dev, struct device_attribute *attr, \
313 const char *buf, size_t count) \
314{ \
315 return set_in_max(dev, buf, count, offset); \
316} \
317static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
318 show_in##offset##_min, set_in##offset##_min); \
319static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
320 show_in##offset##_max, set_in##offset##_max);
321 316
322show_in_offset(0); 317show_in_offset(0);
323limit_in_offset(0); 318limit_in_offset(0);
@@ -338,24 +333,39 @@ limit_in_offset(7);
338show_in_offset(8); 333show_in_offset(8);
339 334
340/* 3 temperatures */ 335/* 3 temperatures */
341static ssize_t show_temp(struct device *dev, char *buf, int nr) 336static ssize_t show_temp(struct device *dev, struct device_attribute *attr,
337 char *buf)
342{ 338{
339 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
340 int nr = sensor_attr->index;
341
343 struct it87_data *data = it87_update_device(dev); 342 struct it87_data *data = it87_update_device(dev);
344 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr])); 343 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr]));
345} 344}
346static ssize_t show_temp_max(struct device *dev, char *buf, int nr) 345static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr,
346 char *buf)
347{ 347{
348 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
349 int nr = sensor_attr->index;
350
348 struct it87_data *data = it87_update_device(dev); 351 struct it87_data *data = it87_update_device(dev);
349 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_high[nr])); 352 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_high[nr]));
350} 353}
351static ssize_t show_temp_min(struct device *dev, char *buf, int nr) 354static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr,
355 char *buf)
352{ 356{
357 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
358 int nr = sensor_attr->index;
359
353 struct it87_data *data = it87_update_device(dev); 360 struct it87_data *data = it87_update_device(dev);
354 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_low[nr])); 361 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_low[nr]));
355} 362}
356static ssize_t set_temp_max(struct device *dev, const char *buf, 363static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
357 size_t count, int nr) 364 const char *buf, size_t count)
358{ 365{
366 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
367 int nr = sensor_attr->index;
368
359 struct i2c_client *client = to_i2c_client(dev); 369 struct i2c_client *client = to_i2c_client(dev);
360 struct it87_data *data = i2c_get_clientdata(client); 370 struct it87_data *data = i2c_get_clientdata(client);
361 int val = simple_strtol(buf, NULL, 10); 371 int val = simple_strtol(buf, NULL, 10);
@@ -366,9 +376,12 @@ static ssize_t set_temp_max(struct device *dev, const char *buf,
366 up(&data->update_lock); 376 up(&data->update_lock);
367 return count; 377 return count;
368} 378}
369static ssize_t set_temp_min(struct device *dev, const char *buf, 379static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
370 size_t count, int nr) 380 const char *buf, size_t count)
371{ 381{
382 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
383 int nr = sensor_attr->index;
384
372 struct i2c_client *client = to_i2c_client(dev); 385 struct i2c_client *client = to_i2c_client(dev);
373 struct it87_data *data = i2c_get_clientdata(client); 386 struct it87_data *data = i2c_get_clientdata(client);
374 int val = simple_strtol(buf, NULL, 10); 387 int val = simple_strtol(buf, NULL, 10);
@@ -380,42 +393,23 @@ static ssize_t set_temp_min(struct device *dev, const char *buf,
380 return count; 393 return count;
381} 394}
382#define show_temp_offset(offset) \ 395#define show_temp_offset(offset) \
383static ssize_t show_temp_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ 396static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
384{ \ 397 show_temp, NULL, offset - 1); \
385 return show_temp(dev, buf, offset - 1); \ 398static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
386} \ 399 show_temp_max, set_temp_max, offset - 1); \
387static ssize_t \ 400static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \
388show_temp_##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \ 401 show_temp_min, set_temp_min, offset - 1);
389{ \
390 return show_temp_max(dev, buf, offset - 1); \
391} \
392static ssize_t \
393show_temp_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
394{ \
395 return show_temp_min(dev, buf, offset - 1); \
396} \
397static ssize_t set_temp_##offset##_max (struct device *dev, struct device_attribute *attr, \
398 const char *buf, size_t count) \
399{ \
400 return set_temp_max(dev, buf, count, offset - 1); \
401} \
402static ssize_t set_temp_##offset##_min (struct device *dev, struct device_attribute *attr, \
403 const char *buf, size_t count) \
404{ \
405 return set_temp_min(dev, buf, count, offset - 1); \
406} \
407static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL); \
408static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
409 show_temp_##offset##_max, set_temp_##offset##_max); \
410static DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \
411 show_temp_##offset##_min, set_temp_##offset##_min);
412 402
413show_temp_offset(1); 403show_temp_offset(1);
414show_temp_offset(2); 404show_temp_offset(2);
415show_temp_offset(3); 405show_temp_offset(3);
416 406
417static ssize_t show_sensor(struct device *dev, char *buf, int nr) 407static ssize_t show_sensor(struct device *dev, struct device_attribute *attr,
408 char *buf)
418{ 409{
410 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
411 int nr = sensor_attr->index;
412
419 struct it87_data *data = it87_update_device(dev); 413 struct it87_data *data = it87_update_device(dev);
420 u8 reg = data->sensor; /* In case the value is updated while we use it */ 414 u8 reg = data->sensor; /* In case the value is updated while we use it */
421 415
@@ -425,9 +419,12 @@ static ssize_t show_sensor(struct device *dev, char *buf, int nr)
425 return sprintf(buf, "2\n"); /* thermistor */ 419 return sprintf(buf, "2\n"); /* thermistor */
426 return sprintf(buf, "0\n"); /* disabled */ 420 return sprintf(buf, "0\n"); /* disabled */
427} 421}
428static ssize_t set_sensor(struct device *dev, const char *buf, 422static ssize_t set_sensor(struct device *dev, struct device_attribute *attr,
429 size_t count, int nr) 423 const char *buf, size_t count)
430{ 424{
425 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
426 int nr = sensor_attr->index;
427
431 struct i2c_client *client = to_i2c_client(dev); 428 struct i2c_client *client = to_i2c_client(dev);
432 struct it87_data *data = i2c_get_clientdata(client); 429 struct it87_data *data = i2c_get_clientdata(client);
433 int val = simple_strtol(buf, NULL, 10); 430 int val = simple_strtol(buf, NULL, 10);
@@ -450,53 +447,67 @@ static ssize_t set_sensor(struct device *dev, const char *buf,
450 return count; 447 return count;
451} 448}
452#define show_sensor_offset(offset) \ 449#define show_sensor_offset(offset) \
453static ssize_t show_sensor_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ 450static SENSOR_DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, \
454{ \ 451 show_sensor, set_sensor, offset - 1);
455 return show_sensor(dev, buf, offset - 1); \
456} \
457static ssize_t set_sensor_##offset (struct device *dev, struct device_attribute *attr, \
458 const char *buf, size_t count) \
459{ \
460 return set_sensor(dev, buf, count, offset - 1); \
461} \
462static DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, \
463 show_sensor_##offset, set_sensor_##offset);
464 452
465show_sensor_offset(1); 453show_sensor_offset(1);
466show_sensor_offset(2); 454show_sensor_offset(2);
467show_sensor_offset(3); 455show_sensor_offset(3);
468 456
469/* 3 Fans */ 457/* 3 Fans */
470static ssize_t show_fan(struct device *dev, char *buf, int nr) 458static ssize_t show_fan(struct device *dev, struct device_attribute *attr,
459 char *buf)
471{ 460{
461 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
462 int nr = sensor_attr->index;
463
472 struct it87_data *data = it87_update_device(dev); 464 struct it87_data *data = it87_update_device(dev);
473 return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr], 465 return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr],
474 DIV_FROM_REG(data->fan_div[nr]))); 466 DIV_FROM_REG(data->fan_div[nr])));
475} 467}
476static ssize_t show_fan_min(struct device *dev, char *buf, int nr) 468static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr,
469 char *buf)
477{ 470{
471 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
472 int nr = sensor_attr->index;
473
478 struct it87_data *data = it87_update_device(dev); 474 struct it87_data *data = it87_update_device(dev);
479 return sprintf(buf,"%d\n", 475 return sprintf(buf,"%d\n",
480 FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr]))); 476 FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr])));
481} 477}
482static ssize_t show_fan_div(struct device *dev, char *buf, int nr) 478static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr,
479 char *buf)
483{ 480{
481 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
482 int nr = sensor_attr->index;
483
484 struct it87_data *data = it87_update_device(dev); 484 struct it87_data *data = it87_update_device(dev);
485 return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr])); 485 return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr]));
486} 486}
487static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr) 487static ssize_t show_pwm_enable(struct device *dev, struct device_attribute *attr,
488 char *buf)
488{ 489{
490 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
491 int nr = sensor_attr->index;
492
489 struct it87_data *data = it87_update_device(dev); 493 struct it87_data *data = it87_update_device(dev);
490 return sprintf(buf,"%d\n", (data->fan_main_ctrl & (1 << nr)) ? 1 : 0); 494 return sprintf(buf,"%d\n", (data->fan_main_ctrl & (1 << nr)) ? 1 : 0);
491} 495}
492static ssize_t show_pwm(struct device *dev, char *buf, int nr) 496static ssize_t show_pwm(struct device *dev, struct device_attribute *attr,
497 char *buf)
493{ 498{
499 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
500 int nr = sensor_attr->index;
501
494 struct it87_data *data = it87_update_device(dev); 502 struct it87_data *data = it87_update_device(dev);
495 return sprintf(buf,"%d\n", data->manual_pwm_ctl[nr]); 503 return sprintf(buf,"%d\n", data->manual_pwm_ctl[nr]);
496} 504}
497static ssize_t set_fan_min(struct device *dev, const char *buf, 505static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
498 size_t count, int nr) 506 const char *buf, size_t count)
499{ 507{
508 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
509 int nr = sensor_attr->index;
510
500 struct i2c_client *client = to_i2c_client(dev); 511 struct i2c_client *client = to_i2c_client(dev);
501 struct it87_data *data = i2c_get_clientdata(client); 512 struct it87_data *data = i2c_get_clientdata(client);
502 int val = simple_strtol(buf, NULL, 10); 513 int val = simple_strtol(buf, NULL, 10);
@@ -507,9 +518,12 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
507 up(&data->update_lock); 518 up(&data->update_lock);
508 return count; 519 return count;
509} 520}
510static ssize_t set_fan_div(struct device *dev, const char *buf, 521static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
511 size_t count, int nr) 522 const char *buf, size_t count)
512{ 523{
524 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
525 int nr = sensor_attr->index;
526
513 struct i2c_client *client = to_i2c_client(dev); 527 struct i2c_client *client = to_i2c_client(dev);
514 struct it87_data *data = i2c_get_clientdata(client); 528 struct it87_data *data = i2c_get_clientdata(client);
515 int val = simple_strtol(buf, NULL, 10); 529 int val = simple_strtol(buf, NULL, 10);
@@ -547,9 +561,12 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
547 up(&data->update_lock); 561 up(&data->update_lock);
548 return count; 562 return count;
549} 563}
550static ssize_t set_pwm_enable(struct device *dev, const char *buf, 564static ssize_t set_pwm_enable(struct device *dev,
551 size_t count, int nr) 565 struct device_attribute *attr, const char *buf, size_t count)
552{ 566{
567 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
568 int nr = sensor_attr->index;
569
553 struct i2c_client *client = to_i2c_client(dev); 570 struct i2c_client *client = to_i2c_client(dev);
554 struct it87_data *data = i2c_get_clientdata(client); 571 struct it87_data *data = i2c_get_clientdata(client);
555 int val = simple_strtol(buf, NULL, 10); 572 int val = simple_strtol(buf, NULL, 10);
@@ -578,9 +595,12 @@ static ssize_t set_pwm_enable(struct device *dev, const char *buf,
578 up(&data->update_lock); 595 up(&data->update_lock);
579 return count; 596 return count;
580} 597}
581static ssize_t set_pwm(struct device *dev, const char *buf, 598static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
582 size_t count, int nr) 599 const char *buf, size_t count)
583{ 600{
601 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
602 int nr = sensor_attr->index;
603
584 struct i2c_client *client = to_i2c_client(dev); 604 struct i2c_client *client = to_i2c_client(dev);
585 struct it87_data *data = i2c_get_clientdata(client); 605 struct it87_data *data = i2c_get_clientdata(client);
586 int val = simple_strtol(buf, NULL, 10); 606 int val = simple_strtol(buf, NULL, 10);
@@ -596,64 +616,23 @@ static ssize_t set_pwm(struct device *dev, const char *buf,
596 return count; 616 return count;
597} 617}
598 618
599#define show_fan_offset(offset) \ 619#define show_fan_offset(offset) \
600static ssize_t show_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ 620static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
601{ \ 621 show_fan, NULL, offset - 1); \
602 return show_fan(dev, buf, offset - 1); \ 622static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
603} \ 623 show_fan_min, set_fan_min, offset - 1); \
604static ssize_t show_fan_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ 624static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
605{ \ 625 show_fan_div, set_fan_div, offset - 1);
606 return show_fan_min(dev, buf, offset - 1); \
607} \
608static ssize_t show_fan_##offset##_div (struct device *dev, struct device_attribute *attr, char *buf) \
609{ \
610 return show_fan_div(dev, buf, offset - 1); \
611} \
612static ssize_t set_fan_##offset##_min (struct device *dev, struct device_attribute *attr, \
613 const char *buf, size_t count) \
614{ \
615 return set_fan_min(dev, buf, count, offset - 1); \
616} \
617static ssize_t set_fan_##offset##_div (struct device *dev, struct device_attribute *attr, \
618 const char *buf, size_t count) \
619{ \
620 return set_fan_div(dev, buf, count, offset - 1); \
621} \
622static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL); \
623static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
624 show_fan_##offset##_min, set_fan_##offset##_min); \
625static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
626 show_fan_##offset##_div, set_fan_##offset##_div);
627 626
628show_fan_offset(1); 627show_fan_offset(1);
629show_fan_offset(2); 628show_fan_offset(2);
630show_fan_offset(3); 629show_fan_offset(3);
631 630
632#define show_pwm_offset(offset) \ 631#define show_pwm_offset(offset) \
633static ssize_t show_pwm##offset##_enable (struct device *dev, struct device_attribute *attr, \ 632static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \
634 char *buf) \ 633 show_pwm_enable, set_pwm_enable, offset - 1); \
635{ \ 634static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \
636 return show_pwm_enable(dev, buf, offset - 1); \ 635 show_pwm, set_pwm, offset - 1);
637} \
638static ssize_t show_pwm##offset (struct device *dev, struct device_attribute *attr, char *buf) \
639{ \
640 return show_pwm(dev, buf, offset - 1); \
641} \
642static ssize_t set_pwm##offset##_enable (struct device *dev, struct device_attribute *attr, \
643 const char *buf, size_t count) \
644{ \
645 return set_pwm_enable(dev, buf, count, offset - 1); \
646} \
647static ssize_t set_pwm##offset (struct device *dev, struct device_attribute *attr, \
648 const char *buf, size_t count) \
649{ \
650 return set_pwm(dev, buf, count, offset - 1); \
651} \
652static DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \
653 show_pwm##offset##_enable, \
654 set_pwm##offset##_enable); \
655static DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \
656 show_pwm##offset , set_pwm##offset );
657 636
658show_pwm_offset(1); 637show_pwm_offset(1);
659show_pwm_offset(2); 638show_pwm_offset(2);
@@ -861,60 +840,60 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind)
861 it87_init_client(new_client, data); 840 it87_init_client(new_client, data);
862 841
863 /* Register sysfs hooks */ 842 /* Register sysfs hooks */
864 device_create_file(&new_client->dev, &dev_attr_in0_input); 843 device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr);
865 device_create_file(&new_client->dev, &dev_attr_in1_input); 844 device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr);
866 device_create_file(&new_client->dev, &dev_attr_in2_input); 845 device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr);
867 device_create_file(&new_client->dev, &dev_attr_in3_input); 846 device_create_file(&new_client->dev, &sensor_dev_attr_in3_input.dev_attr);
868 device_create_file(&new_client->dev, &dev_attr_in4_input); 847 device_create_file(&new_client->dev, &sensor_dev_attr_in4_input.dev_attr);
869 device_create_file(&new_client->dev, &dev_attr_in5_input); 848 device_create_file(&new_client->dev, &sensor_dev_attr_in5_input.dev_attr);
870 device_create_file(&new_client->dev, &dev_attr_in6_input); 849 device_create_file(&new_client->dev, &sensor_dev_attr_in6_input.dev_attr);
871 device_create_file(&new_client->dev, &dev_attr_in7_input); 850 device_create_file(&new_client->dev, &sensor_dev_attr_in7_input.dev_attr);
872 device_create_file(&new_client->dev, &dev_attr_in8_input); 851 device_create_file(&new_client->dev, &sensor_dev_attr_in8_input.dev_attr);
873 device_create_file(&new_client->dev, &dev_attr_in0_min); 852 device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr);
874 device_create_file(&new_client->dev, &dev_attr_in1_min); 853 device_create_file(&new_client->dev, &sensor_dev_attr_in1_min.dev_attr);
875 device_create_file(&new_client->dev, &dev_attr_in2_min); 854 device_create_file(&new_client->dev, &sensor_dev_attr_in2_min.dev_attr);
876 device_create_file(&new_client->dev, &dev_attr_in3_min); 855 device_create_file(&new_client->dev, &sensor_dev_attr_in3_min.dev_attr);
877 device_create_file(&new_client->dev, &dev_attr_in4_min); 856 device_create_file(&new_client->dev, &sensor_dev_attr_in4_min.dev_attr);
878 device_create_file(&new_client->dev, &dev_attr_in5_min); 857 device_create_file(&new_client->dev, &sensor_dev_attr_in5_min.dev_attr);
879 device_create_file(&new_client->dev, &dev_attr_in6_min); 858 device_create_file(&new_client->dev, &sensor_dev_attr_in6_min.dev_attr);
880 device_create_file(&new_client->dev, &dev_attr_in7_min); 859 device_create_file(&new_client->dev, &sensor_dev_attr_in7_min.dev_attr);
881 device_create_file(&new_client->dev, &dev_attr_in0_max); 860 device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr);
882 device_create_file(&new_client->dev, &dev_attr_in1_max); 861 device_create_file(&new_client->dev, &sensor_dev_attr_in1_max.dev_attr);
883 device_create_file(&new_client->dev, &dev_attr_in2_max); 862 device_create_file(&new_client->dev, &sensor_dev_attr_in2_max.dev_attr);
884 device_create_file(&new_client->dev, &dev_attr_in3_max); 863 device_create_file(&new_client->dev, &sensor_dev_attr_in3_max.dev_attr);
885 device_create_file(&new_client->dev, &dev_attr_in4_max); 864 device_create_file(&new_client->dev, &sensor_dev_attr_in4_max.dev_attr);
886 device_create_file(&new_client->dev, &dev_attr_in5_max); 865 device_create_file(&new_client->dev, &sensor_dev_attr_in5_max.dev_attr);
887 device_create_file(&new_client->dev, &dev_attr_in6_max); 866 device_create_file(&new_client->dev, &sensor_dev_attr_in6_max.dev_attr);
888 device_create_file(&new_client->dev, &dev_attr_in7_max); 867 device_create_file(&new_client->dev, &sensor_dev_attr_in7_max.dev_attr);
889 device_create_file(&new_client->dev, &dev_attr_temp1_input); 868 device_create_file(&new_client->dev, &sensor_dev_attr_temp1_input.dev_attr);
890 device_create_file(&new_client->dev, &dev_attr_temp2_input); 869 device_create_file(&new_client->dev, &sensor_dev_attr_temp2_input.dev_attr);
891 device_create_file(&new_client->dev, &dev_attr_temp3_input); 870 device_create_file(&new_client->dev, &sensor_dev_attr_temp3_input.dev_attr);
892 device_create_file(&new_client->dev, &dev_attr_temp1_max); 871 device_create_file(&new_client->dev, &sensor_dev_attr_temp1_max.dev_attr);
893 device_create_file(&new_client->dev, &dev_attr_temp2_max); 872 device_create_file(&new_client->dev, &sensor_dev_attr_temp2_max.dev_attr);
894 device_create_file(&new_client->dev, &dev_attr_temp3_max); 873 device_create_file(&new_client->dev, &sensor_dev_attr_temp3_max.dev_attr);
895 device_create_file(&new_client->dev, &dev_attr_temp1_min); 874 device_create_file(&new_client->dev, &sensor_dev_attr_temp1_min.dev_attr);
896 device_create_file(&new_client->dev, &dev_attr_temp2_min); 875 device_create_file(&new_client->dev, &sensor_dev_attr_temp2_min.dev_attr);
897 device_create_file(&new_client->dev, &dev_attr_temp3_min); 876 device_create_file(&new_client->dev, &sensor_dev_attr_temp3_min.dev_attr);
898 device_create_file(&new_client->dev, &dev_attr_temp1_type); 877 device_create_file(&new_client->dev, &sensor_dev_attr_temp1_type.dev_attr);
899 device_create_file(&new_client->dev, &dev_attr_temp2_type); 878 device_create_file(&new_client->dev, &sensor_dev_attr_temp2_type.dev_attr);
900 device_create_file(&new_client->dev, &dev_attr_temp3_type); 879 device_create_file(&new_client->dev, &sensor_dev_attr_temp3_type.dev_attr);
901 device_create_file(&new_client->dev, &dev_attr_fan1_input); 880 device_create_file(&new_client->dev, &sensor_dev_attr_fan1_input.dev_attr);
902 device_create_file(&new_client->dev, &dev_attr_fan2_input); 881 device_create_file(&new_client->dev, &sensor_dev_attr_fan2_input.dev_attr);
903 device_create_file(&new_client->dev, &dev_attr_fan3_input); 882 device_create_file(&new_client->dev, &sensor_dev_attr_fan3_input.dev_attr);
904 device_create_file(&new_client->dev, &dev_attr_fan1_min); 883 device_create_file(&new_client->dev, &sensor_dev_attr_fan1_min.dev_attr);
905 device_create_file(&new_client->dev, &dev_attr_fan2_min); 884 device_create_file(&new_client->dev, &sensor_dev_attr_fan2_min.dev_attr);
906 device_create_file(&new_client->dev, &dev_attr_fan3_min); 885 device_create_file(&new_client->dev, &sensor_dev_attr_fan3_min.dev_attr);
907 device_create_file(&new_client->dev, &dev_attr_fan1_div); 886 device_create_file(&new_client->dev, &sensor_dev_attr_fan1_div.dev_attr);
908 device_create_file(&new_client->dev, &dev_attr_fan2_div); 887 device_create_file(&new_client->dev, &sensor_dev_attr_fan2_div.dev_attr);
909 device_create_file(&new_client->dev, &dev_attr_fan3_div); 888 device_create_file(&new_client->dev, &sensor_dev_attr_fan3_div.dev_attr);
910 device_create_file(&new_client->dev, &dev_attr_alarms); 889 device_create_file(&new_client->dev, &dev_attr_alarms);
911 if (enable_pwm_interface) { 890 if (enable_pwm_interface) {
912 device_create_file(&new_client->dev, &dev_attr_pwm1_enable); 891 device_create_file(&new_client->dev, &sensor_dev_attr_pwm1_enable.dev_attr);
913 device_create_file(&new_client->dev, &dev_attr_pwm2_enable); 892 device_create_file(&new_client->dev, &sensor_dev_attr_pwm2_enable.dev_attr);
914 device_create_file(&new_client->dev, &dev_attr_pwm3_enable); 893 device_create_file(&new_client->dev, &sensor_dev_attr_pwm3_enable.dev_attr);
915 device_create_file(&new_client->dev, &dev_attr_pwm1); 894 device_create_file(&new_client->dev, &sensor_dev_attr_pwm1.dev_attr);
916 device_create_file(&new_client->dev, &dev_attr_pwm2); 895 device_create_file(&new_client->dev, &sensor_dev_attr_pwm2.dev_attr);
917 device_create_file(&new_client->dev, &dev_attr_pwm3); 896 device_create_file(&new_client->dev, &sensor_dev_attr_pwm3.dev_attr);
918 } 897 }
919 898
920 if (data->type == it8712) { 899 if (data->type == it8712) {