From patchwork Thu May 19 23:11:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wujek dev X-Patchwork-Id: 12856124 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EBF7BC433EF for ; Thu, 19 May 2022 23:21:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:References: In-Reply-To:Message-ID:Subject:Cc:From:Date:To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nk0JP3+JsAvJ3RD+VVi1rQeB4LtO3FCcNDZnx2U7jfA=; b=lGyGglzf1t6tJ2 p8fWj3f6FxJ4ywwli6KwM39UTFwe4w395nB/nPtHB1NRJLM3kxs9H4Pw9A9S4OUj7d5+l0gTcwUx/ ltD2CAjPxiJHSDTer74Lt3NbviERYH62+F+3/enBo3/ZtK/SHGz2H6Uod1YptoTLnWx5TsBmXcrKT 1BJl/ymjSHETlvH9sX7P3kY9k8YX36g7+p0Wjh0JU6xC/ZEwrfM1YgCZOQjEQN3GotZpay/L9qYbk O3w8C0chGEVOX733Kcy4UTJzpI4VedlBudIQNpnIqeD0Ij1bEOe2p1ZPjLDsoXbM2xsadPjCmHAan M1rdI8z3i4NgK+d22WLg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrpRO-009f3T-Mz; Thu, 19 May 2022 23:20:22 +0000 Received: from mail-41103.protonmail.ch ([185.70.41.103]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrpRL-009f2F-UB for linux-arm-kernel@lists.infradead.org; Thu, 19 May 2022 23:20:21 +0000 Date: Thu, 19 May 2022 23:11:23 +0000 Authentication-Results: mail-41103.protonmail.ch; dkim=pass (2048-bit key) header.d=wujek.eu header.i=@wujek.eu header.b="P0jXOg7x" 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220519_162020_157360_87145A2A X-CRM114-Status: UNSURE ( 6.82 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Adam Wujek Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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(+) -- 2.17.1 diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.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, struct 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 = msg->buf[0] + 2; /* add len byte + PEC byte */ + cdns_i2c_writereg(CDNS_I2C_IXR_ALL_INTR_MASK, CDNS_I2C_IDR_OFFSET);