When user writes a value to update_interval which does not match the
possible values, instead of returning invalid error, return the closest
value.
Signed-off-by: Daniel Matyas <[email protected]>
---
v6: Added patch.
drivers/hwmon/max31827.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/hwmon/max31827.c b/drivers/hwmon/max31827.c
index 41e4f716605a..13ebe691475a 100644
--- a/drivers/hwmon/max31827.c
+++ b/drivers/hwmon/max31827.c
@@ -360,9 +360,8 @@ static int max31827_write(struct device *dev, enum hwmon_sensor_types type,
val < max31827_conversions[res])
res++;
- if (res == ARRAY_SIZE(max31827_conversions) ||
- val != max31827_conversions[res])
- return -EINVAL;
+ if (res == ARRAY_SIZE(max31827_conversions))
+ res = ARRAY_SIZE(max31827_conversions) - 1;
res = FIELD_PREP(MAX31827_CONFIGURATION_CNV_RATE_MASK,
res);
--
2.34.1