diff options
author | Jim Cromie <jim.cromie@gmail.com> | 2008-10-18 23:27:32 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-20 11:52:35 -0400 |
commit | b267e8cdc638dfa53360d532aa56afa0ec12e6a5 (patch) | |
tree | 157decc2e52bf498a8a0b17d9c55b5ece060c6d9 /drivers/hwmon/pc87360.c | |
parent | 492e9657d1a790f44ab9b0e03fc72c1d8145f590 (diff) |
hwmon/pc87360 separate alarm files: add temp-min/max/crit/fault-alarms
Adds temp-min/max/crit/fault-alarm callbacks, sensor-device-attribute
declarations, and refs to those new decls in the macro used to initialize
the temp_group (of sysfs files)
[akpm@linux-foundation.org: cleanups]
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: "Mark M. Hoffman" <mhoffman@lightlink.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/hwmon/pc87360.c')
-rw-r--r-- | drivers/hwmon/pc87360.c | 84 |
1 files changed, 80 insertions, 4 deletions
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index 3a7d7fa64ebc..c80ee5f056ba 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c | |||
@@ -845,12 +845,76 @@ static ssize_t show_temp_alarms(struct device *dev, struct device_attribute *att | |||
845 | } | 845 | } |
846 | static DEVICE_ATTR(alarms_temp, S_IRUGO, show_temp_alarms, NULL); | 846 | static DEVICE_ATTR(alarms_temp, S_IRUGO, show_temp_alarms, NULL); |
847 | 847 | ||
848 | /* show_temp_min/max_alarm() reads data from the per-channel status | ||
849 | register (sec 12.3.7), not the temp event status registers (sec | ||
850 | 12.3.2) that show_temp_alarm() reads (via data->temp_alarms) */ | ||
851 | |||
852 | static ssize_t show_temp_min_alarm(struct device *dev, | ||
853 | struct device_attribute *devattr, char *buf) | ||
854 | { | ||
855 | struct pc87360_data *data = pc87360_update_device(dev); | ||
856 | unsigned nr = to_sensor_dev_attr(devattr)->index; | ||
857 | |||
858 | return sprintf(buf, "%u\n", !!(data->temp_status[nr] & CHAN_ALM_MIN)); | ||
859 | } | ||
860 | static ssize_t show_temp_max_alarm(struct device *dev, | ||
861 | struct device_attribute *devattr, char *buf) | ||
862 | { | ||
863 | struct pc87360_data *data = pc87360_update_device(dev); | ||
864 | unsigned nr = to_sensor_dev_attr(devattr)->index; | ||
865 | |||
866 | return sprintf(buf, "%u\n", !!(data->temp_status[nr] & CHAN_ALM_MAX)); | ||
867 | } | ||
868 | static ssize_t show_temp_crit_alarm(struct device *dev, | ||
869 | struct device_attribute *devattr, char *buf) | ||
870 | { | ||
871 | struct pc87360_data *data = pc87360_update_device(dev); | ||
872 | unsigned nr = to_sensor_dev_attr(devattr)->index; | ||
873 | |||
874 | return sprintf(buf, "%u\n", !!(data->temp_status[nr] & TEMP_ALM_CRIT)); | ||
875 | } | ||
876 | |||
877 | static struct sensor_device_attribute temp_min_alarm[] = { | ||
878 | SENSOR_ATTR(temp1_min_alarm, S_IRUGO, show_temp_min_alarm, NULL, 0), | ||
879 | SENSOR_ATTR(temp2_min_alarm, S_IRUGO, show_temp_min_alarm, NULL, 1), | ||
880 | SENSOR_ATTR(temp3_min_alarm, S_IRUGO, show_temp_min_alarm, NULL, 2), | ||
881 | }; | ||
882 | static struct sensor_device_attribute temp_max_alarm[] = { | ||
883 | SENSOR_ATTR(temp1_max_alarm, S_IRUGO, show_temp_max_alarm, NULL, 0), | ||
884 | SENSOR_ATTR(temp2_max_alarm, S_IRUGO, show_temp_max_alarm, NULL, 1), | ||
885 | SENSOR_ATTR(temp3_max_alarm, S_IRUGO, show_temp_max_alarm, NULL, 2), | ||
886 | }; | ||
887 | static struct sensor_device_attribute temp_crit_alarm[] = { | ||
888 | SENSOR_ATTR(temp1_crit_alarm, S_IRUGO, show_temp_crit_alarm, NULL, 0), | ||
889 | SENSOR_ATTR(temp2_crit_alarm, S_IRUGO, show_temp_crit_alarm, NULL, 1), | ||
890 | SENSOR_ATTR(temp3_crit_alarm, S_IRUGO, show_temp_crit_alarm, NULL, 2), | ||
891 | }; | ||
892 | |||
893 | #define TEMP_FAULT 0x40 /* open diode */ | ||
894 | static ssize_t show_temp_fault(struct device *dev, | ||
895 | struct device_attribute *devattr, char *buf) | ||
896 | { | ||
897 | struct pc87360_data *data = pc87360_update_device(dev); | ||
898 | unsigned nr = to_sensor_dev_attr(devattr)->index; | ||
899 | |||
900 | return sprintf(buf, "%u\n", !!(data->temp_status[nr] & TEMP_FAULT)); | ||
901 | } | ||
902 | static struct sensor_device_attribute temp_fault[] = { | ||
903 | SENSOR_ATTR(temp1_fault, S_IRUGO, show_temp_fault, NULL, 0), | ||
904 | SENSOR_ATTR(temp2_fault, S_IRUGO, show_temp_fault, NULL, 1), | ||
905 | SENSOR_ATTR(temp3_fault, S_IRUGO, show_temp_fault, NULL, 2), | ||
906 | }; | ||
907 | |||
848 | #define TEMP_UNIT_ATTRS(X) \ | 908 | #define TEMP_UNIT_ATTRS(X) \ |
849 | &temp_input[X].dev_attr.attr, \ | 909 | &temp_input[X].dev_attr.attr, \ |
850 | &temp_status[X].dev_attr.attr, \ | 910 | &temp_status[X].dev_attr.attr, \ |
851 | &temp_min[X].dev_attr.attr, \ | 911 | &temp_min[X].dev_attr.attr, \ |
852 | &temp_max[X].dev_attr.attr, \ | 912 | &temp_max[X].dev_attr.attr, \ |
853 | &temp_crit[X].dev_attr.attr | 913 | &temp_crit[X].dev_attr.attr, \ |
914 | &temp_min_alarm[X].dev_attr.attr, \ | ||
915 | &temp_max_alarm[X].dev_attr.attr, \ | ||
916 | &temp_crit_alarm[X].dev_attr.attr, \ | ||
917 | &temp_fault[X].dev_attr.attr | ||
854 | 918 | ||
855 | static struct attribute * pc8736x_temp_attr_array[] = { | 919 | static struct attribute * pc8736x_temp_attr_array[] = { |
856 | TEMP_UNIT_ATTRS(0), | 920 | TEMP_UNIT_ATTRS(0), |
@@ -864,8 +928,8 @@ static const struct attribute_group pc8736x_temp_group = { | |||
864 | .attrs = pc8736x_temp_attr_array, | 928 | .attrs = pc8736x_temp_attr_array, |
865 | }; | 929 | }; |
866 | 930 | ||
867 | static ssize_t show_name(struct device *dev, struct device_attribute | 931 | static ssize_t show_name(struct device *dev, |
868 | *devattr, char *buf) | 932 | struct device_attribute *devattr, char *buf) |
869 | { | 933 | { |
870 | struct pc87360_data *data = dev_get_drvdata(dev); | 934 | struct pc87360_data *data = dev_get_drvdata(dev); |
871 | return sprintf(buf, "%s\n", data->name); | 935 | return sprintf(buf, "%s\n", data->name); |
@@ -1086,7 +1150,15 @@ static int __devinit pc87360_probe(struct platform_device *pdev) | |||
1086 | || (err = device_create_file(dev, | 1150 | || (err = device_create_file(dev, |
1087 | &temp_crit[i].dev_attr)) | 1151 | &temp_crit[i].dev_attr)) |
1088 | || (err = device_create_file(dev, | 1152 | || (err = device_create_file(dev, |
1089 | &temp_status[i].dev_attr))) | 1153 | &temp_status[i].dev_attr)) |
1154 | || (err = device_create_file(dev, | ||
1155 | &temp_min_alarm[i].dev_attr)) | ||
1156 | || (err = device_create_file(dev, | ||
1157 | &temp_max_alarm[i].dev_attr)) | ||
1158 | || (err = device_create_file(dev, | ||
1159 | &temp_crit_alarm[i].dev_attr)) | ||
1160 | || (err = device_create_file(dev, | ||
1161 | &temp_fault[i].dev_attr))) | ||
1090 | goto ERROR3; | 1162 | goto ERROR3; |
1091 | } | 1163 | } |
1092 | if ((err = device_create_file(dev, &dev_attr_alarms_temp))) | 1164 | if ((err = device_create_file(dev, &dev_attr_alarms_temp))) |
@@ -1192,6 +1264,10 @@ static void pc87360_write_value(struct pc87360_data *data, u8 ldi, u8 bank, | |||
1192 | #define CHAN_ALM_ENA 0x10 /* propagate to alarms-reg ?? (chk val!) */ | 1264 | #define CHAN_ALM_ENA 0x10 /* propagate to alarms-reg ?? (chk val!) */ |
1193 | #define CHAN_READY (CHAN_ENA|CHAN_CNVRTD) /* sample ready mask */ | 1265 | #define CHAN_READY (CHAN_ENA|CHAN_CNVRTD) /* sample ready mask */ |
1194 | 1266 | ||
1267 | #define TEMP_OTS_OE 0x20 /* OTS Output Enable */ | ||
1268 | #define VIN_RW1C_MASK (CHAN_READY|CHAN_ALM_MAX|CHAN_ALM_MIN) /* 0x87 */ | ||
1269 | #define TEMP_RW1C_MASK (VIN_RW1C_MASK|TEMP_ALM_CRIT|TEMP_FAULT) /* 0xCF */ | ||
1270 | |||
1195 | static void pc87360_init_device(struct platform_device *pdev, | 1271 | static void pc87360_init_device(struct platform_device *pdev, |
1196 | int use_thermistors) | 1272 | int use_thermistors) |
1197 | { | 1273 | { |