Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: (w83793) Implement the standard intrusion detection interface

We have a standard intrusion detection interface now, drivers should
implement it. I've left the old interface in place for the time being,
with a deprecation warning, it will be removed later.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>

authored by

Jean Delvare and committed by
Jean Delvare
a516dc3e c32301b5

+32 -5
+1 -1
Documentation/hwmon/w83793
··· 92 92 93 93 * Chassis 94 94 If the case open alarm triggers, it will stay in this state unless cleared 95 - by any write to the sysfs file "chassis". 95 + by writing 0 to the sysfs file "intrusion0_alarm". 96 96 97 97 * VID and VRM 98 98 The VRM version is detected automatically, don't modify the it unless you
+31 -4
drivers/hwmon/w83793.c
··· 421 421 422 422 /* Write any value to clear chassis alarm */ 423 423 static ssize_t 424 + store_chassis_clear_legacy(struct device *dev, 425 + struct device_attribute *attr, const char *buf, 426 + size_t count) 427 + { 428 + struct i2c_client *client = to_i2c_client(dev); 429 + struct w83793_data *data = i2c_get_clientdata(client); 430 + u8 val; 431 + 432 + dev_warn(dev, "Attribute chassis is deprecated, " 433 + "use intrusion0_alarm instead\n"); 434 + 435 + mutex_lock(&data->update_lock); 436 + val = w83793_read_value(client, W83793_REG_CLR_CHASSIS); 437 + val |= 0x80; 438 + w83793_write_value(client, W83793_REG_CLR_CHASSIS, val); 439 + mutex_unlock(&data->update_lock); 440 + return count; 441 + } 442 + 443 + /* Write 0 to clear chassis alarm */ 444 + static ssize_t 424 445 store_chassis_clear(struct device *dev, 425 446 struct device_attribute *attr, const char *buf, 426 447 size_t count) 427 448 { 428 449 struct i2c_client *client = to_i2c_client(dev); 429 450 struct w83793_data *data = i2c_get_clientdata(client); 430 - u8 val; 451 + unsigned long val; 452 + u8 reg; 453 + 454 + if (strict_strtoul(buf, 10, &val) || val != 0) 455 + return -EINVAL; 431 456 432 457 mutex_lock(&data->update_lock); 433 - val = w83793_read_value(client, W83793_REG_CLR_CHASSIS); 434 - val |= 0x80; 435 - w83793_write_value(client, W83793_REG_CLR_CHASSIS, val); 458 + reg = w83793_read_value(client, W83793_REG_CLR_CHASSIS); 459 + w83793_write_value(client, W83793_REG_CLR_CHASSIS, reg | 0x80); 460 + data->valid = 0; /* Force cache refresh */ 436 461 mutex_unlock(&data->update_lock); 437 462 return count; 438 463 } ··· 1127 1102 1128 1103 static struct sensor_device_attribute_2 sda_single_files[] = { 1129 1104 SENSOR_ATTR_2(chassis, S_IWUSR | S_IRUGO, show_alarm_beep, 1105 + store_chassis_clear_legacy, ALARM_STATUS, 30), 1106 + SENSOR_ATTR_2(intrusion0_alarm, S_IWUSR | S_IRUGO, show_alarm_beep, 1130 1107 store_chassis_clear, ALARM_STATUS, 30), 1131 1108 SENSOR_ATTR_2(beep_enable, S_IWUSR | S_IRUGO, show_beep_enable, 1132 1109 store_beep_enable, NOT_USED, NOT_USED),