diff options
author | Jean Delvare <khali@linux-fr.org> | 2006-09-24 14:52:15 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-09-28 18:31:15 -0400 |
commit | 2d45771e6ea79f56a7d85e448f702f60ef86c228 (patch) | |
tree | c3cdd385657c59fe9356cb32283f85f09a717382 /drivers/hwmon/lm83.c | |
parent | 51bd56339335fad3643739504523190cd6d3416b (diff) |
hwmon: Add individual alarm files to 4 drivers
hwmon: Add individual alarm files to 4 drivers
Add individual sysfs files for all f71805f, lm63, lm83 and lm90 alarm
and fault conditions. This is a requirement for the planned
chip-independent libsensors. Almost all other hwmon drivers will need
the same improvement.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/hwmon/lm83.c')
-rw-r--r-- | drivers/hwmon/lm83.c | 49 |
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 | ||
194 | static 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 | |||
194 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); | 204 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); |
195 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); | 205 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); |
196 | static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2); | 206 | static 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); | |||
208 | static SENSOR_DEVICE_ATTR(temp3_crit, S_IWUSR | S_IRUGO, show_temp, | 218 | static SENSOR_DEVICE_ATTR(temp3_crit, S_IWUSR | S_IRUGO, show_temp, |
209 | set_temp, 8); | 219 | set_temp, 8); |
210 | static SENSOR_DEVICE_ATTR(temp4_crit, S_IRUGO, show_temp, NULL, 8); | 220 | static SENSOR_DEVICE_ATTR(temp4_crit, S_IRUGO, show_temp, NULL, 8); |
221 | |||
222 | /* Individual alarm files */ | ||
223 | static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 0); | ||
224 | static SENSOR_DEVICE_ATTR(temp3_crit_alarm, S_IRUGO, show_alarm, NULL, 1); | ||
225 | static SENSOR_DEVICE_ATTR(temp3_input_fault, S_IRUGO, show_alarm, NULL, 2); | ||
226 | static SENSOR_DEVICE_ATTR(temp3_max_alarm, S_IRUGO, show_alarm, NULL, 4); | ||
227 | static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6); | ||
228 | static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL, 8); | ||
229 | static SENSOR_DEVICE_ATTR(temp4_crit_alarm, S_IRUGO, show_alarm, NULL, 9); | ||
230 | static SENSOR_DEVICE_ATTR(temp4_input_fault, S_IRUGO, show_alarm, NULL, 10); | ||
231 | static SENSOR_DEVICE_ATTR(temp4_max_alarm, S_IRUGO, show_alarm, NULL, 12); | ||
232 | static SENSOR_DEVICE_ATTR(temp2_input_fault, S_IRUGO, show_alarm, NULL, 13); | ||
233 | static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 15); | ||
234 | /* Raw alarm file for compatibility */ | ||
211 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 235 | static 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; |