Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: linux-hwmon@vger.kernel.org
Cc: Anton Lundin <glance@ac2.se>, Guenter Roeck <linux@roeck-us.net>,
	Sashiko <sashiko-bot@kernel.org>
Subject: [RFT PATCH 3/3] hwmon: (nct6775) Fix tolerance bitmask when reading REG_FAN_MODE
Date: Mon,  9 Nov 2026 19:59:55 -0800	[thread overview]
Message-ID: <20261110035955.3968731-4-linux@roeck-us.net> (raw)
In-Reply-To: <20261110035955.3968731-1-linux@roeck-us.net>

On NCT6775, bits 0..3 of REG_FAN_MODE hold the temperature or fan speed
tolerance (tolerance_mask is 0x0f), whereas on NCT5525, NCT6106,
NCT6116, NCT6126, and NCT6776+, only bits 0..2 hold the temperature
tolerance or low 3 bits of speed tolerance (tolerance_mask is 0x07).
However, nct6775_update_pwm() masks fanmodecfg with a hardcoded 0x0f.

When bit 3 of REG_FAN_MODE is set on chips where tolerance_mask is 0x07,
nct6775_update_pwm() includes bit 3 in temp_tolerance[0] and
target_speed_tolerance, corrupting reported tolerance values and causing
pwm_update_registers() to OR bit 3 back into REG_FAN_MODE.

Mask fanmodecfg with data->tolerance_mask instead of 0x0f in
nct6775_update_pwm().

Fixes: cdcaeceb74ff ("hwmon: (nct6775) Add support for automatic fan control")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev
Cc: Anton Lundin <glance@ac2.se>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/hwmon/nct6775-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/nct6775-core.c b/drivers/hwmon/nct6775-core.c
index 1d63747a2f38..ff7f7468185d 100644
--- a/drivers/hwmon/nct6775-core.c
+++ b/drivers/hwmon/nct6775-core.c
@@ -1510,10 +1510,10 @@ static int nct6775_update_pwm(struct device *dev)
 
 		if (!data->temp_tolerance[0][i] ||
 		    data->pwm_enable[i] != speed_cruise)
-			data->temp_tolerance[0][i] = fanmodecfg & 0x0f;
+			data->temp_tolerance[0][i] = fanmodecfg & data->tolerance_mask;
 		if (!data->target_speed_tolerance[i] ||
 		    data->pwm_enable[i] == speed_cruise) {
-			u8 t = fanmodecfg & 0x0f;
+			u8 t = fanmodecfg & data->tolerance_mask;
 
 			if (data->REG_TOLERANCE_H) {
 				err = nct6775_read_value(data, data->REG_TOLERANCE_H[i], &reg);
-- 
2.45.2


  parent reply	other threads:[~2026-11-10  4:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10  3:59 [RFT PATCH 0/3] hwmon: (nct6775) Fix target temperature and tolerance handling Guenter Roeck
2026-11-10  3:59 ` [RFT PATCH 1/3] hwmon: (nct6775) Fix target temp and tolerance for NCT6106/6116/6126 Guenter Roeck
2026-11-10  4:15   ` sashiko-bot
2026-11-10  5:46     ` Guenter Roeck
2026-11-10  3:59 ` [RFT PATCH 2/3] hwmon: (nct6775) Fix swapped temperature tolerance register writes Guenter Roeck
2026-11-10  4:19   ` sashiko-bot
2026-11-10  3:59 ` Guenter Roeck [this message]
2026-11-10  4:26   ` [RFT PATCH 3/3] hwmon: (nct6775) Fix tolerance bitmask when reading REG_FAN_MODE sashiko-bot

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=20261110035955.3968731-4-linux@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=glance@ac2.se \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=sashiko-bot@kernel.org \
    /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