[PATCH 1/5] hwmon: (pmbus/core) fix regulator enable/disable
Nuno Sá via B4 Relay <[email protected]> Tue, 28 Jul 2026 17:03:48 +0100
| Newsgroups | org.kernel.vger.linux-hwmon,org.kernel.feeds.b4-sent,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-doc |
|---|---|
| Message-ID | <[email protected]> |
From: Nuno Sá <[email protected]> pmbus_update_byte_data() can return the value of PMBUS_OPERATION which can be different than 0 and that can mess with the regulator core given _regulator_disable() explicitly checks for ret == 0 in order to call _regulator_handle_consumer_disable(). Fixes: ddbb4db4ced1 ("hwmon: (pmbus) Add regulator support") Signed-off-by: Nuno Sá <[email protected]> --- drivers/hwmon/pmbus/pmbus_core.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 0081f16c3a95..7b58f7198574 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -3100,12 +3100,21 @@ static int _pmbus_regulator_on_off(struct regulator_dev *rdev, bool enable) struct device *dev = rdev_get_dev(rdev); struct i2c_client *client = to_i2c_client(dev->parent); u8 page = rdev_get_id(rdev); + int rv; guard(pmbus_lock)(client); + /* + * pmbus_update_byte_data() can just return the value of + * PMBUS_OPERATION and that's not what we want to return to the + * regulator core. + */ + rv = pmbus_update_byte_data(client, page, PMBUS_OPERATION, + PB_OPERATION_CONTROL_ON, + enable ? PB_OPERATION_CONTROL_ON : 0); + if (rv < 0) + return rv; - return pmbus_update_byte_data(client, page, PMBUS_OPERATION, - PB_OPERATION_CONTROL_ON, - enable ? PB_OPERATION_CONTROL_ON : 0); + return 0; } static int pmbus_regulator_enable(struct regulator_dev *rdev) -- 2.55.0