From nobody Mon May 11 00:10:32 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33F44C433FE for ; Wed, 20 Apr 2022 12:54:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378653AbiDTM5l (ORCPT ); Wed, 20 Apr 2022 08:57:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378647AbiDTM5h (ORCPT ); Wed, 20 Apr 2022 08:57:37 -0400 Received: from mail-4022.proton.ch (mail-4022.proton.ch [185.70.40.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 126FD110D for ; Wed, 20 Apr 2022 05:54:49 -0700 (PDT) Date: Wed, 20 Apr 2022 12:54:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wujek.eu; s=protonmail2; t=1650459287; bh=+8+1bERFEDfD5DtGG4zF7lQrC6F4hcnI/ewNHOmoNj0=; h=Date:From:Cc:Reply-To:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID; b=YyvXWSC85ziVaPQu9qzlDAZ35WqHJsiHTHMHdIgtN2rLAnHp1XP44of/2L04KCi1v sEAp5fAX0TN9p9Di02WpohaHw/R2G4Jti+95BADe5Im7jBwfv9tIJWN/WAlmxFW7L9 Bpx9yoNgqNbrp4PS7Ui9/xHwVYGyX/7SniYSvQzJmNW9Y7rO0Xf3oAKzSTB1PpA6pP A3MFsuAdZzdte2zrLQDXfo/czWUMeRjJyNEd3HHyyWzV09kmygrxYuW6//4Ai9CGJ6 oIiLAopF3FCkoYGycJP1LpKwNKqfH8WPKAdrGMpYg/ZT74sBDEJ6FbeeFMqIjsgrQc A9ho+bfoOFGIQ== From: Adam Wujek Cc: Adam Wujek , Guenter Roeck , Jean Delvare , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Reply-To: Adam Wujek Subject: [PATCH] hwmod: (pmbus) disable PEC if not enabled Message-ID: <20220420125421.415716-1-dev_public@wujek.eu> In-Reply-To: References: <20220419205228.303952-1-dev_public@wujek.eu> Feedback-ID: 23425257:user:proton MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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, a kernel driver 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. Signed-off-by: Adam Wujek --- drivers/hwmon/pmbus/pmbus_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_c= ore.c index b2618b1d529e..0af7a3d74f47 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -2334,7 +2334,8 @@ static int pmbus_init_common(struct i2c_client *clien= t, struct pmbus_data *data, client->flags |=3D I2C_CLIENT_PEC; } } - } + } else + client->flags &=3D ~I2C_CLIENT_PEC; /* * Check if the chip is write protected. If it is, we can not clear -- 2.25.1