aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm83.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/lm83.c')
-rw-r--r--drivers/hwmon/lm83.c49
1 files changed, 48 insertions, 1 deletions
diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c
index 2137d7879df6..ea224891d311 100644
--- a/drivers/hwmon/lm83.c
+++ b/drivers/hwmon/lm83.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * lm83.c - Part of lm_sensors, Linux kernel modules for hardware 2 * lm83.c - Part of lm_sensors, Linux kernel modules for hardware
3 * monitoring 3 * monitoring
4 * Copyright (C) 2003-2005 Jean Delvare <khali@linux-fr.org> 4 * Copyright (C) 2003-2006 Jean Delvare <khali@linux-fr.org>
5 * 5 *
6 * Heavily inspired from the lm78, lm75 and adm1021 drivers. The LM83 is 6 * Heavily inspired from the lm78, lm75 and adm1021 drivers. The LM83 is
7 * a sensor chip made by National Semiconductor. It reports up to four 7 * a sensor chip made by National Semiconductor. It reports up to four
@@ -191,6 +191,16 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *dummy,
191 return sprintf(buf, "%d\n", data->alarms); 191 return sprintf(buf, "%d\n", data->alarms);
192} 192}
193 193
194static ssize_t show_alarm(struct device *dev, struct device_attribute
195 *devattr, char *buf)
196{
197 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
198 struct lm83_data *data = lm83_update_device(dev);
199 int bitnr = attr->index;
200
201 return sprintf(buf, "%d\n", (data->alarms >> bitnr) & 1);
202}
203
194static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); 204static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0);
195static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); 205static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1);
196static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2); 206static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2);
@@ -208,6 +218,20 @@ static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp, NULL, 8);
208static SENSOR_DEVICE_ATTR(temp3_crit, S_IWUSR | S_IRUGO, show_temp, 218static SENSOR_DEVICE_ATTR(temp3_crit, S_IWUSR | S_IRUGO, show_temp,
209 set_temp, 8); 219 set_temp, 8);
210static SENSOR_DEVICE_ATTR(temp4_crit, S_IRUGO, show_temp, NULL, 8); 220static SENSOR_DEVICE_ATTR(temp4_crit, S_IRUGO, show_temp, NULL, 8);
221
222/* Individual alarm files */
223static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 0);
224static SENSOR_DEVICE_ATTR(temp3_crit_alarm, S_IRUGO, show_alarm, NULL, 1);
225static SENSOR_DEVICE_ATTR(temp3_input_fault, S_IRUGO, show_alarm, NULL, 2);
226static SENSOR_DEVICE_ATTR(temp3_max_alarm, S_IRUGO, show_alarm, NULL, 4);
227static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6);
228static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL, 8);
229static SENSOR_DEVICE_ATTR(temp4_crit_alarm, S_IRUGO, show_alarm, NULL, 9);
230static SENSOR_DEVICE_ATTR(temp4_input_fault, S_IRUGO, show_alarm, NULL, 10);
231static SENSOR_DEVICE_ATTR(temp4_max_alarm, S_IRUGO, show_alarm, NULL, 12);
232static SENSOR_DEVICE_ATTR(temp2_input_fault, S_IRUGO, show_alarm, NULL, 13);
233static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 15);
234/* Raw alarm file for compatibility */
211static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 235static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
212 236
213/* 237/*
@@ -350,6 +374,16 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind)
350 device_create_file(&new_client->dev, 374 device_create_file(&new_client->dev,
351 &sensor_dev_attr_temp3_crit.dev_attr); 375 &sensor_dev_attr_temp3_crit.dev_attr);
352 376
377 device_create_file(&new_client->dev,
378 &sensor_dev_attr_temp3_input_fault.dev_attr);
379 device_create_file(&new_client->dev,
380 &sensor_dev_attr_temp1_max_alarm.dev_attr);
381 device_create_file(&new_client->dev,
382 &sensor_dev_attr_temp3_max_alarm.dev_attr);
383 device_create_file(&new_client->dev,
384 &sensor_dev_attr_temp1_crit_alarm.dev_attr);
385 device_create_file(&new_client->dev,
386 &sensor_dev_attr_temp3_crit_alarm.dev_attr);
353 device_create_file(&new_client->dev, &dev_attr_alarms); 387 device_create_file(&new_client->dev, &dev_attr_alarms);
354 388
355 if (kind == lm83) { 389 if (kind == lm83) {
@@ -367,6 +401,19 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind)
367 &sensor_dev_attr_temp2_crit.dev_attr); 401 &sensor_dev_attr_temp2_crit.dev_attr);
368 device_create_file(&new_client->dev, 402 device_create_file(&new_client->dev,
369 &sensor_dev_attr_temp4_crit.dev_attr); 403 &sensor_dev_attr_temp4_crit.dev_attr);
404
405 device_create_file(&new_client->dev,
406 &sensor_dev_attr_temp2_input_fault.dev_attr);
407 device_create_file(&new_client->dev,
408 &sensor_dev_attr_temp4_input_fault.dev_attr);
409 device_create_file(&new_client->dev,
410 &sensor_dev_attr_temp2_max_alarm.dev_attr);
411 device_create_file(&new_client->dev,
412 &sensor_dev_attr_temp4_max_alarm.dev_attr);
413 device_create_file(&new_client->dev,
414 &sensor_dev_attr_temp2_crit_alarm.dev_attr);
415 device_create_file(&new_client->dev,
416 &sensor_dev_attr_temp4_crit_alarm.dev_attr);
370 } 417 }
371 418
372 return 0; 419 return 0;