[PATCH 0/4] hwmon: (ina2xx) Decouple in0 and curr1 alarms

Jared Kangas <[email protected]> Wed, 29 Jul 2026 08:42:34 -0700
Newsgroups org.kernel.vger.linux-hwmon,org.kernel.vger.linux-kernel
Message-ID <20260729-upstream-ina2xx-in0-curr1-alarms-v1-0-349f7b2f1df8@redhat.com>
The in0 and curr1 alarms in the ina2xx driver are both based on shunt
voltage in the hardware, which causes unexpected behavior when reading
the two inputs' alarms:

1. Both alarms may read back 1, even though only one is set.

2. The "active" alarm may read back 0 even if the limit was reached due
   to the use of alert latching. If the inactive alarm is read, it
   clears the active alarm, and the alarm may not be set before the next
   read:

        # echo 1800 >curr1_lcrit
        # head {in0,curr1}_lcrit_alarm
        ==> in0_lcrit_alarm <==
        1

        ==> curr1_lcrit_alarm <==
        0

To address this, track the active alarm's type in the driver, and when
reading alarms, return early without polling the hardware if the alarm
being read is inactive.

Some prep work is done in patches 1-3 to simplify the fix in patch 4.

Signed-off-by: Jared Kangas <[email protected]>
---
Jared Kangas (4):
      hwmon: (ina2xx) Replace regmap in ina226_alert_read() with ina2xx_data
      hwmon: (ina2xx) Replace masks with enum in alert functions
      hwmon: (ina2xx) Track active alarm in ina2xx_data
      hwmon: (ina2xx) Return 0 on inactive alarm/limit reads

 drivers/hwmon/ina2xx.c | 148 ++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 122 insertions(+), 26 deletions(-)
---
base-commit: 1590cf0329716306e948a8fc29f1d3ee87d3989f
change-id: 20260724-upstream-ina2xx-in0-curr1-alarms-f85e7d692fdf

Best regards,
-- 
Jared Kangas <[email protected]>