* [PATCH] hwmon: (nct6683) Return -EBUSY if a fan curve is no longer supported
@ 2026-11-29 17:43 Tomasz Bojanowski
2026-11-29 18:25 ` Guenter Roeck
0 siblings, 1 reply; 2+ messages in thread
From: Tomasz Bojanowski @ 2026-11-29 17:43 UTC (permalink / raw)
To: Guenter Roeck
Cc: linux-hwmon, Hamza Mahfooz, Jonathan Corbet, Shuah Khan,
Randy Dunlap, linux-doc, linux-kernel
Before writing a point of a fan curve, the driver checks that it still
supports the curve which is set in the EC. If it does not, nothing is
written, so this is not an I/O error. Return -EBUSY instead of -EIO.
Writing pwmN_auto_channels_temp already returns -EBUSY if its check of the
current temperature source fails.
-EIO is still returned if the EC does not take the new curve. Document
both, and that the check includes whether the curve sets a duty cycle.
Compile tested.
Signed-off-by: Tomasz Bojanowski <tomasz@bojanowski.me>
---
Proposed in: https://lore.kernel.org/linux-hwmon/20261117071645.587863-1-tomasz@bojanowski.me/
I used an AI assistant (Claude Code) during development, including for
the test scripts and for comparing the EC register dumps. I reviewed all
of the changes and take responsibility for them.
Documentation/hwmon/nct6683.rst | 11 ++++++-----
drivers/hwmon/nct6683.c | 2 +-
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/Documentation/hwmon/nct6683.rst b/Documentation/hwmon/nct6683.rst
index 1afdf4788d82..bbed349e03a3 100644
--- a/Documentation/hwmon/nct6683.rst
+++ b/Documentation/hwmon/nct6683.rst
@@ -89,11 +89,12 @@ temperatures and the duty cycles of the curve do not decrease and the
temperatures are at most 127 degrees Celsius; otherwise they are
read-only. They can be written in manual and in automatic mode. In manual
mode, a new curve is used after switching to automatic mode. Writing a
-point returns -EIO if the curve no longer meets these conditions or if the
-EC does not take the new curve. Temperatures are clamped to 0-127 degrees
-Celsius and duty cycles to 0-255, and both to the values of the adjacent
-points, so the points have to be written from point 7 to point 1 to raise
-a curve and from point 1 to point 7 to lower it.
+point returns -EBUSY if the curve no longer sets a duty cycle or no longer
+meets these conditions, and -EIO if the EC does not take the new curve.
+Temperatures are clamped to 0-127 degrees Celsius and duty cycles to
+0-255, and both to the values of the adjacent points, so the points have
+to be written from point 7 to point 1 to raise a curve and from point 1 to
+point 7 to lower it.
pwmN_auto_channels_temp is writable if, when the driver is loaded, the
curve uses a single temperature which can be selected; otherwise it is
diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c
index 36565afe8297..ac47cb9d7691 100644
--- a/drivers/hwmon/nct6683.c
+++ b/drivers/hwmon/nct6683.c
@@ -1342,7 +1342,7 @@ static int nct6687dr_curve_set_point(struct device *dev, int ch, int p,
/* Do not touch a curve which is no longer supported */
if (!nct6687dr_curve_read(data, ch, &old) ||
!nct6687dr_curve_valid(&old)) {
- err = -EIO;
+ err = -EBUSY;
goto unlock;
}
base-commit: 8d0f79f49fb10c9f07fee6720551113272a1812b
--
2.56.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] hwmon: (nct6683) Return -EBUSY if a fan curve is no longer supported
2026-11-29 17:43 [PATCH] hwmon: (nct6683) Return -EBUSY if a fan curve is no longer supported Tomasz Bojanowski
@ 2026-11-29 18:25 ` Guenter Roeck
0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2026-11-29 18:25 UTC (permalink / raw)
To: Tomasz Bojanowski
Cc: linux-hwmon, Hamza Mahfooz, Jonathan Corbet, Shuah Khan,
Randy Dunlap, linux-doc, linux-kernel
On Sun, Nov 29, 2026 at 06:43:05PM +0100, Tomasz Bojanowski wrote:
> Before writing a point of a fan curve, the driver checks that it still
> supports the curve which is set in the EC. If it does not, nothing is
> written, so this is not an I/O error. Return -EBUSY instead of -EIO.
>
> Writing pwmN_auto_channels_temp already returns -EBUSY if its check of the
> current temperature source fails.
>
> -EIO is still returned if the EC does not take the new curve. Document
> both, and that the check includes whether the curve sets a duty cycle.
>
> Compile tested.
>
> Signed-off-by: Tomasz Bojanowski <tomasz@bojanowski.me>
Applied.
On a side note, I tested the recent changes on boards with
NCT6683_CUSTOMER_ID_MSI3 (MAG B650M MORTAR WIFI (MS-7D76) and MAG B650
TOMAHAWK WIFI (MS-7D75)). This is what I get on the Tomahawk board:
pwm1:87
pwm1_auto_channels_temp:1
pwm1_auto_point1_pwm:51
pwm1_auto_point1_temp:0
pwm1_auto_point2_pwm:89
pwm1_auto_point2_temp:45000
pwm1_auto_point3_pwm:178
pwm1_auto_point3_temp:65000
pwm1_auto_point4_pwm:255
pwm1_auto_point4_temp:80000
pwm1_auto_point5_pwm:255
pwm1_auto_point5_temp:80000
pwm1_auto_point6_pwm:255
pwm1_auto_point6_temp:80000
pwm1_auto_point7_pwm:255
pwm1_auto_point7_temp:80000
pwm1_enable:2
pwm1_step_down_time:100
pwm1_step_up_time:100
pwm2:255
pwm2_auto_channels_temp:1
pwm2_auto_point1_pwm:255
pwm2_auto_point1_temp:32000
pwm2_auto_point2_pwm:255
pwm2_auto_point2_temp:32000
pwm2_auto_point3_pwm:255
pwm2_auto_point3_temp:32000
pwm2_auto_point4_pwm:255
pwm2_auto_point4_temp:32000
pwm2_auto_point5_pwm:255
pwm2_auto_point5_temp:32000
pwm2_auto_point6_pwm:255
pwm2_auto_point6_temp:32000
pwm2_auto_point7_pwm:255
pwm2_auto_point7_temp:32000
pwm2_enable:2
pwm2_step_down_time:100
pwm2_step_up_time:100
pwm3:87
pwm4:153
pwm5:79
pwm6:153
pwm7:153
pwm8:97
and:
fan10_input:0
fan10_min:0
fan10_pulses:2
fan1_input:825
fan1_min:0
fan1_pulses:2
fan2_input:0
fan2_min:0
fan2_pulses:2
fan3_input:775
fan3_min:0
fan3_pulses:2
fan4_input:0
fan4_min:0
fan4_pulses:2
fan5_input:707
fan5_min:0
fan5_pulses:2
fan6_input:0
fan6_min:0
fan6_pulses:2
fan7_input:0
fan7_min:0
fan7_pulses:2
fan8_input:598
fan8_min:0
fan8_pulses:2
fan9_input:0
fan9_min:0
fan9_pulses:2
On the Mortar board a fan is connected to pwm2/fan2, so the data for that
channel works as expected.
pwm control is enabled on all fans. I don't know if that means that pwm3+
have a different register set. Either case, I figured that it would be too
risky to enable pwm control for these boards; I just wanted to let you
know.
Thanks,
Guenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-29 18:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-29 17:43 [PATCH] hwmon: (nct6683) Return -EBUSY if a fan curve is no longer supported Tomasz Bojanowski
2026-11-29 18:25 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®