Commit 3d30f9e69f152d8667b3b13ac6f566e6e76ef7b9

Authored by Jean Delvare
Committed by Jean Delvare
1 parent 764e043bb4

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>

Showing 2 changed files with 31 additions and 1 deletions Side-by-side Diff

Documentation/hwmon/it87
... ... @@ -76,7 +76,8 @@
76 76 These chips are 'Super I/O chips', supporting floppy disks, infrared ports,
77 77 joysticks and other miscellaneous stuff. For hardware monitoring, they
78 78 include an 'environment controller' with 3 temperature sensors, 3 fan
79   -rotation speed sensors, 8 voltage sensors, and associated alarms.
  79 +rotation speed sensors, 8 voltage sensors, associated alarms, and chassis
  80 +intrusion detection.
80 81  
81 82 The IT8712F and IT8716F additionally feature VID inputs, used to report
82 83 the Vcore voltage of the processor. The early IT8712F have 5 VID pins,
drivers/hwmon/it87.c
... ... @@ -1172,6 +1172,32 @@
1172 1172 struct it87_data *data = it87_update_device(dev);
1173 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 1201 static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 8);
1176 1202 static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 9);
1177 1203 static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 10);
... ... @@ -1188,6 +1214,8 @@
1188 1214 static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 16);
1189 1215 static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 17);
1190 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 1220 static ssize_t show_beep(struct device *dev, struct device_attribute *attr,
1193 1221 char *buf)
... ... @@ -1350,6 +1378,7 @@
1350 1378 &sensor_dev_attr_temp3_alarm.dev_attr.attr,
1351 1379  
1352 1380 &dev_attr_alarms.attr,
  1381 + &sensor_dev_attr_intrusion0_alarm.dev_attr.attr,
1353 1382 &dev_attr_name.attr,
1354 1383 NULL
1355 1384 };