diff options
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/lm77.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c index cee5c2e8cfad..459b70ad6bee 100644 --- a/drivers/hwmon/lm77.c +++ b/drivers/hwmon/lm77.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/jiffies.h> | 31 | #include <linux/jiffies.h> |
32 | #include <linux/i2c.h> | 32 | #include <linux/i2c.h> |
33 | #include <linux/hwmon.h> | 33 | #include <linux/hwmon.h> |
34 | #include <linux/hwmon-sysfs.h> | ||
34 | #include <linux/err.h> | 35 | #include <linux/err.h> |
35 | #include <linux/mutex.h> | 36 | #include <linux/mutex.h> |
36 | 37 | ||
@@ -113,7 +114,6 @@ show(temp_input); | |||
113 | show(temp_crit); | 114 | show(temp_crit); |
114 | show(temp_min); | 115 | show(temp_min); |
115 | show(temp_max); | 116 | show(temp_max); |
116 | show(alarms); | ||
117 | 117 | ||
118 | /* read routines for hysteresis values */ | 118 | /* read routines for hysteresis values */ |
119 | static ssize_t show_temp_crit_hyst(struct device *dev, struct device_attribute *attr, char *buf) | 119 | static ssize_t show_temp_crit_hyst(struct device *dev, struct device_attribute *attr, char *buf) |
@@ -186,6 +186,14 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr, | |||
186 | return count; | 186 | return count; |
187 | } | 187 | } |
188 | 188 | ||
189 | static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, | ||
190 | char *buf) | ||
191 | { | ||
192 | int bitnr = to_sensor_dev_attr(attr)->index; | ||
193 | struct lm77_data *data = lm77_update_device(dev); | ||
194 | return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1); | ||
195 | } | ||
196 | |||
189 | static DEVICE_ATTR(temp1_input, S_IRUGO, | 197 | static DEVICE_ATTR(temp1_input, S_IRUGO, |
190 | show_temp_input, NULL); | 198 | show_temp_input, NULL); |
191 | static DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, | 199 | static DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, |
@@ -202,8 +210,9 @@ static DEVICE_ATTR(temp1_min_hyst, S_IRUGO, | |||
202 | static DEVICE_ATTR(temp1_max_hyst, S_IRUGO, | 210 | static DEVICE_ATTR(temp1_max_hyst, S_IRUGO, |
203 | show_temp_max_hyst, NULL); | 211 | show_temp_max_hyst, NULL); |
204 | 212 | ||
205 | static DEVICE_ATTR(alarms, S_IRUGO, | 213 | static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 2); |
206 | show_alarms, NULL); | 214 | static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, 0); |
215 | static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 1); | ||
207 | 216 | ||
208 | static int lm77_attach_adapter(struct i2c_adapter *adapter) | 217 | static int lm77_attach_adapter(struct i2c_adapter *adapter) |
209 | { | 218 | { |
@@ -220,8 +229,9 @@ static struct attribute *lm77_attributes[] = { | |||
220 | &dev_attr_temp1_crit_hyst.attr, | 229 | &dev_attr_temp1_crit_hyst.attr, |
221 | &dev_attr_temp1_min_hyst.attr, | 230 | &dev_attr_temp1_min_hyst.attr, |
222 | &dev_attr_temp1_max_hyst.attr, | 231 | &dev_attr_temp1_max_hyst.attr, |
223 | &dev_attr_alarms.attr, | 232 | &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr, |
224 | 233 | &sensor_dev_attr_temp1_min_alarm.dev_attr.attr, | |
234 | &sensor_dev_attr_temp1_max_alarm.dev_attr.attr, | ||
225 | NULL | 235 | NULL |
226 | }; | 236 | }; |
227 | 237 | ||