hwmon: (w83792d) Implement the standard
PATCH 2/4 hwmon: (w83792d) Implement the standard
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.
--- drivers/hwmon/w83792d.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)
drivers/hwmon/w83792d.c +28 -2
@@ -706,7 +706,7 @@ show_chassis_clear(struct device *dev, s }static ssize_t -store_chassis_clear (struct device *dev,struct device_attribute *attr, +store_chassis_clear_legacy (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) {struct i2c_client *client =to_i2c_client (dev);
@@ -714,6 +714,8 @@ store_chassis_clear(struct device *dev,u32 val;u8 temp1 =0 , temp2 =0 ; +dev_warn (&client->dev,"Attribute chassis_clear is deprecated, " +"use intrusion0_alarm instead\n" ); val =simple_strtoul (buf,NULL ,10 );mutex_lock (&data->update_lock); data->chassis_clear =SENSORS_LIMIT (val,0 ,1 );
@@ -726,6 +728,27 @@ store_chassis_clear(struct device *dev,return count; } +static ssize_t +store_chassis_clear (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) +{ +struct i2c_client *client =to_i2c_client (dev); +struct w83792d_data *data =i2c_get_clientdata (client); +unsigned long val; +u8 reg; + +if (strict_strtoul (buf,10 , &val) || val !=0 ) +return -EINVAL ; + +mutex_lock (&data->update_lock); + reg =w83792d_read_value (client,W83792D_REG_CHASSIS_CLR ); +w83792d_write_value (client,W83792D_REG_CHASSIS_CLR , reg |0x80 ); + data->chassis =0 ; +mutex_unlock (&data->update_lock); + +return count; +} +/* For Smart Fan I / Thermal Cruise */ static ssize_t show_thermal_cruise(struct device *dev, struct device_attribute *attr,
@@ -1012,7 +1035,9 @@ static SENSOR_DEVICE_ATTR(fan5_alarm, S_ static SENSOR_DEVICE_ATTR(fan6_alarm, S_IRUGO, show_alarm, NULL, 23); static DEVICE_ATTR(chassis, S_IRUGO, show_regs_chassis, NULL); static DEVICE_ATTR(chassis_clear, S_IRUGO | S_IWUSR, - show_chassis_clear, store_chassis_clear); + show_chassis_clear, store_chassis_clear_legacy); +static DEVICE_ATTR(intrusion0_alarm, S_IRUGO | S_IWUSR, + show_regs_chassis, store_chassis_clear); static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 0); static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 1); static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 2);
@@ -1214,6 +1239,7 @@ static struct attribute *w83792d_attribu &dev_attr_alarms.attr, &dev_attr_chassis.attr, &dev_attr_chassis_clear.attr, + &dev_attr_intrusion0_alarm.attr, &sensor_dev_attr_tolerance1.dev_attr.attr, &sensor_dev_attr_thermal_cruise1.dev_attr.attr, &sensor_dev_attr_tolerance2.dev_attr.attr,
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 2/4] hwmon: (w83792d) Implement the
Hi Jean,
Quoted 39 lines · Jean Delvare
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 <[email protected]>--- drivers/hwmon/w83792d.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)drivers/hwmon/w83792d.c +9
-1@@ -706,7 +706,7 @@ show_chassis_clear(struct device *dev, s }static ssize_t -store_chassis_clear (struct device *dev,struct device_attribute *attr, +store_chassis_clear_legacy (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) {struct i2c_client *client =to_i2c_client (dev);@@ -714,6 +714,8 @@ store_chassis_clear(struct device *dev,u32 val;u8 temp1 =0 , temp2 =0 ; +dev_warn (&client->dev,"Attribute chassis_clear is deprecated, " +"use intrusion0_alarm instead\n" ); val =simple_strtoul (buf,NULL ,10 );mutex_lock (&data->update_lock); data->chassis_clear =SENSORS_LIMIT (val,0 ,1 );@@ -726,6 +728,27 @@ store_chassis_clear(struct device *dev,return count; } +static ssize_t +store_chassis_clear (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) +{ +struct i2c_client *client =to_i2c_client (dev); +struct w83792d_data *data =i2c_get_clientdata (client);
drivers/hwmon/w83792d.c store_chassis_clear(struct device *dev, · line 746
Quoted 10 lines
drivers/hwmon/w83792d.c +10
-0+unsigned long val; +u8 reg; + +if (strict_strtoul (buf,10 , &val) || val !=0 ) +return -EINVAL ; + +mutex_lock (&data->update_lock); + reg =w83792d_read_value (client,W83792D_REG_CHASSIS_CLR ); +w83792d_write_value (client,W83792D_REG_CHASSIS_CLR , reg |0x80 ); + data->chassis =0 ;
Same as before - you don't really know if the chassis is now closed.
drivers/hwmon/w83792d.c static SENSOR_DEVICE_ATTR(fan5_alarm, S_ · line 1036
Quoted 11 lines
drivers/hwmon/w83792d.c +5
-0+mutex_unlock (&data->update_lock); + +return count; +} +/* For Smart Fan I / Thermal Cruise */ static ssize_t show_thermal_cruise(struct device *dev, struct device_attribute *attr,@@ -1012,7 +1035,9 @@ static SENSOR_DEVICE_ATTR(fan5_alarm, S_ static SENSOR_DEVICE_ATTR(fan6_alarm, S_IRUGO, show_alarm, NULL, 23); static DEVICE_ATTR(chassis, S_IRUGO, show_regs_chassis, NULL);
I think the "chassis" attribute should be deprecated as well.
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Re: [lm-sensors] [PATCH 2/4] hwmon: (w83792d) Implement the
In reply to Jean DelvareQuoted 55 lines · Guenter Roeck
Hi Jean,
Quoted 39 lines · Jean Delvare
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 <[email protected]>--- drivers/hwmon/w83792d.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)drivers/hwmon/w83792d.c +9
-1@@ -706,7 +706,7 @@ show_chassis_clear(struct device *dev, s }static ssize_t -store_chassis_clear (struct device *dev,struct device_attribute *attr, +store_chassis_clear_legacy (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) {struct i2c_client *client =to_i2c_client (dev);@@ -714,6 +714,8 @@ store_chassis_clear(struct device *dev,u32 val;u8 temp1 =0 , temp2 =0 ; +dev_warn (&client->dev,"Attribute chassis_clear is deprecated, " +"use intrusion0_alarm instead\n" ); val =simple_strtoul (buf,NULL ,10 );mutex_lock (&data->update_lock); data->chassis_clear =SENSORS_LIMIT (val,0 ,1 );@@ -726,6 +728,27 @@ store_chassis_clear(struct device *dev,return count; } +static ssize_t +store_chassis_clear (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) +{ +struct i2c_client *client =to_i2c_client (dev); +struct w83792d_data *data =i2c_get_clientdata (client);drivers/hwmon/w83792d.c store_chassis_clear(struct device *dev, · line 746
Quoted 10 lines
drivers/hwmon/w83792d.c +10
-0+unsigned long val; +u8 reg; + +if (strict_strtoul (buf,10 , &val) || val !=0 ) +return -EINVAL ; + +mutex_lock (&data->update_lock); + reg =w83792d_read_value (client,W83792D_REG_CHASSIS_CLR ); +w83792d_write_value (client,W83792D_REG_CHASSIS_CLR , reg |0x80 ); + data->chassis =0 ;Same as before - you don't really know if the chassis is now closed.
Quoted 13 lines
drivers/hwmon/w83792d.c static SENSOR_DEVICE_ATTR(fan5_alarm, S_ · line 1036
Quoted 11 lines
drivers/hwmon/w83792d.c +5
-0+mutex_unlock (&data->update_lock); + +return count; +} +/* For Smart Fan I / Thermal Cruise */ static ssize_t show_thermal_cruise(struct device *dev, struct device_attribute *attr,@@ -1012,7 +1035,9 @@ static SENSOR_DEVICE_ATTR(fan5_alarm, S_ static SENSOR_DEVICE_ATTR(fan6_alarm, S_IRUGO, show_alarm, NULL, 23); static DEVICE_ATTR(chassis, S_IRUGO, show_regs_chassis, NULL);I think the "chassis" attribute should be deprecated as well.
Right. Originally I refrained from doing this, to avoid flooding the kernel log. But given that libsensors 3 never reads this attribute, this may not be a problem in practice. And it's probably better to annoy a user by filling his/her log than by dropping an attribute he/she is using without a notice.
I'll post updated patches soon. Thanks for the review!
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors