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 v2] i2c: busses: i2c-cadence: fix message length when receive block message
Date: Thu, 19 May 2022 23:11:23 +0000	[thread overview]
Message-ID: <20220519231058.437365-1-dev_public@wujek.eu> (raw)
In-Reply-To: <20220519124946.387373-1-dev_public@wujek.eu>

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 <dev_public@wujek.eu>
---
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-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);

--
2.17.1



  reply	other threads:[~2022-05-19 23:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-19 12:50 [PATCH] " Adam Wujek
2022-05-19 23:11 ` Adam Wujek [this message]
2022-05-24 15:05   ` [PATCH v2] " 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=20220519231058.437365-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®