hwmon: (it87) Add chassis intrusion detection
Subsystems (2)
PATCH 1/1 hwmon: (it87) Add chassis intrusion detection
Add chassis intrusion detection support for all supported devices, using the standard interface.
---
This needs testing! The only report I have so far, says that reporting works OK but clearing the intrusion alarm does not. That case is still under investigation, as my code follows the datasheet as far as I can see, so I have no idea why it wouldn't work.
it87.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
drivers/hwmon/it87.c +29 -0
@@ -1172,6 +1172,32 @@ static ssize_t show_alarm(struct devicestruct it87_data *data =it87_update_device (dev);return sprintf (buf,"%u\n" , (data->alarms >> bitnr) &1 ); } + +static ssize_t clear_intrusion (struct device *dev,struct device_attribute + *attr,const char *buf,size_t count) +{ +struct it87_data *data =dev_get_drvdata (dev); +long val; +int config; + +if (strict_strtol (buf,10 , &val) <0 || val !=0 ) +return -EINVAL ; + +mutex_lock (&data->update_lock); + config =it87_read_value (data,IT87_REG_CONFIG ); +if (config <0 ) + count = config; +else { + config |=1 <<5 ; +it87_write_value (data,IT87_REG_CONFIG , config); +/* Invalidate cache to force re-read */ + data->valid =0 ; + } +mutex_unlock (&data->update_lock); + +return count; +} + static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 8); static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 9); static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 10);
@@ -1188,6 +1214,8 @@ static SENSOR_DEVICE_ATTR(fan5_alarm, S_ static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 16); static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 17); static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 18); +static SENSOR_DEVICE_ATTR(intrusion0_alarm, S_IRUGO | S_IWUSR, + show_alarm, clear_intrusion, 4);static ssize_t show_beep (struct device *dev,struct device_attribute *attr,char *buf)
@@ -1350,6 +1378,7 @@ static struct attribute *it87_attributes &sensor_dev_attr_temp3_alarm.dev_attr.attr, &dev_attr_alarms.attr, + &sensor_dev_attr_intrusion0_alarm.dev_attr.attr, &dev_attr_name.attr, NULL };
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH] hwmon: (it87) Add chassis intrusion
Quoted 30 lines · Jean Delvare
Add chassis intrusion detection support for all supported devices, using the standard interface.
Signed-off-by Jean Delvare <[email protected]>---
This needs testing! The only report I have so far, says that reporting works OK but clearing the intrusion alarm does not. That case is still under investigation, as my code follows the datasheet as far as I can see, so I have no idea why it wouldn't work.it87.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)drivers/hwmon/it87.c +11
-0@@ -1172,6 +1172,32 @@ static ssize_t show_alarm(struct devicestruct it87_data *data =it87_update_device (dev);return sprintf (buf,"%u\n" , (data->alarms >> bitnr) &1 ); } + +static ssize_t clear_intrusion (struct device *dev,struct device_attribute + *attr,const char *buf,size_t count) +{ +struct it87_data *data =dev_get_drvdata (dev); +long val; +int config; + +if (strict_strtol (buf,10 , &val) <0 || val !=0 ) +return -EINVAL ; +
drivers/hwmon/it87.c static ssize_t show_alarm(struct device · line 1195
Quoted 10 lines
drivers/hwmon/it87.c +10
-0+mutex_lock (&data->update_lock); + config =it87_read_value (data,IT87_REG_CONFIG ); +if (config <0 ) + count = config; +else { + config |=1 <<5 ; +it87_write_value (data,IT87_REG_CONFIG , config); +/* Invalidate cache to force re-read */ + data->valid =0 ; + }
If you use { } for the else branch, you should use { } for the if branch as well.
Other than that, difficult to say why it would not work. The datasheet I have access to agrees with your code. Maybe it works differently for different chips ?
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH] hwmon: (it87) Add chassis intrusion
In reply to Jean DelvareHi Guenter,
Quoted 35 lines · Guenter Roeck
Quoted 34 lines · Jean Delvare
Add chassis intrusion detection support for all supported devices, using the standard interface.
Signed-off-by Jean Delvare <[email protected]>---
This needs testing! The only report I have so far, says that reporting works OK but clearing the intrusion alarm does not. That case is still under investigation, as my code follows the datasheet as far as I can see, so I have no idea why it wouldn't work.it87.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)drivers/hwmon/it87.c +15
-0@@ -1172,6 +1172,32 @@ static ssize_t show_alarm(struct devicestruct it87_data *data =it87_update_device (dev);return sprintf (buf,"%u\n" , (data->alarms >> bitnr) &1 ); } + +static ssize_t clear_intrusion (struct device *dev,struct device_attribute + *attr,const char *buf,size_t count) +{ +struct it87_data *data =dev_get_drvdata (dev); +long val; +int config; + +if (strict_strtol (buf,10 , &val) <0 || val !=0 ) +return -EINVAL ; + +mutex_lock (&data->update_lock); + config =it87_read_value (data,IT87_REG_CONFIG ); +if (config <0 ) + count = config;
Quoted 8 lines
drivers/hwmon/it87.c static ssize_t show_alarm(struct device · line 1195
Quoted 6 lines
drivers/hwmon/it87.c +6
-0+else { + config |=1 <<5 ; +it87_write_value (data,IT87_REG_CONFIG , config); +/* Invalidate cache to force re-read */ + data->valid =0 ; + }If you use { } for the else branch, you should use { } for the if branch as well.
checkpatch.pl says that I can, not that I have to. But I will if that makes you happy...
Quoted 3 lines
Other than that, difficult to say why it would not work. The datasheet I have access to agrees with your code. Maybe it works differently for different chips ?
I had one success report by now, so I'll push the patch to Linus. As testing coverage increases, we'll see if there's a pattern amongst failure cases.
Thanks for the review.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH] hwmon: (it87) Add chassis intrusion
In reply to Jean DelvareQuoted 47 lines · Jean Delvare
Hi Guenter,
Quoted 35 lines · Guenter Roeck
Quoted 34 lines · Jean Delvare
Add chassis intrusion detection support for all supported devices, using the standard interface.
Signed-off-by Jean Delvare <[email protected]>---
This needs testing! The only report I have so far, says that reporting works OK but clearing the intrusion alarm does not. That case is still under investigation, as my code follows the datasheet as far as I can see, so I have no idea why it wouldn't work.it87.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)drivers/hwmon/it87.c +15
-0@@ -1172,6 +1172,32 @@ static ssize_t show_alarm(struct devicestruct it87_data *data =it87_update_device (dev);return sprintf (buf,"%u\n" , (data->alarms >> bitnr) &1 ); } + +static ssize_t clear_intrusion (struct device *dev,struct device_attribute + *attr,const char *buf,size_t count) +{ +struct it87_data *data =dev_get_drvdata (dev); +long val; +int config; + +if (strict_strtol (buf,10 , &val) <0 || val !=0 ) +return -EINVAL ; + +mutex_lock (&data->update_lock); + config =it87_read_value (data,IT87_REG_CONFIG ); +if (config <0 ) + count = config;Quoted 8 lines
drivers/hwmon/it87.c static ssize_t show_alarm(struct device · line 1195
Quoted 6 lines
drivers/hwmon/it87.c +6
-0+else { + config |=1 <<5 ; +it87_write_value (data,IT87_REG_CONFIG , config); +/* Invalidate cache to force re-read */ + data->valid =0 ; + }If you use { } for the else branch, you should use { } for the if branch as well.
Quoted 3 lines
checkpatch.pl says that I can, not that I have to. But I will if that makes you happy...
Hi Jean,
mentioned in CodingStyle, really.
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors