]> git.baikalelectronics.ru Git - kernel.git/commit
hwmon: (adt7475) Make volt2reg return same reg as reg2volt input
authorLuuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
Thu, 5 Dec 2019 23:16:59 +0000 (12:16 +1300)
committerGuenter Roeck <linux@roeck-us.net>
Fri, 17 Jan 2020 15:56:48 +0000 (07:56 -0800)
commitbf28ed72f6318b488b7ec1ae66ffb058569c7531
tree9a0c1dff0f2b07324774ab6f010256e3bd6e87cb
parentecc571876e443527a4578aa63726a2658e1735e0
hwmon: (adt7475) Make volt2reg return same reg as reg2volt input

reg2volt returns the voltage that matches a given register value.
Converting this back the other way with volt2reg didn't return the same
register value because it used truncation instead of rounding.

This meant that values read from sysfs could not be written back to sysfs
to set back the same register value.

With this change, volt2reg will return the same value for every voltage
previously returned by reg2volt (for the set of possible input values)

Signed-off-by: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20191205231659.1301-1-luuk.paulussen@alliedtelesis.co.nz
cc: stable@vger.kernel.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/adt7475.c