Skip to content

Commit 75d2b2b

Browse files
awujekgroeck
authored andcommitted
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: 4e5418f ("hwmon: (pmbus_core) Check adapter PEC support") Signed-off-by: Adam Wujek <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent 4aaaaf0 commit 75d2b2b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/hwmon/pmbus/pmbus_core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2326,6 +2326,9 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data,
23262326
data->has_status_word = true;
23272327
}
23282328

2329+
/* Make sure PEC is disabled, will be enabled later if needed */
2330+
client->flags &= ~I2C_CLIENT_PEC;
2331+
23292332
/* Enable PEC if the controller and bus supports it */
23302333
if (!(data->flags & PMBUS_NO_CAPABILITY)) {
23312334
ret = i2c_smbus_read_byte_data(client, PMBUS_CAPABILITY);

0 commit comments

Comments
 (0)