From nobody Thu May 7 19:51:07 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 228AAC433F5 for ; Thu, 19 May 2022 23:11:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245687AbiESXLj (ORCPT ); Thu, 19 May 2022 19:11:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231533AbiESXLh (ORCPT ); Thu, 19 May 2022 19:11:37 -0400 Received: from mail-4018.proton.ch (mail-4018.proton.ch [185.70.40.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3751EC1EE2 for ; Thu, 19 May 2022 16:11:35 -0700 (PDT) Date: Thu, 19 May 2022 23:11:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wujek.eu; s=protonmail2; t=1653001892; x=1653261092; bh=s+PX3ttgd2pqhf/X4X6oI+ne2p0Lx6BzbzmdfFsmb+E=; 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=P0jXOg7xBd7b1w+1w+YFAYZXxdDQwSRLFCpOewLBpEudkFpgNttzjtSQSY2EjkW5d QyFb82nQWuwPzl+m1GsNkuMS1tCv9B3tMX67z3bVidP32RGGO33ELd5C2Qf42SAmJh xlNQGELN5h6FELEbPlIfGNSWjxYX7kB3ywt1L6fV4IEgvH5jV+mVeWVlTwDoXXrBll syIfjrDzkFg9sFFOPyqNXqPokR5IyL75nxM8HTq5KpSpx2h/vufvedK+sJGi2m9GR4 VemUaFxIUHWWTRL4ZPpAi5u8utBWw0Is1SMvB3g/1mv55QvHfYHOESk/mBKXSxpBaf 9SGNrfRmHFDLQ== From: Adam Wujek Cc: Adam Wujek , Michal Simek , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Reply-To: Adam Wujek Subject: [PATCH v2] i2c: busses: i2c-cadence: fix message length when receive block message Message-ID: <20220519231058.437365-1-dev_public@wujek.eu> In-Reply-To: <20220519124946.387373-1-dev_public@wujek.eu> References: <20220519124946.387373-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" Needed by hwmon/pmbus_core driver to calculate PEC correctly. The hwmon/pmbus_core driver relies on bus drivers to update the message length of receive block transfers. Only in this type of smbus transfer the length is not known before the transfer is started. Signed-off-by: Adam Wujek --- Notes: Changes in v2: - fix multiline comment drivers/i2c/busses/i2c-cadence.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cade= nce.c index 805c77143a0f..a679eb390ef5 100644 --- a/drivers/i2c/busses/i2c-cadence.c +++ b/drivers/i2c/busses/i2c-cadence.c @@ -794,6 +794,13 @@ static int cdns_i2c_process_msg(struct cdns_i2c *id, s= truct i2c_msg *msg, return -ETIMEDOUT; } + /* + * Update message len, as i2c/smbus driver (function + * i2c_smbus_xfer_emulated) relies on i2c device drivers to do this. + */ + if ((msg->flags & I2C_M_RECV_LEN) && (msg->flags & I2C_M_RD)) + msg->len =3D msg->buf[0] + 2; /* add len byte + PEC byte */ + cdns_i2c_writereg(CDNS_I2C_IXR_ALL_INTR_MASK, CDNS_I2C_IDR_OFFSET); -- 2.17.1