Linux-i3c Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] i3c: master: svc: Update actual read length
@ 2025-04-01  6:34 Stanley Chu
  2025-04-01 15:00 ` Frank Li
  0 siblings, 1 reply; 2+ messages in thread
From: Stanley Chu @ 2025-04-01  6:34 UTC (permalink / raw)
  To: frank.li, miquel.raynal, alexandre.belloni, linux-i3c
  Cc: linux-kernel, tomer.maimon, kwliu, yschu

From: Stanley Chu <yschu@nuvoton.com>

Some drivers, such as mctp-i3c.c, reuse the i3c_priv_xfer.len as
the actual read len. Therefore, the controller driver should also
update the i3c_priv_xfer.len after the read transfer is completed.

Signed-off-by: Stanley Chu <yschu@nuvoton.com>
---
 drivers/i3c/master/svc-i3c-master.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
index 85e16de208d3..dd520f5d4c9f 100644
--- a/drivers/i3c/master/svc-i3c-master.c
+++ b/drivers/i3c/master/svc-i3c-master.c
@@ -1470,9 +1470,16 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master)
 					  cmd->len, &cmd->actual_len,
 					  cmd->continued);
 		/* cmd->xfer is NULL if I2C or CCC transfer */
-		if (cmd->xfer)
+		if (cmd->xfer) {
 			cmd->xfer->actual_len = cmd->actual_len;
 
+			/*
+			 * Some i3c drivers reuse i3c_priv_xfer.len as
+			 * the actual read length.
+			 */
+			cmd->xfer->len = cmd->actual_len;
+		}
+
 		if (ret)
 			break;
 	}
-- 
2.34.1


-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v1] i3c: master: svc: Update actual read length
  2025-04-01  6:34 [PATCH v1] i3c: master: svc: Update actual read length Stanley Chu
@ 2025-04-01 15:00 ` Frank Li
  0 siblings, 0 replies; 2+ messages in thread
From: Frank Li @ 2025-04-01 15:00 UTC (permalink / raw)
  To: Stanley Chu
  Cc: miquel.raynal, alexandre.belloni, linux-i3c, linux-kernel,
	tomer.maimon, kwliu, yschu

On Tue, Apr 01, 2025 at 02:34:06PM +0800, Stanley Chu wrote:
> From: Stanley Chu <yschu@nuvoton.com>
>
> Some drivers, such as mctp-i3c.c, reuse the i3c_priv_xfer.len as

In include/linux/i3c/device.h define API as

/**
 * struct i3c_priv_xfer - I3C SDR private transfer
 ...
 * @len: transfer length in bytes of the transfer
 * @actual_len: actual length in bytes are transferred by the controller
 ...
 */
struct i3c_priv_xfer {
...
        u16 len;
        u16 actual_len;
...
};

You should fix mctp-i3c.c or need change API defination firstly.

Frank

> the actual read len. Therefore, the controller driver should also
> update the i3c_priv_xfer.len after the read transfer is completed.
>
> Signed-off-by: Stanley Chu <yschu@nuvoton.com>
> ---
>  drivers/i3c/master/svc-i3c-master.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
> index 85e16de208d3..dd520f5d4c9f 100644
> --- a/drivers/i3c/master/svc-i3c-master.c
> +++ b/drivers/i3c/master/svc-i3c-master.c
> @@ -1470,9 +1470,16 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master)
>  					  cmd->len, &cmd->actual_len,
>  					  cmd->continued);
>  		/* cmd->xfer is NULL if I2C or CCC transfer */
> -		if (cmd->xfer)
> +		if (cmd->xfer) {
>  			cmd->xfer->actual_len = cmd->actual_len;
>
> +			/*
> +			 * Some i3c drivers reuse i3c_priv_xfer.len as
> +			 * the actual read length.
> +			 */
> +			cmd->xfer->len = cmd->actual_len;
> +		}
> +
>  		if (ret)
>  			break;
>  	}
> --
> 2.34.1
>

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-04-01 15:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-01  6:34 [PATCH v1] i3c: master: svc: Update actual read length Stanley Chu
2025-04-01 15:00 ` Frank Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox