hwmon: (ina238) Simplify voltage register accesses
authorGuenter Roeck <linux@roeck-us.net>
Sun, 31 Aug 2025 04:48:29 +0000 (21:48 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Sun, 7 Sep 2025 23:34:29 +0000 (16:34 -0700)
commit7e420b6a274206f339fe3617943ba1ef9dd1fcb0
tree2ba2907ceaf868ea3625e569c67917ce078b7207
parent4a4fcd611295af96af51574b31f9e19e7505f965
hwmon: (ina238) Simplify voltage register accesses

Calculate voltage LSB values in the probe function and use throughout
the code.

Use a single function to read all voltages, independently of the register
width. Use the pre-calculated LSB values to convert register values to
voltages and do not rely on runtime chip specific code.

Use ROUND_CLOSEST functions instead of divide operations to reduce
rounding errors.

Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Tested-by: Chris Packham <chris.packham@alliedtelesis.co.nz> # INA780
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/ina238.c