diff options
author | Jean Delvare <khali@linux-fr.org> | 2011-07-25 15:46:10 -0400 |
---|---|---|
committer | Jean Delvare <khali@endymion.delvare> | 2011-07-25 15:46:10 -0400 |
commit | 3d30f9e69f152d8667b3b13ac6f566e6e76ef7b9 (patch) | |
tree | e4e71eb7a3d824a4c4289b5b81864788a905ddb6 /drivers/hwmon | |
parent | 764e043bb48b6b94f9dec228aedbd8ab08f4708b (diff) |
hwmon: (it87) Add chassis intrusion detection support
Add chassis intrusion detection support for all supported devices,
using the standard interface.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/it87.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index 5f5247750430..d912649fac50 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c | |||
@@ -1172,6 +1172,32 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, | |||
1172 | struct it87_data *data = it87_update_device(dev); | 1172 | struct it87_data *data = it87_update_device(dev); |
1173 | return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1); | 1173 | return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1); |
1174 | } | 1174 | } |
1175 | |||
1176 | static ssize_t clear_intrusion(struct device *dev, struct device_attribute | ||
1177 | *attr, const char *buf, size_t count) | ||
1178 | { | ||
1179 | struct it87_data *data = dev_get_drvdata(dev); | ||
1180 | long val; | ||
1181 | int config; | ||
1182 | |||
1183 | if (strict_strtol(buf, 10, &val) < 0 || val != 0) | ||
1184 | return -EINVAL; | ||
1185 | |||
1186 | mutex_lock(&data->update_lock); | ||
1187 | config = it87_read_value(data, IT87_REG_CONFIG); | ||
1188 | if (config < 0) { | ||
1189 | count = config; | ||
1190 | } else { | ||
1191 | config |= 1 << 5; | ||
1192 | it87_write_value(data, IT87_REG_CONFIG, config); | ||
1193 | /* Invalidate cache to force re-read */ | ||
1194 | data->valid = 0; | ||
1195 | } | ||
1196 | mutex_unlock(&data->update_lock); | ||
1197 | |||
1198 | return count; | ||
1199 | } | ||
1200 | |||
1175 | static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 8); | 1201 | static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 8); |
1176 | static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 9); | 1202 | static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 9); |
1177 | static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 10); | 1203 | static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 10); |
@@ -1188,6 +1214,8 @@ static SENSOR_DEVICE_ATTR(fan5_alarm, S_IRUGO, show_alarm, NULL, 6); | |||
1188 | static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 16); | 1214 | static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 16); |
1189 | static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 17); | 1215 | static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 17); |
1190 | static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 18); | 1216 | static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 18); |
1217 | static SENSOR_DEVICE_ATTR(intrusion0_alarm, S_IRUGO | S_IWUSR, | ||
1218 | show_alarm, clear_intrusion, 4); | ||
1191 | 1219 | ||
1192 | static ssize_t show_beep(struct device *dev, struct device_attribute *attr, | 1220 | static ssize_t show_beep(struct device *dev, struct device_attribute *attr, |
1193 | char *buf) | 1221 | char *buf) |
@@ -1350,6 +1378,7 @@ static struct attribute *it87_attributes[] = { | |||
1350 | &sensor_dev_attr_temp3_alarm.dev_attr.attr, | 1378 | &sensor_dev_attr_temp3_alarm.dev_attr.attr, |
1351 | 1379 | ||
1352 | &dev_attr_alarms.attr, | 1380 | &dev_attr_alarms.attr, |
1381 | &sensor_dev_attr_intrusion0_alarm.dev_attr.attr, | ||
1353 | &dev_attr_name.attr, | 1382 | &dev_attr_name.attr, |
1354 | NULL | 1383 | NULL |
1355 | }; | 1384 | }; |