All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hwmon: (pmbus) Clear pmbus fault/warning bits before read
@ 2022-02-10 12:41 Vikash Chandola
  2022-02-10 14:44 ` Guenter Roeck
  0 siblings, 1 reply; 8+ messages in thread
From: Vikash Chandola @ 2022-02-10 12:41 UTC (permalink / raw)
  To: iwona.winiarska, linux, jdelvare, linux-hwmon, linux-kernel
  Cc: Vikash Chandola

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@linux.intel.com>
---
 drivers/hwmon/pmbus/pmbus_core.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index 776ee2237be2..1cc82d644079 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -577,6 +577,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)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-02-22 13:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-10 12:41 [PATCH] hwmon: (pmbus) Clear pmbus fault/warning bits before read Vikash Chandola
2022-02-10 14:44 ` Guenter Roeck
2022-02-10 15:57   ` Vikash Chandola
2022-02-10 17:25     ` Guenter Roeck
2022-02-10 18:29       ` Vikash Chandola
2022-02-10 19:55         ` Guenter Roeck
2022-02-10 19:57           ` Guenter Roeck
2022-02-22 13:20             ` Vikash Chandola

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.