hwmon: (pmbus/adm1275) Fix problems with temperature monitoring on ADM1272
authorGuenter Roeck <linux@roeck-us.net>
Fri, 2 Jun 2023 21:34:47 +0000 (14:34 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Thu, 8 Jun 2023 13:38:48 +0000 (06:38 -0700)
commitb153a0bb4199566abd337119207f82b59a8cd1ca
treeb9d3d4057844fca9f1612fa98927f2e504123fa5
parenta6d80df47ee2c69db99e4f2f8871aa4db154620b
hwmon: (pmbus/adm1275) Fix problems with temperature monitoring on ADM1272

The PMON_CONFIG register on ADM1272 is a 16 bit register. Writing a 8 bit
value into it clears the upper 8 bits of the register, resulting in
unexpected side effects. Fix by writing the 16 bit register value.

Also, it has been reported that temperature readings are sometimes widely
inaccurate, to the point where readings may result in device shutdown due
to errant overtemperature faults. Improve by enabling temperature sampling.

While at it, move the common code for ADM1272 and ADM1278 into a separate
function, and clarify in the error message that an attempt was made to
enable both VOUT and temperature monitoring.

Last but not least, return the error code reported by the underlying I2C
controller and not -ENODEV if updating the PMON_CONFIG register fails.
After all, this does not indicate that the chip is not present, but an
error in the communication with the chip.

Fixes: 4ff0ce227a1e ("hwmon: (pmbus/adm1275) Add support for ADM1272")
Fixes: 9da9c2dc57b2 ("hwmon: (adm1275) enable adm1272 temperature reporting")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20230602213447.3557346-1-linux@roeck-us.net
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/pmbus/adm1275.c