aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm78.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/lm78.c')
-rw-r--r--drivers/hwmon/lm78.c48
1 files changed, 39 insertions, 9 deletions
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c
index 6eea3476b90c..3f7055ee679f 100644
--- a/drivers/hwmon/lm78.c
+++ b/drivers/hwmon/lm78.c
@@ -131,7 +131,7 @@ static inline int TEMP_FROM_REG(s8 val)
131 the driver field to differentiate between I2C and ISA chips. */ 131 the driver field to differentiate between I2C and ISA chips. */
132struct lm78_data { 132struct lm78_data {
133 struct i2c_client client; 133 struct i2c_client client;
134 struct class_device *class_dev; 134 struct device *hwmon_dev;
135 struct mutex lock; 135 struct mutex lock;
136 enum chips type; 136 enum chips type;
137 137
@@ -438,6 +438,25 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *da,
438} 438}
439static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 439static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
440 440
441static ssize_t show_alarm(struct device *dev, struct device_attribute *da,
442 char *buf)
443{
444 struct lm78_data *data = lm78_update_device(dev);
445 int nr = to_sensor_dev_attr(da)->index;
446 return sprintf(buf, "%u\n", (data->alarms >> nr) & 1);
447}
448static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0);
449static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1);
450static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2);
451static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3);
452static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 8);
453static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 9);
454static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 10);
455static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 6);
456static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 7);
457static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, 11);
458static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4);
459
441/* This function is called when: 460/* This function is called when:
442 * lm78_driver is inserted (when this module is loaded), for each 461 * lm78_driver is inserted (when this module is loaded), for each
443 available adapter 462 available adapter
@@ -453,36 +472,47 @@ static struct attribute *lm78_attributes[] = {
453 &sensor_dev_attr_in0_input.dev_attr.attr, 472 &sensor_dev_attr_in0_input.dev_attr.attr,
454 &sensor_dev_attr_in0_min.dev_attr.attr, 473 &sensor_dev_attr_in0_min.dev_attr.attr,
455 &sensor_dev_attr_in0_max.dev_attr.attr, 474 &sensor_dev_attr_in0_max.dev_attr.attr,
475 &sensor_dev_attr_in0_alarm.dev_attr.attr,
456 &sensor_dev_attr_in1_input.dev_attr.attr, 476 &sensor_dev_attr_in1_input.dev_attr.attr,
457 &sensor_dev_attr_in1_min.dev_attr.attr, 477 &sensor_dev_attr_in1_min.dev_attr.attr,
458 &sensor_dev_attr_in1_max.dev_attr.attr, 478 &sensor_dev_attr_in1_max.dev_attr.attr,
479 &sensor_dev_attr_in1_alarm.dev_attr.attr,
459 &sensor_dev_attr_in2_input.dev_attr.attr, 480 &sensor_dev_attr_in2_input.dev_attr.attr,
460 &sensor_dev_attr_in2_min.dev_attr.attr, 481 &sensor_dev_attr_in2_min.dev_attr.attr,
461 &sensor_dev_attr_in2_max.dev_attr.attr, 482 &sensor_dev_attr_in2_max.dev_attr.attr,
483 &sensor_dev_attr_in2_alarm.dev_attr.attr,
462 &sensor_dev_attr_in3_input.dev_attr.attr, 484 &sensor_dev_attr_in3_input.dev_attr.attr,
463 &sensor_dev_attr_in3_min.dev_attr.attr, 485 &sensor_dev_attr_in3_min.dev_attr.attr,
464 &sensor_dev_attr_in3_max.dev_attr.attr, 486 &sensor_dev_attr_in3_max.dev_attr.attr,
487 &sensor_dev_attr_in3_alarm.dev_attr.attr,
465 &sensor_dev_attr_in4_input.dev_attr.attr, 488 &sensor_dev_attr_in4_input.dev_attr.attr,
466 &sensor_dev_attr_in4_min.dev_attr.attr, 489 &sensor_dev_attr_in4_min.dev_attr.attr,
467 &sensor_dev_attr_in4_max.dev_attr.attr, 490 &sensor_dev_attr_in4_max.dev_attr.attr,
491 &sensor_dev_attr_in4_alarm.dev_attr.attr,
468 &sensor_dev_attr_in5_input.dev_attr.attr, 492 &sensor_dev_attr_in5_input.dev_attr.attr,
469 &sensor_dev_attr_in5_min.dev_attr.attr, 493 &sensor_dev_attr_in5_min.dev_attr.attr,
470 &sensor_dev_attr_in5_max.dev_attr.attr, 494 &sensor_dev_attr_in5_max.dev_attr.attr,
495 &sensor_dev_attr_in5_alarm.dev_attr.attr,
471 &sensor_dev_attr_in6_input.dev_attr.attr, 496 &sensor_dev_attr_in6_input.dev_attr.attr,
472 &sensor_dev_attr_in6_min.dev_attr.attr, 497 &sensor_dev_attr_in6_min.dev_attr.attr,
473 &sensor_dev_attr_in6_max.dev_attr.attr, 498 &sensor_dev_attr_in6_max.dev_attr.attr,
499 &sensor_dev_attr_in6_alarm.dev_attr.attr,
474 &dev_attr_temp1_input.attr, 500 &dev_attr_temp1_input.attr,
475 &dev_attr_temp1_max.attr, 501 &dev_attr_temp1_max.attr,
476 &dev_attr_temp1_max_hyst.attr, 502 &dev_attr_temp1_max_hyst.attr,
503 &sensor_dev_attr_temp1_alarm.dev_attr.attr,
477 &sensor_dev_attr_fan1_input.dev_attr.attr, 504 &sensor_dev_attr_fan1_input.dev_attr.attr,
478 &sensor_dev_attr_fan1_min.dev_attr.attr, 505 &sensor_dev_attr_fan1_min.dev_attr.attr,
479 &sensor_dev_attr_fan1_div.dev_attr.attr, 506 &sensor_dev_attr_fan1_div.dev_attr.attr,
507 &sensor_dev_attr_fan1_alarm.dev_attr.attr,
480 &sensor_dev_attr_fan2_input.dev_attr.attr, 508 &sensor_dev_attr_fan2_input.dev_attr.attr,
481 &sensor_dev_attr_fan2_min.dev_attr.attr, 509 &sensor_dev_attr_fan2_min.dev_attr.attr,
482 &sensor_dev_attr_fan2_div.dev_attr.attr, 510 &sensor_dev_attr_fan2_div.dev_attr.attr,
511 &sensor_dev_attr_fan2_alarm.dev_attr.attr,
483 &sensor_dev_attr_fan3_input.dev_attr.attr, 512 &sensor_dev_attr_fan3_input.dev_attr.attr,
484 &sensor_dev_attr_fan3_min.dev_attr.attr, 513 &sensor_dev_attr_fan3_min.dev_attr.attr,
485 &sensor_dev_attr_fan3_div.dev_attr.attr, 514 &sensor_dev_attr_fan3_div.dev_attr.attr,
515 &sensor_dev_attr_fan3_alarm.dev_attr.attr,
486 &dev_attr_alarms.attr, 516 &dev_attr_alarms.attr,
487 &dev_attr_cpu0_vid.attr, 517 &dev_attr_cpu0_vid.attr,
488 518
@@ -585,9 +615,9 @@ static int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
585 if ((err = sysfs_create_group(&new_client->dev.kobj, &lm78_group))) 615 if ((err = sysfs_create_group(&new_client->dev.kobj, &lm78_group)))
586 goto ERROR3; 616 goto ERROR3;
587 617
588 data->class_dev = hwmon_device_register(&new_client->dev); 618 data->hwmon_dev = hwmon_device_register(&new_client->dev);
589 if (IS_ERR(data->class_dev)) { 619 if (IS_ERR(data->hwmon_dev)) {
590 err = PTR_ERR(data->class_dev); 620 err = PTR_ERR(data->hwmon_dev);
591 goto ERROR4; 621 goto ERROR4;
592 } 622 }
593 623
@@ -608,7 +638,7 @@ static int lm78_detach_client(struct i2c_client *client)
608 struct lm78_data *data = i2c_get_clientdata(client); 638 struct lm78_data *data = i2c_get_clientdata(client);
609 int err; 639 int err;
610 640
611 hwmon_device_unregister(data->class_dev); 641 hwmon_device_unregister(data->hwmon_dev);
612 sysfs_remove_group(&client->dev.kobj, &lm78_group); 642 sysfs_remove_group(&client->dev.kobj, &lm78_group);
613 643
614 if ((err = i2c_detach_client(client))) 644 if ((err = i2c_detach_client(client)))
@@ -659,9 +689,9 @@ static int __devinit lm78_isa_probe(struct platform_device *pdev)
659 || (err = device_create_file(&pdev->dev, &dev_attr_name))) 689 || (err = device_create_file(&pdev->dev, &dev_attr_name)))
660 goto exit_remove_files; 690 goto exit_remove_files;
661 691
662 data->class_dev = hwmon_device_register(&pdev->dev); 692 data->hwmon_dev = hwmon_device_register(&pdev->dev);
663 if (IS_ERR(data->class_dev)) { 693 if (IS_ERR(data->hwmon_dev)) {
664 err = PTR_ERR(data->class_dev); 694 err = PTR_ERR(data->hwmon_dev);
665 goto exit_remove_files; 695 goto exit_remove_files;
666 } 696 }
667 697
@@ -681,7 +711,7 @@ static int __devexit lm78_isa_remove(struct platform_device *pdev)
681{ 711{
682 struct lm78_data *data = platform_get_drvdata(pdev); 712 struct lm78_data *data = platform_get_drvdata(pdev);
683 713
684 hwmon_device_unregister(data->class_dev); 714 hwmon_device_unregister(data->hwmon_dev);
685 sysfs_remove_group(&pdev->dev.kobj, &lm78_group); 715 sysfs_remove_group(&pdev->dev.kobj, &lm78_group);
686 device_remove_file(&pdev->dev, &dev_attr_name); 716 device_remove_file(&pdev->dev, &dev_attr_name);
687 release_region(data->client.addr, LM78_EXTENT); 717 release_region(data->client.addr, LM78_EXTENT);