[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250105195521.3263193-2-radian.dc@gmail.com>
Date: Sun, 5 Jan 2025 20:55:14 +0100
From: Adrian DC <radian.dc@...il.com>
To: Jean Delvare <jdelvare@...e.com>,
Guenter Roeck <linux@...ck-us.net>,
linux-hwmon@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Adrian DC <radian.dc@...il.com>
Subject: [PATCH 1/3] hwmon/adt7470: allow 'fan*_{min,max}' to be reset to '0'
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@...il.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
Powered by blists - more mailing lists