Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jared Kangas" <jkangas@redhat.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v2 4/4] hwmon: (ina2xx) Decouple in0 and curr1 alarms
Date: Thu, 20 Aug 2026 13:23:03 +0000	[thread overview]
Message-ID: <20260820132304.2B1BA1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260820-upstream-ina2xx-in0-curr1-alarms-v2-4-fdce35abc41e@redhat.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Writing 0 to an inactive alert limit unintentionally clears the currently active alert, breaking the newly introduced alarm decoupling.
--

--- Patch [4]: [PATCH v2 4/4] hwmon: (ina2xx) Decouple in0 and curr1 alarms ---
commit 0eea1308d1961d2cb0471626855b002f45901d56
Author: Jared Kangas <jkangas@redhat.com>

hwmon: (ina2xx) Decouple in0 and curr1 alarms

This commit attempts to decouple shunt voltage and current limit alarms by
tracking the active alert type and returning zero during reads if the active
alarm is for a different type.

> diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c
> --- a/drivers/hwmon/ina2xx.c
> +++ b/drivers/hwmon/ina2xx.c
[ ... ]
> @@ -484,6 +521,7 @@ static int ina226_alert_limit_write(struct ina2xx_data *data, enum ina2xx_alert_
>  				 INA226_ALERT_CONFIG_MASK, 0);
>  	if (ret < 0)
>  		return ret;
> +	data->active_alert = INA2XX_ALERT_NONE;
>  
>  	ret = regmap_write(regmap, INA226_ALERT_LIMIT,
>  			   ina226_alert_to_reg(data, reg, val));
> @@ -492,9 +530,13 @@ static int ina226_alert_limit_write(struct ina2xx_data *data, enum ina2xx_alert_
>  
>  	if (val) {
>  		mask = ina2xx_alert_type_to_mask(alert);
> -		return regmap_update_bits(regmap, INA226_MASK_ENABLE,
> -					  INA226_ALERT_CONFIG_MASK, mask);
> +		ret = regmap_update_bits(regmap, INA226_MASK_ENABLE,
> +					 INA226_ALERT_CONFIG_MASK, mask);
> +		if (ret < 0)
> +			return ret;
> +		data->active_alert = alert;
>  	}
> +
>  	return 0;
>  }

[Severity: High]
Will this unintentionally disable active alerts if a 0 is written to an
inactive alert?

Because the read side was updated in this patch to return 0 for inactive
alerts, state restoration tools might now read 0 for an inactive alert and
subsequently write 0 back to it during initialization.

When ina226_alert_limit_write() is called with val == 0 for that inactive
alert, the code just before this hunk unconditionally clears the hardware
mask and the newly added line sets data->active_alert = INA2XX_ALERT_NONE.

Since val is 0, the if (val) block is bypassed, leaving all alerts
disabled. This seems to allow writes to an inactive alert to silently
disable the currently active alert.

Does this function need an early return or guard to ignore writes of 0
if the alert being written to is already inactive?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260820-upstream-ina2xx-in0-curr1-alarms-v2-0-fdce35abc41e@redhat.com?part=4

      reply	other threads:[~2026-08-20 13:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-20 13:09 [PATCH v2 0/4] hwmon: (ina2xx) Decouple in0 and curr1 alarms Jared Kangas
2026-08-20 13:09 ` [PATCH v2 1/4] hwmon: (ina2xx) Acquire hwmon_lock in shunt_resistor_show() Jared Kangas
2026-08-20 13:17   ` sashiko-bot
2026-08-20 13:09 ` [PATCH v2 2/4] hwmon: (ina2xx) Parameterize ina2xx_data in ina226_alert_read() Jared Kangas
2026-08-20 13:21   ` sashiko-bot
2026-08-20 13:09 ` [PATCH v2 3/4] hwmon: (ina2xx) Replace masks with enum in alert functions Jared Kangas
2026-08-20 13:17   ` sashiko-bot
2026-08-20 13:09 ` [PATCH v2 4/4] hwmon: (ina2xx) Decouple in0 and curr1 alarms Jared Kangas
2026-08-20 13:23   ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260820132304.2B1BA1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=jkangas@redhat.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox