hwmon: (tps23861) fix byte order in current and voltage registers
authorAlexandru Gagniuc <mr.nuke.me@gmail.com>
Thu, 21 Jul 2022 03:22:55 +0000 (22:22 -0500)
committerGuenter Roeck <linux@roeck-us.net>
Thu, 21 Jul 2022 14:18:39 +0000 (07:18 -0700)
commit0eabb1396656f215a5333a9444158b17b0fd3247
treed8051f245aaed268c87f7651b2cdb5041a5384b9
parent3b1ea71faccba3abbf71f9a2510c212e1783b6e1
hwmon: (tps23861) fix byte order in current and voltage registers

Trying to use this driver on a big-endian machine results in garbage
values for voltage and current. The tps23861 registers are little-
endian, and regmap_read_bulk() does not do byte order conversion. Thus
on BE machines, the most significant bytes got modified, and were
trimmed by the VOLTAGE_CURRENT_MASK.

To resolve this use uint16_t values, and convert them to host byte
order using le16_to_cpu(). This results in correct readings on MIPS.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Link: https://lore.kernel.org/r/20220721032255.2850647-1-mr.nuke.me@gmail.com
[groeck: Use __le16 instead of uint16_t]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/tps23861.c