Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp71681pxb; Thu, 21 Apr 2022 17:20:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvmuS0lJn1RFqIKaw022/cUpUy8Pdw1HqXVRcMWSfkhnCOVfVH0uNRnErCjsiIh4oLi4P9 X-Received: by 2002:a63:5518:0:b0:3a8:c75d:8536 with SMTP id j24-20020a635518000000b003a8c75d8536mr1696074pgb.366.1650586815906; Thu, 21 Apr 2022 17:20:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650586815; cv=none; d=google.com; s=arc-20160816; b=dbTcvb4kEK2r7BQrDShm07eZ/EaFttpgauirCCH3gHt01vttv1le2Y/R+TKtTlWtNI 4Qlu/URNdylQdcDM3JE+EPGQWb3UPaDSotY9h2EXTHPAxhNm7XSwWiaUmErj/Q/X+1J0 GvjKabrFV2/f++ykjg9UHxeCUc5GuDaOZI8PLgqFg5YCyehm5zQxnkV+aWEKh2xX/YsY ONxDb/zoUyj7qv+7id7iyWRcFOjLLF8hoenqsxfgh02Vtd+J2hLq9jYFwDbVOY2N1z0H fLkShmoq1FHmmoa0mClox236wThRAMBTXVWGyV2q+Kmo5ZHaz1q9iC35Vp83TR6avRr1 BxTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :feedback-id:references:in-reply-to:message-id:subject:reply-to:cc :from:dkim-signature:date; bh=+8+1bERFEDfD5DtGG4zF7lQrC6F4hcnI/ewNHOmoNj0=; b=LqeRzkxGqCNYQb/KBAAHS6Kc8Ehorz86rEfNnmZgd77SAJcYeei7mL+hbkeCizNVKB BNtmUgazWo8jUnig7iod2yIpWC7DwNqPql57eS4cI8shUZBust+Shux+Tanl9o85YGrm csysg3KTN6P/iXrQguQNj4f29k1x4c+udMpIEqpFmL/x8PaWbqfh4bvIAnRTyMpPiARx V8LR8mhkxDenkcVvrso3ZNGnHIypZHiiUhbzJXqfq8bf8TDPZeQ6t1BGUMKHEZqRKVbP BA0PudSOVmk8uoLin1EKGnu6rCjvDektYWtwq7iWdtTQYJ2ZgBFfNP/UWucV992dh7b7 rdmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wujek.eu header.s=protonmail2 header.b=YyvXWSC8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b17-20020a63cf51000000b003986444128fsi6884125pgj.671.2022.04.21.17.19.37; Thu, 21 Apr 2022 17:20:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@wujek.eu header.s=protonmail2 header.b=YyvXWSC8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378651AbiDTM5k (ORCPT + 99 others); Wed, 20 Apr 2022 08:57:40 -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-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MISSING_HEADERS, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, =09=09=09=09client->flags |=3D I2C_CLIENT_PEC; =09=09=09} =09=09} -=09} +=09} else +=09=09client->flags &=3D ~I2C_CLIENT_PEC; =09/* =09 * Check if the chip is write protected. If it is, we can not clear -- 2.25.1