aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm87.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2007-09-26 17:39:01 -0400
committerMark M. Hoffman <mhoffman@lightlink.com>2007-10-09 22:56:31 -0400
commitc2803b98557c10464f3a1fc65f56d0c8c01991bd (patch)
tree90c251f232eab77c8e45bc8d843990196a226b45 /drivers/hwmon/lm87.c
parentb965d4b7f614522170af6a7e450be0333792ccd2 (diff)
hwmon: (lm87) Add individual alarm files
Add individual alarm files to the lm87 driver. The new libsensors needs this. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Hans de Goede <j.w.r.degoede@hhs.nl> Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
Diffstat (limited to 'drivers/hwmon/lm87.c')
-rw-r--r--drivers/hwmon/lm87.c67
1 files changed, 61 insertions, 6 deletions
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c
index ef8a9b251cd8..86537af0a0b5 100644
--- a/drivers/hwmon/lm87.c
+++ b/drivers/hwmon/lm87.c
@@ -58,6 +58,7 @@
58#include <linux/jiffies.h> 58#include <linux/jiffies.h>
59#include <linux/i2c.h> 59#include <linux/i2c.h>
60#include <linux/hwmon.h> 60#include <linux/hwmon.h>
61#include <linux/hwmon-sysfs.h>
61#include <linux/hwmon-vid.h> 62#include <linux/hwmon-vid.h>
62#include <linux/err.h> 63#include <linux/err.h>
63#include <linux/mutex.h> 64#include <linux/mutex.h>
@@ -531,6 +532,29 @@ static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const
531} 532}
532static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); 533static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout);
533 534
535static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
536 char *buf)
537{
538 struct lm87_data *data = lm87_update_device(dev);
539 int bitnr = to_sensor_dev_attr(attr)->index;
540 return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1);
541}
542static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0);
543static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1);
544static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2);
545static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3);
546static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 8);
547static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 9);
548static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 6);
549static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 7);
550static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4);
551static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 5);
552static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 5);
553static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 6);
554static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 7);
555static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 14);
556static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_alarm, NULL, 15);
557
534/* 558/*
535 * Real code 559 * Real code
536 */ 560 */
@@ -546,24 +570,31 @@ static struct attribute *lm87_attributes[] = {
546 &dev_attr_in1_input.attr, 570 &dev_attr_in1_input.attr,
547 &dev_attr_in1_min.attr, 571 &dev_attr_in1_min.attr,
548 &dev_attr_in1_max.attr, 572 &dev_attr_in1_max.attr,
573 &sensor_dev_attr_in1_alarm.dev_attr.attr,
549 &dev_attr_in2_input.attr, 574 &dev_attr_in2_input.attr,
550 &dev_attr_in2_min.attr, 575 &dev_attr_in2_min.attr,
551 &dev_attr_in2_max.attr, 576 &dev_attr_in2_max.attr,
577 &sensor_dev_attr_in2_alarm.dev_attr.attr,
552 &dev_attr_in3_input.attr, 578 &dev_attr_in3_input.attr,
553 &dev_attr_in3_min.attr, 579 &dev_attr_in3_min.attr,
554 &dev_attr_in3_max.attr, 580 &dev_attr_in3_max.attr,
581 &sensor_dev_attr_in3_alarm.dev_attr.attr,
555 &dev_attr_in4_input.attr, 582 &dev_attr_in4_input.attr,
556 &dev_attr_in4_min.attr, 583 &dev_attr_in4_min.attr,
557 &dev_attr_in4_max.attr, 584 &dev_attr_in4_max.attr,
585 &sensor_dev_attr_in4_alarm.dev_attr.attr,
558 586
559 &dev_attr_temp1_input.attr, 587 &dev_attr_temp1_input.attr,
560 &dev_attr_temp1_max.attr, 588 &dev_attr_temp1_max.attr,
561 &dev_attr_temp1_min.attr, 589 &dev_attr_temp1_min.attr,
562 &dev_attr_temp1_crit.attr, 590 &dev_attr_temp1_crit.attr,
591 &sensor_dev_attr_temp1_alarm.dev_attr.attr,
563 &dev_attr_temp2_input.attr, 592 &dev_attr_temp2_input.attr,
564 &dev_attr_temp2_max.attr, 593 &dev_attr_temp2_max.attr,
565 &dev_attr_temp2_min.attr, 594 &dev_attr_temp2_min.attr,
566 &dev_attr_temp2_crit.attr, 595 &dev_attr_temp2_crit.attr,
596 &sensor_dev_attr_temp2_alarm.dev_attr.attr,
597 &sensor_dev_attr_temp2_fault.dev_attr.attr,
567 598
568 &dev_attr_alarms.attr, 599 &dev_attr_alarms.attr,
569 &dev_attr_aout_output.attr, 600 &dev_attr_aout_output.attr,
@@ -579,30 +610,38 @@ static struct attribute *lm87_attributes_opt[] = {
579 &dev_attr_in6_input.attr, 610 &dev_attr_in6_input.attr,
580 &dev_attr_in6_min.attr, 611 &dev_attr_in6_min.attr,
581 &dev_attr_in6_max.attr, 612 &dev_attr_in6_max.attr,
613 &sensor_dev_attr_in6_alarm.dev_attr.attr,
582 614
583 &dev_attr_fan1_input.attr, 615 &dev_attr_fan1_input.attr,
584 &dev_attr_fan1_min.attr, 616 &dev_attr_fan1_min.attr,
585 &dev_attr_fan1_div.attr, 617 &dev_attr_fan1_div.attr,
618 &sensor_dev_attr_fan1_alarm.dev_attr.attr,
586 619
587 &dev_attr_in7_input.attr, 620 &dev_attr_in7_input.attr,
588 &dev_attr_in7_min.attr, 621 &dev_attr_in7_min.attr,
589 &dev_attr_in7_max.attr, 622 &dev_attr_in7_max.attr,
623 &sensor_dev_attr_in7_alarm.dev_attr.attr,
590 624
591 &dev_attr_fan2_input.attr, 625 &dev_attr_fan2_input.attr,
592 &dev_attr_fan2_min.attr, 626 &dev_attr_fan2_min.attr,
593 &dev_attr_fan2_div.attr, 627 &dev_attr_fan2_div.attr,
628 &sensor_dev_attr_fan2_alarm.dev_attr.attr,
594 629
595 &dev_attr_temp3_input.attr, 630 &dev_attr_temp3_input.attr,
596 &dev_attr_temp3_max.attr, 631 &dev_attr_temp3_max.attr,
597 &dev_attr_temp3_min.attr, 632 &dev_attr_temp3_min.attr,
598 &dev_attr_temp3_crit.attr, 633 &dev_attr_temp3_crit.attr,
634 &sensor_dev_attr_temp3_alarm.dev_attr.attr,
635 &sensor_dev_attr_temp3_fault.dev_attr.attr,
599 636
600 &dev_attr_in0_input.attr, 637 &dev_attr_in0_input.attr,
601 &dev_attr_in0_min.attr, 638 &dev_attr_in0_min.attr,
602 &dev_attr_in0_max.attr, 639 &dev_attr_in0_max.attr,
640 &sensor_dev_attr_in0_alarm.dev_attr.attr,
603 &dev_attr_in5_input.attr, 641 &dev_attr_in5_input.attr,
604 &dev_attr_in5_min.attr, 642 &dev_attr_in5_min.attr,
605 &dev_attr_in5_max.attr, 643 &dev_attr_in5_max.attr,
644 &sensor_dev_attr_in5_alarm.dev_attr.attr,
606 645
607 &dev_attr_cpu0_vid.attr, 646 &dev_attr_cpu0_vid.attr,
608 &dev_attr_vrm.attr, 647 &dev_attr_vrm.attr,
@@ -690,7 +729,9 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind)
690 || (err = device_create_file(&new_client->dev, 729 || (err = device_create_file(&new_client->dev,
691 &dev_attr_in6_min)) 730 &dev_attr_in6_min))
692 || (err = device_create_file(&new_client->dev, 731 || (err = device_create_file(&new_client->dev,
693 &dev_attr_in6_max))) 732 &dev_attr_in6_max))
733 || (err = device_create_file(&new_client->dev,
734 &sensor_dev_attr_in6_alarm.dev_attr)))
694 goto exit_remove; 735 goto exit_remove;
695 } else { 736 } else {
696 if ((err = device_create_file(&new_client->dev, 737 if ((err = device_create_file(&new_client->dev,
@@ -698,7 +739,9 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind)
698 || (err = device_create_file(&new_client->dev, 739 || (err = device_create_file(&new_client->dev,
699 &dev_attr_fan1_min)) 740 &dev_attr_fan1_min))
700 || (err = device_create_file(&new_client->dev, 741 || (err = device_create_file(&new_client->dev,
701 &dev_attr_fan1_div))) 742 &dev_attr_fan1_div))
743 || (err = device_create_file(&new_client->dev,
744 &sensor_dev_attr_fan1_alarm.dev_attr)))
702 goto exit_remove; 745 goto exit_remove;
703 } 746 }
704 747
@@ -708,7 +751,9 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind)
708 || (err = device_create_file(&new_client->dev, 751 || (err = device_create_file(&new_client->dev,
709 &dev_attr_in7_min)) 752 &dev_attr_in7_min))
710 || (err = device_create_file(&new_client->dev, 753 || (err = device_create_file(&new_client->dev,
711 &dev_attr_in7_max))) 754 &dev_attr_in7_max))
755 || (err = device_create_file(&new_client->dev,
756 &sensor_dev_attr_in7_alarm.dev_attr)))
712 goto exit_remove; 757 goto exit_remove;
713 } else { 758 } else {
714 if ((err = device_create_file(&new_client->dev, 759 if ((err = device_create_file(&new_client->dev,
@@ -716,7 +761,9 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind)
716 || (err = device_create_file(&new_client->dev, 761 || (err = device_create_file(&new_client->dev,
717 &dev_attr_fan2_min)) 762 &dev_attr_fan2_min))
718 || (err = device_create_file(&new_client->dev, 763 || (err = device_create_file(&new_client->dev,
719 &dev_attr_fan2_div))) 764 &dev_attr_fan2_div))
765 || (err = device_create_file(&new_client->dev,
766 &sensor_dev_attr_fan2_alarm.dev_attr)))
720 goto exit_remove; 767 goto exit_remove;
721 } 768 }
722 769
@@ -728,7 +775,11 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind)
728 || (err = device_create_file(&new_client->dev, 775 || (err = device_create_file(&new_client->dev,
729 &dev_attr_temp3_min)) 776 &dev_attr_temp3_min))
730 || (err = device_create_file(&new_client->dev, 777 || (err = device_create_file(&new_client->dev,
731 &dev_attr_temp3_crit))) 778 &dev_attr_temp3_crit))
779 || (err = device_create_file(&new_client->dev,
780 &sensor_dev_attr_temp3_alarm.dev_attr))
781 || (err = device_create_file(&new_client->dev,
782 &sensor_dev_attr_temp3_fault.dev_attr)))
732 goto exit_remove; 783 goto exit_remove;
733 } else { 784 } else {
734 if ((err = device_create_file(&new_client->dev, 785 if ((err = device_create_file(&new_client->dev,
@@ -738,11 +789,15 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind)
738 || (err = device_create_file(&new_client->dev, 789 || (err = device_create_file(&new_client->dev,
739 &dev_attr_in0_max)) 790 &dev_attr_in0_max))
740 || (err = device_create_file(&new_client->dev, 791 || (err = device_create_file(&new_client->dev,
792 &sensor_dev_attr_in0_alarm.dev_attr))
793 || (err = device_create_file(&new_client->dev,
741 &dev_attr_in5_input)) 794 &dev_attr_in5_input))
742 || (err = device_create_file(&new_client->dev, 795 || (err = device_create_file(&new_client->dev,
743 &dev_attr_in5_min)) 796 &dev_attr_in5_min))
744 || (err = device_create_file(&new_client->dev, 797 || (err = device_create_file(&new_client->dev,
745 &dev_attr_in5_max))) 798 &dev_attr_in5_max))
799 || (err = device_create_file(&new_client->dev,
800 &sensor_dev_attr_in5_alarm.dev_attr)))
746 goto exit_remove; 801 goto exit_remove;
747 } 802 }
748 803