mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tomasz Bojanowski <tomasz@bojanowski.me>
To: Guenter Roeck <linux@roeck-us.net>
Cc: linux-hwmon@vger.kernel.org,
	Hamza Mahfooz <someguy@effective-light.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] hwmon: (nct6683) Return -EBUSY if a fan curve is no longer supported
Date: Sun, 29 Nov 2026 18:43:05 +0100	[thread overview]
Message-ID: <20261129174305.813063-1-tomasz@bojanowski.me> (raw)

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


             reply	other threads:[~2026-11-29 17:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 17:43 Tomasz Bojanowski [this message]
2026-11-29 18: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=20261129174305.813063-1-tomasz@bojanowski.me \
    --to=tomasz@bojanowski.me \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=rdunlap@infradead.org \
    --cc=skhan@linuxfoundation.org \
    --cc=someguy@effective-light.com \
    /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

all inboxes | Powered by JetHome®