diff options
Diffstat (limited to 'drivers/hwmon/lm92.c')
-rw-r--r-- | drivers/hwmon/lm92.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index af5c77d568fe..c31942e08246 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c | |||
@@ -45,13 +45,14 @@ | |||
45 | #include <linux/slab.h> | 45 | #include <linux/slab.h> |
46 | #include <linux/i2c.h> | 46 | #include <linux/i2c.h> |
47 | #include <linux/hwmon.h> | 47 | #include <linux/hwmon.h> |
48 | #include <linux/hwmon-sysfs.h> | ||
48 | #include <linux/err.h> | 49 | #include <linux/err.h> |
49 | #include <linux/mutex.h> | 50 | #include <linux/mutex.h> |
50 | 51 | ||
51 | /* The LM92 and MAX6635 have 2 two-state pins for address selection, | 52 | /* The LM92 and MAX6635 have 2 two-state pins for address selection, |
52 | resulting in 4 possible addresses. */ | 53 | resulting in 4 possible addresses. */ |
53 | static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, | 54 | static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, |
54 | I2C_CLIENT_END }; | 55 | I2C_CLIENT_END }; |
55 | 56 | ||
56 | /* Insmod parameters */ | 57 | /* Insmod parameters */ |
57 | I2C_CLIENT_INSMOD_1(lm92); | 58 | I2C_CLIENT_INSMOD_1(lm92); |
@@ -209,6 +210,14 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, ch | |||
209 | return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->temp1_input)); | 210 | return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->temp1_input)); |
210 | } | 211 | } |
211 | 212 | ||
213 | static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, | ||
214 | char *buf) | ||
215 | { | ||
216 | int bitnr = to_sensor_dev_attr(attr)->index; | ||
217 | struct lm92_data *data = lm92_update_device(dev); | ||
218 | return sprintf(buf, "%d\n", (data->temp1_input >> bitnr) & 1); | ||
219 | } | ||
220 | |||
212 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1_input, NULL); | 221 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1_input, NULL); |
213 | static DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp1_crit, | 222 | static DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp1_crit, |
214 | set_temp1_crit); | 223 | set_temp1_crit); |
@@ -221,6 +230,9 @@ static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp1_max, | |||
221 | set_temp1_max); | 230 | set_temp1_max); |
222 | static DEVICE_ATTR(temp1_max_hyst, S_IRUGO, show_temp1_max_hyst, NULL); | 231 | static DEVICE_ATTR(temp1_max_hyst, S_IRUGO, show_temp1_max_hyst, NULL); |
223 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 232 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
233 | static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 2); | ||
234 | static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, 0); | ||
235 | static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 1); | ||
224 | 236 | ||
225 | 237 | ||
226 | /* | 238 | /* |
@@ -297,7 +309,9 @@ static struct attribute *lm92_attributes[] = { | |||
297 | &dev_attr_temp1_max.attr, | 309 | &dev_attr_temp1_max.attr, |
298 | &dev_attr_temp1_max_hyst.attr, | 310 | &dev_attr_temp1_max_hyst.attr, |
299 | &dev_attr_alarms.attr, | 311 | &dev_attr_alarms.attr, |
300 | 312 | &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr, | |
313 | &sensor_dev_attr_temp1_min_alarm.dev_attr.attr, | ||
314 | &sensor_dev_attr_temp1_max_alarm.dev_attr.attr, | ||
301 | NULL | 315 | NULL |
302 | }; | 316 | }; |
303 | 317 | ||