aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2011-01-12 15:55:10 -0500
committerJean Delvare <khali@endymion.delvare>2011-01-12 15:55:10 -0500
commita516dc3e9b19adbcaa9aeda0100ee8ee2938748a (patch)
treefc4f5427bc90718829dd15434e067382b7d9500d
parentc32301b5957bb77579eb80ff5a84324d34b97346 (diff)
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>
-rw-r--r--Documentation/hwmon/w837932
-rw-r--r--drivers/hwmon/w83793.c33
2 files changed, 31 insertions, 4 deletions
diff --git a/Documentation/hwmon/w83793 b/Documentation/hwmon/w83793
index 51171a83165b..6cc5f639b721 100644
--- a/Documentation/hwmon/w83793
+++ b/Documentation/hwmon/w83793
@@ -92,7 +92,7 @@ This driver implements support for Winbond W83793G/W83793R chips.
92 92
93* Chassis 93* Chassis
94 If the case open alarm triggers, it will stay in this state unless cleared 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* VID and VRM 97* VID and VRM
98 The VRM version is detected automatically, don't modify the it unless you 98 The VRM version is detected automatically, don't modify the it unless you
diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
index 8e540ada47d2..d0c30124c13b 100644
--- a/drivers/hwmon/w83793.c
+++ b/drivers/hwmon/w83793.c
@@ -421,14 +421,17 @@ store_beep_enable(struct device *dev, struct device_attribute *attr,
421 421
422/* Write any value to clear chassis alarm */ 422/* Write any value to clear chassis alarm */
423static ssize_t 423static ssize_t
424store_chassis_clear(struct device *dev, 424store_chassis_clear_legacy(struct device *dev,
425 struct device_attribute *attr, const char *buf, 425 struct device_attribute *attr, const char *buf,
426 size_t count) 426 size_t count)
427{ 427{
428 struct i2c_client *client = to_i2c_client(dev); 428 struct i2c_client *client = to_i2c_client(dev);
429 struct w83793_data *data = i2c_get_clientdata(client); 429 struct w83793_data *data = i2c_get_clientdata(client);
430 u8 val; 430 u8 val;
431 431
432 dev_warn(dev, "Attribute chassis is deprecated, "
433 "use intrusion0_alarm instead\n");
434
432 mutex_lock(&data->update_lock); 435 mutex_lock(&data->update_lock);
433 val = w83793_read_value(client, W83793_REG_CLR_CHASSIS); 436 val = w83793_read_value(client, W83793_REG_CLR_CHASSIS);
434 val |= 0x80; 437 val |= 0x80;
@@ -437,6 +440,28 @@ store_chassis_clear(struct device *dev,
437 return count; 440 return count;
438} 441}
439 442
443/* Write 0 to clear chassis alarm */
444static ssize_t
445store_chassis_clear(struct device *dev,
446 struct device_attribute *attr, const char *buf,
447 size_t count)
448{
449 struct i2c_client *client = to_i2c_client(dev);
450 struct w83793_data *data = i2c_get_clientdata(client);
451 unsigned long val;
452 u8 reg;
453
454 if (strict_strtoul(buf, 10, &val) || val != 0)
455 return -EINVAL;
456
457 mutex_lock(&data->update_lock);
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 */
461 mutex_unlock(&data->update_lock);
462 return count;
463}
464
440#define FAN_INPUT 0 465#define FAN_INPUT 0
441#define FAN_MIN 1 466#define FAN_MIN 1
442static ssize_t 467static ssize_t
@@ -1102,6 +1127,8 @@ static DEVICE_ATTR(vrm, S_IWUSR | S_IRUGO, show_vrm, store_vrm);
1102 1127
1103static struct sensor_device_attribute_2 sda_single_files[] = { 1128static struct sensor_device_attribute_2 sda_single_files[] = {
1104 SENSOR_ATTR_2(chassis, S_IWUSR | S_IRUGO, show_alarm_beep, 1129 SENSOR_ATTR_2(chassis, S_IWUSR | S_IRUGO, show_alarm_beep,
1130 store_chassis_clear_legacy, ALARM_STATUS, 30),
1131 SENSOR_ATTR_2(intrusion0_alarm, S_IWUSR | S_IRUGO, show_alarm_beep,
1105 store_chassis_clear, ALARM_STATUS, 30), 1132 store_chassis_clear, ALARM_STATUS, 30),
1106 SENSOR_ATTR_2(beep_enable, S_IWUSR | S_IRUGO, show_beep_enable, 1133 SENSOR_ATTR_2(beep_enable, S_IWUSR | S_IRUGO, show_beep_enable,
1107 store_beep_enable, NOT_USED, NOT_USED), 1134 store_beep_enable, NOT_USED, NOT_USED),