mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Adam Wujek <dev_public@wujek.eu>
To: unlisted-recipients:; (no To-header on input)
Cc: Adam Wujek <dev_public@wujek.eu>,
	Michal Simek <michal.simek@xilinx.com>,
	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
Date: Thu, 19 May 2022 12:50:19 +0000	[thread overview]
Message-ID: <20220519124946.387373-1-dev_public@wujek.eu> (raw)

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 <dev_public@wujek.eu>
---
 drivers/i2c/busses/i2c-cadence.c | 5 +++++
 1 file changed, 5 insertions(+)

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);

--
2.17.1



             reply	other threads:[~2022-05-19 12:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-19 12:50 Adam Wujek [this message]
2022-05-19 23:11 ` [PATCH v2] " Adam Wujek
2022-05-24 15:05   ` Michal Simek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220519124946.387373-1-dev_public@wujek.eu \
    --to=dev_public@wujek.eu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@xilinx.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®