mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 04:47:05 +00:00
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 <daniel.matyas@analog.com> Link: https://lore.kernel.org/r/20231031182158.124608-4-daniel.matyas@analog.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
8a0806df46
commit
64176bde46
1 changed files with 2 additions and 3 deletions
|
@ -361,9 +361,8 @@ static int max31827_write(struct device *dev, enum hwmon_sensor_types type,
|
||||||
val < max31827_conversions[res])
|
val < max31827_conversions[res])
|
||||||
res++;
|
res++;
|
||||||
|
|
||||||
if (res == ARRAY_SIZE(max31827_conversions) ||
|
if (res == ARRAY_SIZE(max31827_conversions))
|
||||||
val != max31827_conversions[res])
|
res = ARRAY_SIZE(max31827_conversions) - 1;
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
res = FIELD_PREP(MAX31827_CONFIGURATION_CNV_RATE_MASK,
|
res = FIELD_PREP(MAX31827_CONFIGURATION_CNV_RATE_MASK,
|
||||||
res);
|
res);
|
||||||
|
|
Loading…
Reference in a new issue