]> git.baikalelectronics.ru Git - kernel.git/commit
hwmon: (pmbus) disable PEC if not enabled
authorAdam Wujek <dev_public@wujek.eu>
Wed, 20 Apr 2022 14:51:25 +0000 (14:51 +0000)
committerGuenter Roeck <linux@roeck-us.net>
Mon, 25 Apr 2022 16:15:20 +0000 (09:15 -0700)
commit6d95fcac48e453e048cb673f0adf5bb50b8f2a37
tree445fbf5e68b97a77275990fafa6213c3fcc88116
parentf0f40760973951868737e2e328b6e02b20120e4b
hwmon: (pmbus) disable PEC if not enabled

Explicitly disable PEC when the client does not support it.
The problematic scenario is the following. A device with enabled PEC
support is up and running and a kernel driver is loaded.
Then the driver is unloaded (or device unbound), the HW device
is reconfigured externally (e.g. by i2cset) to advertise itself as not
supporting PEC. Without a new code, at the second load of the driver
(or bind) the "flags" variable is not updated to avoid PEC usage. As a
consequence the further communication with the device is done with
the PEC enabled, which is wrong and may fail.

The implementation first disable the I2C_CLIENT_PEC flag, then the old
code enable it if needed.

Fixes: 4fa6933f50b9 ("hwmon: (pmbus_core) Check adapter PEC support")
Signed-off-by: Adam Wujek <dev_public@wujek.eu>
Link: https://lore.kernel.org/r/20220420145059.431061-1-dev_public@wujek.eu
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/pmbus/pmbus_core.c