2023-02-15 13:01:44

by Christophe JAILLET

[permalink] [raw]
Subject: [PATCH] spi: synquacer: Fix timeout handling in synquacer_spi_transfer_one()

wait_for_completion_timeout() never returns a <0 value. It returns either
on timeout or a positive value (at least 1, or number of jiffies left
till timeout)

So, fix the error handling path and return -ETIMEDOUT should a timeout
occur.

Fixes: b0823ee35cf9 ("spi: Add spi driver for Socionext SynQuacer platform")
Signed-off-by: Christophe JAILLET <[email protected]>
---
Compile tested only.
---
drivers/spi/spi-synquacer.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-synquacer.c b/drivers/spi/spi-synquacer.c
index 47cbe73137c2..dc188f9202c9 100644
--- a/drivers/spi/spi-synquacer.c
+++ b/drivers/spi/spi-synquacer.c
@@ -472,10 +472,9 @@ static int synquacer_spi_transfer_one(struct spi_master *master,
read_fifo(sspi);
}

- if (status < 0) {
- dev_err(sspi->dev, "failed to transfer. status: 0x%x\n",
- status);
- return status;
+ if (status == 0) {
+ dev_err(sspi->dev, "failed to transfer. Timeout.\n");
+ return -ETIMEDOUT;
}

return 0;
--
2.34.1



2023-02-15 15:24:36

by Jassi Brar

[permalink] [raw]
Subject: Re: [PATCH] spi: synquacer: Fix timeout handling in synquacer_spi_transfer_one()

On Wed, 15 Feb 2023 at 07:01, Christophe JAILLET
<[email protected]> wrote:
>
> wait_for_completion_timeout() never returns a <0 value. It returns either
> on timeout or a positive value (at least 1, or number of jiffies left
> till timeout)
>
> So, fix the error handling path and return -ETIMEDOUT should a timeout
> occur.
>
> Fixes: b0823ee35cf9 ("spi: Add spi driver for Socionext SynQuacer platform")
> Signed-off-by: Christophe JAILLET <[email protected]>
> ---
> Compile tested only.
> ---
> drivers/spi/spi-synquacer.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/spi/spi-synquacer.c b/drivers/spi/spi-synquacer.c
> index 47cbe73137c2..dc188f9202c9 100644
> --- a/drivers/spi/spi-synquacer.c
> +++ b/drivers/spi/spi-synquacer.c
> @@ -472,10 +472,9 @@ static int synquacer_spi_transfer_one(struct spi_master *master,
> read_fifo(sspi);
> }
>
> - if (status < 0) {
> - dev_err(sspi->dev, "failed to transfer. status: 0x%x\n",
> - status);
> - return status;
> + if (status == 0) {
> + dev_err(sspi->dev, "failed to transfer. Timeout.\n");
> + return -ETIMEDOUT;
> }
>
> return 0;
>
Acked-by: Jassi Brar <[email protected]>

thanks

2023-02-15 17:51:23

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] spi: synquacer: Fix timeout handling in synquacer_spi_transfer_one()

On Wed, 15 Feb 2023 14:01:28 +0100, Christophe JAILLET wrote:
> wait_for_completion_timeout() never returns a <0 value. It returns either
> on timeout or a positive value (at least 1, or number of jiffies left
> till timeout)
>
> So, fix the error handling path and return -ETIMEDOUT should a timeout
> occur.
>
> [...]

Applied to

broonie/spi.git for-next

Thanks!

[1/1] spi: synquacer: Fix timeout handling in synquacer_spi_transfer_one()
commit: e6a0b671880207566e1ece983bf989dde60bc1d7

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark