[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aVKSqx6J4HHfnBNX@aurel32.net>
Date: Mon, 29 Dec 2025 15:39:39 +0100
From: Aurelien Jarno <aurelien@...el32.net>
To: Troy Mitchell <troy.mitchell@...ux.spacemit.com>
Cc: Andi Shyti <andi.shyti@...nel.org>, Yixun Lan <dlan@...too.org>,
Alex Elder <elder@...cstar.com>,
Michael Opdenacker <michael.opdenacker@...tcommit.com>,
Troy Mitchell <troymitchell988@...il.com>,
linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-riscv@...ts.infradead.org, spacemit@...ts.linux.dev
Subject: Re: [PATCH v5 1/2] i2c: spacemit: replace i2c_xfer_msg()
On 2025-12-26 11:31, Troy Mitchell wrote:
> The upcoming PIO support requires a wait_pio_xfer() helper, which is
> invoked from xfer_msg().
>
> Since wait_pio_xfer() depends on err_check(), move the definition of
> xfer_msg() after err_check() to avoid a forward declaration of
> err_check().
>
> Signed-off-by: Troy Mitchell <troy.mitchell@...ux.spacemit.com>
> ---
> drivers/i2c/busses/i2c-k1.c | 62 ++++++++++++++++++++++-----------------------
> 1 file changed, 31 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-k1.c b/drivers/i2c/busses/i2c-k1.c
> index d42c03ef5db5984ea8e06b3d7eb485b4f899e616..accef6653b56bd3505770328af17e441fad613a7 100644
> --- a/drivers/i2c/busses/i2c-k1.c
> +++ b/drivers/i2c/busses/i2c-k1.c
> @@ -304,37 +304,6 @@ static void spacemit_i2c_start(struct spacemit_i2c_dev *i2c)
> writel(val, i2c->base + SPACEMIT_ICR);
> }
>
> -static int spacemit_i2c_xfer_msg(struct spacemit_i2c_dev *i2c)
> -{
> - unsigned long time_left;
> - struct i2c_msg *msg;
> -
> - for (i2c->msg_idx = 0; i2c->msg_idx < i2c->msg_num; i2c->msg_idx++) {
> - msg = &i2c->msgs[i2c->msg_idx];
> - i2c->msg_buf = msg->buf;
> - i2c->unprocessed = msg->len;
> - i2c->status = 0;
> -
> - reinit_completion(&i2c->complete);
> -
> - spacemit_i2c_start(i2c);
> -
> - time_left = wait_for_completion_timeout(&i2c->complete,
> - i2c->adapt.timeout);
> - if (!time_left) {
> - dev_err(i2c->dev, "msg completion timeout\n");
> - spacemit_i2c_conditionally_reset_bus(i2c);
> - spacemit_i2c_reset(i2c);
> - return -ETIMEDOUT;
> - }
> -
> - if (i2c->status & SPACEMIT_SR_ERR)
> - return spacemit_i2c_handle_err(i2c);
> - }
> -
> - return 0;
> -}
> -
> static bool spacemit_i2c_is_last_msg(struct spacemit_i2c_dev *i2c)
> {
> if (i2c->msg_idx != i2c->msg_num - 1)
> @@ -418,6 +387,37 @@ static void spacemit_i2c_err_check(struct spacemit_i2c_dev *i2c)
> complete(&i2c->complete);
> }
>
> +static int spacemit_i2c_xfer_msg(struct spacemit_i2c_dev *i2c)
> +{
> + unsigned long time_left;
> + struct i2c_msg *msg;
> +
> + for (i2c->msg_idx = 0; i2c->msg_idx < i2c->msg_num; i2c->msg_idx++) {
> + msg = &i2c->msgs[i2c->msg_idx];
> + i2c->msg_buf = msg->buf;
> + i2c->unprocessed = msg->len;
> + i2c->status = 0;
> +
> + reinit_completion(&i2c->complete);
> +
> + spacemit_i2c_start(i2c);
> +
> + time_left = wait_for_completion_timeout(&i2c->complete,
> + i2c->adapt.timeout);
> + if (!time_left) {
> + dev_err(i2c->dev, "msg completion timeout\n");
> + spacemit_i2c_conditionally_reset_bus(i2c);
> + spacemit_i2c_reset(i2c);
> + return -ETIMEDOUT;
> + }
> +
> + if (i2c->status & SPACEMIT_SR_ERR)
> + return spacemit_i2c_handle_err(i2c);
> + }
> +
> + return 0;
> +}
> +
> static irqreturn_t spacemit_i2c_irq_handler(int irq, void *devid)
> {
> struct spacemit_i2c_dev *i2c = devid;
With the patch title updated as suggested:
Reviewed-by: Aurelien Jarno <aurelien@...el32.net>
--
Aurelien Jarno GPG: 4096R/1DDD8C9B
aurelien@...el32.net http://aurel32.net
Powered by blists - more mailing lists