Add individual alarm files to 4 drivers
Subsystems (4)
PATCH 1/1 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-agnostic libsensors. Almost all other hwmon drivers will need the same improvement.
Signed-off-by Jean Delvare <khali at linux-fr.org>
--- drivers/hwmon/f71805f.c | 46 ++++++++++++++++++++++++++++++++++---------- drivers/hwmon/lm63.c | 33 +++++++++++++++++++++++++++++++- drivers/hwmon/lm83.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++- drivers/hwmon/lm90.c | 37 ++++++++++++++++++++++++++++++++++- 4 files changed, 151 insertions(+), 14 deletions(-)
drivers/hwmon/lm90.c +36 -1
@@ -1,7 +1,7 @@/* * lm90.c - Part of lm_sensors, Linux kernel modules for hardware * monitoring -* Copyright (C) 2003-2005 Jean Delvare <khali at linux-fr.org> +* Copyright (C) 2003-2006 Jean Delvare <khali at linux-fr.org> * * Based on the lm83 driver. The LM90 is a sensor chip made by National * Semiconductor. It reports up to two temperatures (its own plus up to
@@ -327,6 +327,16 @@return sprintf (buf,"%d\n" , data->alarms); } +static ssize_t show_alarm (struct device *dev,struct device_attribute + *devattr,char *buf) +{ +struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr); +struct lm90_data *data =lm90_update_device (dev); +int bitnr = attr->index; + +return sprintf (buf,"%d\n" , (data->alarms >> bitnr) &1 ); +} + static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp8, NULL, 0); static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp11, NULL, 0); static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp8,
@@ -344,6 +354,16 @@ static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temphyst, set_temphyst, 3); static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temphyst, NULL, 4); + +/* Individual alarm files */ +static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 0); +static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL, 1); +static SENSOR_DEVICE_ATTR(temp2_input_fault, S_IRUGO, show_alarm, NULL, 2); +static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_alarm, NULL, 3); +static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 4); +static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, 5); +static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6); +/* Raw alarm file for compatibility */ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);/* pec used for ADM1032 only */
@@ -595,6 +615,21 @@ &sensor_dev_attr_temp1_crit_hyst.dev_attr);device_create_file (&new_client->dev, &sensor_dev_attr_temp2_crit_hyst.dev_attr); + +device_create_file (&new_client->dev, + &sensor_dev_attr_temp2_input_fault.dev_attr); +device_create_file (&new_client->dev, + &sensor_dev_attr_temp1_min_alarm.dev_attr); +device_create_file (&new_client->dev, + &sensor_dev_attr_temp2_min_alarm.dev_attr); +device_create_file (&new_client->dev, + &sensor_dev_attr_temp1_max_alarm.dev_attr); +device_create_file (&new_client->dev, + &sensor_dev_attr_temp2_max_alarm.dev_attr); +device_create_file (&new_client->dev, + &sensor_dev_attr_temp1_crit_alarm.dev_attr); +device_create_file (&new_client->dev, + &sensor_dev_attr_temp2_crit_alarm.dev_attr);device_create_file (&new_client->dev, &dev_attr_alarms);if (new_client->flags &I2C_CLIENT_PEC )
drivers/hwmon/f71805f.c +35 -11
106 lines not on this page · raw message
drivers/hwmon/lm63.c +32 -1
@@ -1,7 +1,7 @@/* * lm63.c - driver for the National Semiconductor LM63 temperature sensor * with integrated fan control -* Copyright (C) 2004-2005 Jean Delvare <khali at linux-fr.org> +* Copyright (C) 2004-2006 Jean Delvare <khali at linux-fr.org> * Based on the lm90 driver. * * The LM63 is a sensor chip made by National Semiconductor. It measures
@@ -330,6 +330,16 @@return sprintf (buf,"%u\n" , data->alarms); } +static ssize_t show_alarm (struct device *dev,struct device_attribute *devattr, +char *buf) +{ +struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr); +struct lm63_data *data =lm63_update_device (dev); +int bitnr = attr->index; + +return sprintf (buf,"%u\n" , (data->alarms >> bitnr) &1 ); +} + static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); static SENSOR_DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan, set_fan, 1);
@@ -350,6 +360,14 @@ static DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_temp2_crit_hyst, set_temp2_crit_hyst); +/* Individual alarm files */ +static SENSOR_DEVICE_ATTR(fan1_min_alarm, S_IRUGO, show_alarm, NULL, 0); +static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL, 1); +static SENSOR_DEVICE_ATTR(temp2_input_fault, S_IRUGO, show_alarm, NULL, 2); +static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_alarm, NULL, 3); +static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 4); +static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6); +/* Raw alarm file for compatibility */ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);/*
@@ -449,6 +467,8 @@ &sensor_dev_attr_fan1_input.dev_attr);device_create_file (&new_client->dev, &sensor_dev_attr_fan1_min.dev_attr); +device_create_file (&new_client->dev, + &sensor_dev_attr_fan1_min_alarm.dev_attr); }device_create_file (&new_client->dev, &dev_attr_pwm1);device_create_file (&new_client->dev, &dev_attr_pwm1_enable);
@@ -465,6 +485,17 @@device_create_file (&new_client->dev, &sensor_dev_attr_temp2_crit.dev_attr);device_create_file (&new_client->dev, &dev_attr_temp2_crit_hyst); + +device_create_file (&new_client->dev, + &sensor_dev_attr_temp2_input_fault.dev_attr); +device_create_file (&new_client->dev, + &sensor_dev_attr_temp2_min_alarm.dev_attr); +device_create_file (&new_client->dev, + &sensor_dev_attr_temp1_max_alarm.dev_attr); +device_create_file (&new_client->dev, + &sensor_dev_attr_temp2_max_alarm.dev_attr); +device_create_file (&new_client->dev, + &sensor_dev_attr_temp2_crit_alarm.dev_attr);device_create_file (&new_client->dev, &dev_attr_alarms);return 0 ;
drivers/hwmon/lm83.c +48 -1
79 lines not on this page · raw message
Signature · 1 line
Jean Delvare