aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Matyas <[email protected]>2023-10-31 20:21:56 +0200
committerGuenter Roeck <[email protected]>2023-12-11 06:42:54 -0800
commit64176bde4645686590bb0e5efcbcd18497ee4389 (patch)
treefc673781cc60b66aa0da4855559392a51040ed2e
parent8a0806df46b62e88793cab0035da477092bda09a (diff)
hwmon: (max31827) Return closest value in update_interval
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]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
-rw-r--r--drivers/hwmon/max31827.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/hwmon/max31827.c b/drivers/hwmon/max31827.c
index 3b38fdf0ebb2..6b7bfacf6f0a 100644
--- a/drivers/hwmon/max31827.c
+++ b/drivers/hwmon/max31827.c
@@ -361,9 +361,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);