From: Adrian DC <radian.dc@gmail.com>
To: Jean Delvare <jdelvare@suse.com>,
Guenter Roeck <linux@roeck-us.net>,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Adrian DC <radian.dc@gmail.com>
Subject: [PATCH 1/3] hwmon/adt7470: allow 'fan*_{min,max}' to be reset to '0'
Date: Sun, 5 Jan 2025 20:55:14 +0100 [thread overview]
Message-ID: <20250105195521.3263193-2-radian.dc@gmail.com> (raw)
In-Reply-To: <20250105195521.3263193-1-radian.dc@gmail.com>
Tested with the following script and values
---
{
# Access hwmon
cd /sys/class/hwmon/hwmon1/
# Set to 1 => 82
echo -n ' [TEST] Set to 1 : '
echo '1' >./fan1_max
cat ./fan1_max
# Set to 1234 => 1234
echo -n ' [TEST] Set to 1234 : '
echo '1234' >./fan1_max
cat ./fan1_max
# Reset to 0 => 0
echo -n ' [TEST] Set to 0 : '
echo '0' >./fan1_max
cat ./fan1_max
}
---
Signed-off-by: Adrian DC <radian.dc@gmail.com>
---
drivers/hwmon/adt7470.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c
index dbee6926fa05..712bc41b4a0d 100644
--- a/drivers/hwmon/adt7470.c
+++ b/drivers/hwmon/adt7470.c
@@ -662,11 +662,15 @@ static int adt7470_fan_write(struct device *dev, u32 attr, int channel, long val
struct adt7470_data *data = dev_get_drvdata(dev);
int err;
- if (val <= 0)
+ if (val < 0)
return -EINVAL;
- val = FAN_RPM_TO_PERIOD(val);
- val = clamp_val(val, 1, 65534);
+ if (val) {
+ val = FAN_RPM_TO_PERIOD(val);
+ val = clamp_val(val, 1, 65534);
+ } else {
+ val = FAN_PERIOD_INVALID;
+ }
switch (attr) {
case hwmon_fan_min:
--
2.43.0
next prev parent reply other threads:[~2025-01-05 19:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-05 19:55 [PATCH 0/3] hwmon/adt7470: fix 'fan*_{min,max}', 'temp*_alarm' and add 'temp_fan_norm_alarm' Adrian DC
2025-01-05 19:55 ` Adrian DC [this message]
2025-01-06 19:02 ` [PATCH 1/3] hwmon/adt7470: allow 'fan*_{min,max}' to be reset to '0' Guenter Roeck
2025-01-05 19:55 ` [PATCH 2/3] hwmon/adt7470: resolve faulty 'temp*_alarm' values read output Adrian DC
2025-01-06 18:59 ` Guenter Roeck
2025-01-05 19:55 ` [PATCH 3/3] hwmon/adt7470: create 'temp_fan_norm_alarm' attribute for 'NORM' alarm Adrian DC
2025-01-06 19:10 ` 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=20250105195521.3263193-2-radian.dc@gmail.com \
--to=radian.dc@gmail.com \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
/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