Commit 64176bde authored by Daniel Matyas's avatar Daniel Matyas Committed by Guenter Roeck

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: default avatarDaniel Matyas <daniel.matyas@analog.com>
Link: https://lore.kernel.org/r/20231031182158.124608-4-daniel.matyas@analog.comSigned-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 8a0806df
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment