]> git.proxmox.com Git - mirror_ubuntu-bionic-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)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 6 Mar 2020 07:13:20 +0000 (02:13 -0500)
commit293a9c7b8c15bfef624bdd8fae2a8a1b6ad7d4d0
tree68ad1a5cb28cfb3226d47adeb58805136d73c6bd
parent19cdeabd639a5a0d6ba0afe0ddc756d5fb7a434a
hwmon: (adt7475) Make volt2reg return same reg as reg2volt input

BugLink: https://bugs.launchpad.net/bugs/1864261
commit cf3ca1877574a306c0207cbf7fdf25419d9229df upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/hwmon/adt7475.c