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/lm63.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/lm63.c')
-rw-r--r-- | drivers/hwmon/lm63.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index 071f0fc6adec..00a50bea7cbd 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * lm63.c - driver for the National Semiconductor LM63 temperature sensor | 2 | * lm63.c - driver for the National Semiconductor LM63 temperature sensor |
3 | * with integrated fan control | 3 | * with integrated fan control |
4 | * Copyright (C) 2004-2005 Jean Delvare <khali@linux-fr.org> | 4 | * Copyright (C) 2004-2006 Jean Delvare <khali@linux-fr.org> |
5 | * Based on the lm90 driver. | 5 | * Based on the lm90 driver. |
6 | * | 6 | * |
7 | * The LM63 is a sensor chip made by National Semiconductor. It measures | 7 | * The LM63 is a sensor chip made by National Semiconductor. It measures |
@@ -330,6 +330,16 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *dummy, | |||
330 | return sprintf(buf, "%u\n", data->alarms); | 330 | return sprintf(buf, "%u\n", data->alarms); |
331 | } | 331 | } |
332 | 332 | ||
333 | static ssize_t show_alarm(struct device *dev, struct device_attribute *devattr, | ||
334 | char *buf) | ||
335 | { | ||
336 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
337 | struct lm63_data *data = lm63_update_device(dev); | ||
338 | int bitnr = attr->index; | ||
339 | |||
340 | return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1); | ||
341 | } | ||
342 | |||
333 | static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); | 343 | static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); |
334 | static SENSOR_DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan, | 344 | static SENSOR_DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan, |
335 | set_fan, 1); | 345 | set_fan, 1); |
@@ -350,6 +360,14 @@ static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp8, NULL, 2); | |||
350 | static DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_temp2_crit_hyst, | 360 | static DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_temp2_crit_hyst, |
351 | set_temp2_crit_hyst); | 361 | set_temp2_crit_hyst); |
352 | 362 | ||
363 | /* Individual alarm files */ | ||
364 | static SENSOR_DEVICE_ATTR(fan1_min_alarm, S_IRUGO, show_alarm, NULL, 0); | ||
365 | static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL, 1); | ||
366 | static SENSOR_DEVICE_ATTR(temp2_input_fault, S_IRUGO, show_alarm, NULL, 2); | ||
367 | static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_alarm, NULL, 3); | ||
368 | static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 4); | ||
369 | static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6); | ||
370 | /* Raw alarm file for compatibility */ | ||
353 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 371 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
354 | 372 | ||
355 | /* | 373 | /* |
@@ -449,6 +467,8 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind) | |||
449 | &sensor_dev_attr_fan1_input.dev_attr); | 467 | &sensor_dev_attr_fan1_input.dev_attr); |
450 | device_create_file(&new_client->dev, | 468 | device_create_file(&new_client->dev, |
451 | &sensor_dev_attr_fan1_min.dev_attr); | 469 | &sensor_dev_attr_fan1_min.dev_attr); |
470 | device_create_file(&new_client->dev, | ||
471 | &sensor_dev_attr_fan1_min_alarm.dev_attr); | ||
452 | } | 472 | } |
453 | device_create_file(&new_client->dev, &dev_attr_pwm1); | 473 | device_create_file(&new_client->dev, &dev_attr_pwm1); |
454 | device_create_file(&new_client->dev, &dev_attr_pwm1_enable); | 474 | device_create_file(&new_client->dev, &dev_attr_pwm1_enable); |
@@ -465,6 +485,17 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind) | |||
465 | device_create_file(&new_client->dev, | 485 | device_create_file(&new_client->dev, |
466 | &sensor_dev_attr_temp2_crit.dev_attr); | 486 | &sensor_dev_attr_temp2_crit.dev_attr); |
467 | device_create_file(&new_client->dev, &dev_attr_temp2_crit_hyst); | 487 | device_create_file(&new_client->dev, &dev_attr_temp2_crit_hyst); |
488 | |||
489 | device_create_file(&new_client->dev, | ||
490 | &sensor_dev_attr_temp2_input_fault.dev_attr); | ||
491 | device_create_file(&new_client->dev, | ||
492 | &sensor_dev_attr_temp2_min_alarm.dev_attr); | ||
493 | device_create_file(&new_client->dev, | ||
494 | &sensor_dev_attr_temp1_max_alarm.dev_attr); | ||
495 | device_create_file(&new_client->dev, | ||
496 | &sensor_dev_attr_temp2_max_alarm.dev_attr); | ||
497 | device_create_file(&new_client->dev, | ||
498 | &sensor_dev_attr_temp2_crit_alarm.dev_attr); | ||
468 | device_create_file(&new_client->dev, &dev_attr_alarms); | 499 | device_create_file(&new_client->dev, &dev_attr_alarms); |
469 | 500 | ||
470 | return 0; | 501 | return 0; |