From patchwork Thu May 19 12:50:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wujek dev X-Patchwork-Id: 12854886 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 7D7E1C433EF for ; Thu, 19 May 2022 12:51:40 +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:Message-ID: Subject:Cc:From:Date:To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=LgketiUN/cVsiaBZTjCPdwBRXNfn3ebdP/C1xEra7UE=; b=XxA oLahuFAcKxQFj29ImTFDJx3yEex0qyjW/5xU+Wr5MMdeP55j1zNaLpVmQJYuUD6xslIJIcNwtQhg5 FoSobuses7ixIpx897mMzJhMOT56OFQerP/DJUhDVHqlATJ7zTOh9R21aScOPFhkFjGqmvlA8npCj w2NxxIh4asNjcXVIDGI66uwqKPiKKe+OQqb8S7g6RO5ud2eXUKGgZfpvOlUaMFM3PXQ690FOhqZB9 irMJYM2c4ZZmBB9ZgJjMNmufdPFKw4TW7akGG9Fcv22AHnFNauWm/CtSofWm1cbQ9r1FHy10G7SV+ HEtqXYinVWPTwgHITOfz60DIpfki9Ng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrfbz-006lTv-Lh; Thu, 19 May 2022 12:50:39 +0000 Received: from mail-4323.proton.ch ([185.70.43.23]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrfbu-006lOl-Ic for linux-arm-kernel@lists.infradead.org; Thu, 19 May 2022 12:50:37 +0000 Date: Thu, 19 May 2022 12:50:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wujek.eu; s=protonmail2; t=1652964628; x=1653223828; bh=+6dbY/snU3b6uCWUgyekqmraArOZDE0O1Do6Z1g28TA=; h=Date:From:Cc:Reply-To:Subject:Message-ID:Feedback-ID:From:To:Cc: Date:Subject:Reply-To:Feedback-ID:Message-ID; b=M9q70UMjUe+S50Y/XwA+mERO7Nex8c1Hfssapd9f1q2X5Y8u1lPglwRW4oiT6eSkW XZCXD+90cYbj6MNmAV/e6yY+kIvzw+IqHoNNcBTn8tvm/Ndczy5zpr483sxcdQR2vk 0Onx+5I5Dw5zMO4jwGh9OvMeF3sZ1gfhko4sPMjczBMmT8qHjV5mYuZ5av7p/yE++C Cd8C3caxWD5msQw+QTk79j0wbYqIbky4Pet2Y/+71TXc586ADxOC5L9jGKYzUfo0Zn 3MlrvVHS6XDpzH0Lk8QUhjmPZanmRUt63X5zNFKRomF/uaNDv3J+BUvxBUzZx1tj5h +cBxBPZDJr1sw== 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] i2c: busses: i2c-cadence: fix message length when receive block message Message-ID: <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_055036_148713_20F4C868 X-CRM114-Status: UNSURE ( 7.19 ) 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 correctly calculate PEC. The hwmon/pmbus_core driver relies on bus drivers to update the message length of received block transfers. Only in this type of smbus transfer, in which the length is not known before the transfer is started. Signed-off-by: Adam Wujek --- drivers/i2c/busses/i2c-cadence.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.17.1 diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c index 20ac432a37ea..65f1979d4e6f 100644 --- a/drivers/i2c/busses/i2c-cadence.c +++ b/drivers/i2c/busses/i2c-cadence.c @@ -830,6 +830,11 @@ 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);