diff mbox series

[v2,09/14] hwmon: (ina2xx) Set alert latch

Message ID 20240830010554.1462861-10-linux@roeck-us.net (mailing list archive)
State Accepted
Headers show
Series hwmon: (ina2xx) Cleanup and convert to use with_info API | expand

Commit Message

Guenter Roeck Aug. 30, 2024, 1:05 a.m. UTC
Alerts should only be cleared after reported, not immediately after the
alert condition has been cleared. Set the latch enable bit to keep alerts
latched until the alert register has been read from the chip.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v2: Moved patch after consolidation patch to keep it simple
    Set latch bit once when initializing the chip and keep it active

 drivers/hwmon/ina2xx.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Tzung-Bi Shih Aug. 30, 2024, 12:29 p.m. UTC | #1
On Thu, Aug 29, 2024 at 06:05:49PM -0700, Guenter Roeck wrote:
> Alerts should only be cleared after reported, not immediately after the
> alert condition has been cleared. Set the latch enable bit to keep alerts
> latched until the alert register has been read from the chip.
> 
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
diff mbox series

Patch

diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c
index a9e3b23445b4..98338b7e7437 100644
--- a/drivers/hwmon/ina2xx.c
+++ b/drivers/hwmon/ina2xx.c
@@ -67,6 +67,7 @@ 
 
 #define INA226_READ_AVG(reg)		FIELD_GET(INA226_AVG_RD_MASK, reg)
 
+#define INA226_ALERT_LATCH_ENABLE	BIT(0)
 #define INA226_ALERT_POLARITY		BIT(1)
 
 /* bit number of alert functions in Mask/Enable Register */
@@ -640,8 +641,10 @@  static int ina2xx_init(struct device *dev, struct ina2xx_data *data)
 	if (data->chip == ina226) {
 		bool active_high = device_property_read_bool(dev, "ti,alert-polarity-active-high");
 
-		regmap_update_bits(regmap, INA226_MASK_ENABLE, INA226_ALERT_POLARITY,
-				   FIELD_PREP(INA226_ALERT_POLARITY, active_high));
+		regmap_update_bits(regmap, INA226_MASK_ENABLE,
+				   INA226_ALERT_LATCH_ENABLE | INA226_ALERT_POLARITY,
+				   INA226_ALERT_LATCH_ENABLE |
+						FIELD_PREP(INA226_ALERT_POLARITY, active_high));
 	}
 
 	/*