summaryrefslogtreecommitdiff
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorVikash Chandola <vikash.chandola@intel.com>2022-02-03 13:49:55 +0300
committerVikash Chandola <vikash.chandola@intel.com>2022-02-07 19:03:05 +0300
commit747840ee70ac06bd8e4ebad5d0c0d25009481644 (patch)
tree033fb671e8ca58d4f507ce3f7244d9dfe7583f6f /drivers/hwmon
parent36e4e3fa141e0975347104573a024f1160377808 (diff)
downloadlinux-747840ee70ac06bd8e4ebad5d0c0d25009481644.tar.xz
hwmon: (pmbus) Clear pmbus fault/warning bits before read
pmbus fault and warning bits are not cleared by itself once fault/warning condition is not valid anymore. As per pmbus datasheet faults must be cleared by user. Modify hwmon behavior to clear latched status bytes if any bit in status register is high prior to returning fresh data to userspace. If fault/warning conditions are still applicable fault/warning bits will be set and we will get updated data in second read. Hwmon behavior is changed here. Now sysfs reads will reflect latest values from pmbus slave, not latched values. In case a transient warning/fault has happened in the past, it will no longer be reported to userspace. Signed-off-by: Vikash Chandola <vikash.chandola@intel.com>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/pmbus/pmbus_core.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index a4bf6f0fe013..dbb6f56578bc 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -587,6 +587,15 @@ static int pmbus_get_status(struct i2c_client *client, int page, int reg)
break;
default:
status = _pmbus_read_byte_data(client, page, reg);
+ if (status > 0) {
+ /*
+ * Status greater than 0 could mean that there was a fault/warning.
+ * Clear faults and do a second read to make sure we are not getting
+ * stale values.
+ */
+ pmbus_clear_fault_page(client, page);
+ status = _pmbus_read_byte_data(client, page, reg);
+ }
break;
}
if (status < 0)