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: Adam Wujek X-Patchwork-Id: 574694 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 7012DC433F5 for ; Thu, 19 May 2022 12:50:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238133AbiESMum (ORCPT ); Thu, 19 May 2022 08:50:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238164AbiESMuk (ORCPT ); Thu, 19 May 2022 08:50:40 -0400 Received: from mail-4323.proton.ch (mail-4323.proton.ch [185.70.43.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD258BA57A; Thu, 19 May 2022 05:50:31 -0700 (PDT) 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 Reply-To: Adam Wujek 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 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.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);