All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Cong Nguyen" <congnt264@gmail.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v2 2/2] hwmon: (max6621) fix negative temperature offset and crit readings
Date: Mon, 10 Aug 2026 05:16:55 +0000	[thread overview]
Message-ID: <20260810051655.C2BB81F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <ad0baddbd6163cf73545c8e9273258136718585c.1786334038.git.congnt264@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [Medium] The `hwmon_temp_crit_alarm` read path ignores the `channel` parameter and unconditionally clears global alerts, causing alarms to be misattributed and lost.
--

--- Patch [2]: [PATCH v2 2/2] hwmon: (max6621) fix negative temperature offset and crit readings ---
commit 0116e27b3257c1efaee364113dfc90d35d8fb869
Author: Cong Nguyen <congnt264@gmail.com>

hwmon: (max6621) fix negative temperature offset and crit readings

This commit fixes a bug where negative temperature offsets and critical alerts
were read back as large positive numbers due to missing sign extension. By
casting the register value to s16 before scaling, the read path now preserves
the sign encoded during writes.

> diff --git a/drivers/hwmon/max6621.c b/drivers/hwmon/max6621.c
> index 16a3a61d25326..1a644d7871431 100644
> --- a/drivers/hwmon/max6621.c
> +++ b/drivers/hwmon/max6621.c

[ ... ]

> @@ -254,7 +254,7 @@ max6621_read(struct device *dev, enum hwmon_sensor_types type, u32 attr,
>  			if (ret)
>  				return ret;
>  
> -			*val = regval * 1000L;
> +			*val = (s16)regval * 1000L;
>  
>  			break;
>  		case hwmon_temp_crit_alarm:
>  			/*
>  			 * Set val to zero to recover the case, when reading
>  			 * MAX6621_TEMP_ALERT_CAUSE_REG results in for example
>  			 * MAX6621_ALERT_DIS. Reading will return with error,
>  			 * but in such case alarm should be returned as 0.
>  			 */
>  			*val = 0;
>  			ret = regmap_read(data->regmap,
>  					  MAX6621_TEMP_ALERT_CAUSE_REG,
>  					  &regval);

[ ... ]

>  			if (regval) {
>  				ret = i2c_smbus_write_byte(data->client,
>  						MAX6621_CLEAR_ALERT_REG);
>  				if (ret)
>  					return ret;
>  			}
> 
>  			*val = !!regval;
> 
>  			break;

[Severity: Medium]
This is a pre-existing issue, but does this hwmon_temp_crit_alarm read path
in max6621_read() ignore the channel parameter?

When userspace reads the tempX_crit_alarm sysfs attribute for any channel,
this code reads the global MAX6621_TEMP_ALERT_CAUSE_REG and unconditionally
clears it via MAX6621_CLEAR_ALERT_REG if an alert is active.

Could this result in misattributed alarms where a read on one channel
incorrectly reports an alarm belonging to a different channel, and causes
subsequent reads on other channels to miss their alarms because the global
alert state was already cleared?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/9d3a4f1895a47794bb359a2a32fb1ccd6a15812c.1786334038.git.congnt264@gmail.com?part=2

  reply	other threads:[~2026-08-10  5:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-10  4:27 [PATCH v2 1/2] hwmon: (max6621) fix temperature clamp range Cong Nguyen
2026-08-10  4:28 ` [PATCH v2 2/2] hwmon: (max6621) fix negative temperature offset and crit readings Cong Nguyen
2026-08-10  5:16   ` sashiko-bot [this message]
2026-08-10  6:35     ` Guenter Roeck
2026-08-10 16:26   ` Guenter Roeck
2026-08-10  5:12 ` [PATCH v2 1/2] hwmon: (max6621) fix temperature clamp range sashiko-bot
2026-08-10 16:25 ` Guenter Roeck

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=20260810051655.C2BB81F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=congnt264@gmail.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 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.