Message ID | 20250105195521.3263193-2-radian.dc@gmail.com (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | hwmon/adt7470: fix 'fan*_{min,max}', 'temp*_alarm' and add 'temp_fan_norm_alarm' | expand |
On 1/5/25 11:55, Adrian DC wrote: > Tested with the following script and values The patch description is supposed to explain the reason for the changes, not test results. Test results are useful, but only appropriate after "---". Guenter > --- > > { > # 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:
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:
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(-)