aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2011-01-12 15:55:09 -0500
committerJean Delvare <khali@endymion.delvare>2011-01-12 15:55:09 -0500
commitc32301b5957bb77579eb80ff5a84324d34b97346 (patch)
tree6c37d1b19ba0693759cfc736146c32e31f097917
parent0de2b244800b2c0d88d0a85bbe4a0b95fee13332 (diff)
hwmon: (w83792d) 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--drivers/hwmon/w83792d.c44
1 files changed, 41 insertions, 3 deletions
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c
index 679718e6b017..63841f8cec07 100644
--- a/drivers/hwmon/w83792d.c
+++ b/drivers/hwmon/w83792d.c
@@ -691,7 +691,7 @@ store_pwm_mode(struct device *dev, struct device_attribute *attr,
691} 691}
692 692
693static ssize_t 693static ssize_t
694show_regs_chassis(struct device *dev, struct device_attribute *attr, 694show_chassis(struct device *dev, struct device_attribute *attr,
695 char *buf) 695 char *buf)
696{ 696{
697 struct w83792d_data *data = w83792d_update_device(dev); 697 struct w83792d_data *data = w83792d_update_device(dev);
@@ -699,6 +699,16 @@ show_regs_chassis(struct device *dev, struct device_attribute *attr,
699} 699}
700 700
701static ssize_t 701static ssize_t
702show_regs_chassis(struct device *dev, struct device_attribute *attr,
703 char *buf)
704{
705 dev_warn(dev,
706 "Attribute %s is deprecated, use intrusion0_alarm instead\n",
707 "chassis");
708 return show_chassis(dev, attr, buf);
709}
710
711static ssize_t
702show_chassis_clear(struct device *dev, struct device_attribute *attr, char *buf) 712show_chassis_clear(struct device *dev, struct device_attribute *attr, char *buf)
703{ 713{
704 struct w83792d_data *data = w83792d_update_device(dev); 714 struct w83792d_data *data = w83792d_update_device(dev);
@@ -706,7 +716,7 @@ show_chassis_clear(struct device *dev, struct device_attribute *attr, char *buf)
706} 716}
707 717
708static ssize_t 718static ssize_t
709store_chassis_clear(struct device *dev, struct device_attribute *attr, 719store_chassis_clear_legacy(struct device *dev, struct device_attribute *attr,
710 const char *buf, size_t count) 720 const char *buf, size_t count)
711{ 721{
712 struct i2c_client *client = to_i2c_client(dev); 722 struct i2c_client *client = to_i2c_client(dev);
@@ -714,6 +724,10 @@ store_chassis_clear(struct device *dev, struct device_attribute *attr,
714 u32 val; 724 u32 val;
715 u8 temp1 = 0, temp2 = 0; 725 u8 temp1 = 0, temp2 = 0;
716 726
727 dev_warn(dev,
728 "Attribute %s is deprecated, use intrusion0_alarm instead\n",
729 "chassis_clear");
730
717 val = simple_strtoul(buf, NULL, 10); 731 val = simple_strtoul(buf, NULL, 10);
718 mutex_lock(&data->update_lock); 732 mutex_lock(&data->update_lock);
719 data->chassis_clear = SENSORS_LIMIT(val, 0 ,1); 733 data->chassis_clear = SENSORS_LIMIT(val, 0 ,1);
@@ -726,6 +740,27 @@ store_chassis_clear(struct device *dev, struct device_attribute *attr,
726 return count; 740 return count;
727} 741}
728 742
743static ssize_t
744store_chassis_clear(struct device *dev, struct device_attribute *attr,
745 const char *buf, size_t count)
746{
747 struct i2c_client *client = to_i2c_client(dev);
748 struct w83792d_data *data = i2c_get_clientdata(client);
749 unsigned long val;
750 u8 reg;
751
752 if (strict_strtoul(buf, 10, &val) || val != 0)
753 return -EINVAL;
754
755 mutex_lock(&data->update_lock);
756 reg = w83792d_read_value(client, W83792D_REG_CHASSIS_CLR);
757 w83792d_write_value(client, W83792D_REG_CHASSIS_CLR, reg | 0x80);
758 data->valid = 0; /* Force cache refresh */
759 mutex_unlock(&data->update_lock);
760
761 return count;
762}
763
729/* For Smart Fan I / Thermal Cruise */ 764/* For Smart Fan I / Thermal Cruise */
730static ssize_t 765static ssize_t
731show_thermal_cruise(struct device *dev, struct device_attribute *attr, 766show_thermal_cruise(struct device *dev, struct device_attribute *attr,
@@ -1012,7 +1047,9 @@ static SENSOR_DEVICE_ATTR(fan5_alarm, S_IRUGO, show_alarm, NULL, 22);
1012static SENSOR_DEVICE_ATTR(fan6_alarm, S_IRUGO, show_alarm, NULL, 23); 1047static SENSOR_DEVICE_ATTR(fan6_alarm, S_IRUGO, show_alarm, NULL, 23);
1013static DEVICE_ATTR(chassis, S_IRUGO, show_regs_chassis, NULL); 1048static DEVICE_ATTR(chassis, S_IRUGO, show_regs_chassis, NULL);
1014static DEVICE_ATTR(chassis_clear, S_IRUGO | S_IWUSR, 1049static DEVICE_ATTR(chassis_clear, S_IRUGO | S_IWUSR,
1015 show_chassis_clear, store_chassis_clear); 1050 show_chassis_clear, store_chassis_clear_legacy);
1051static DEVICE_ATTR(intrusion0_alarm, S_IRUGO | S_IWUSR,
1052 show_chassis, store_chassis_clear);
1016static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 0); 1053static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 0);
1017static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 1); 1054static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 1);
1018static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 2); 1055static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 2);
@@ -1214,6 +1251,7 @@ static struct attribute *w83792d_attributes[] = {
1214 &dev_attr_alarms.attr, 1251 &dev_attr_alarms.attr,
1215 &dev_attr_chassis.attr, 1252 &dev_attr_chassis.attr,
1216 &dev_attr_chassis_clear.attr, 1253 &dev_attr_chassis_clear.attr,
1254 &dev_attr_intrusion0_alarm.attr,
1217 &sensor_dev_attr_tolerance1.dev_attr.attr, 1255 &sensor_dev_attr_tolerance1.dev_attr.attr,
1218 &sensor_dev_attr_thermal_cruise1.dev_attr.attr, 1256 &sensor_dev_attr_thermal_cruise1.dev_attr.attr,
1219 &sensor_dev_attr_tolerance2.dev_attr.attr, 1257 &sensor_dev_attr_tolerance2.dev_attr.attr,