2022-05-25 18:21:57

by Eddie James

[permalink] [raw]
Subject: [PATCH 2/2] spi: core: Display return code when failing to transfer message

All the other calls to the controller driver display the error
return code. The return code is helpful to understand what went
wrong, so include it when failing to transfer one message.

Signed-off-by: Eddie James <[email protected]>
---
drivers/spi/spi.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 481edea77c62..ea09d1b42bf6 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1654,7 +1654,8 @@ static void __spi_pump_messages(struct spi_controller *ctlr, bool in_kthread)
ret = ctlr->transfer_one_message(ctlr, msg);
if (ret) {
dev_err(&ctlr->dev,
- "failed to transfer one message from queue\n");
+ "failed to transfer one message from queue: %d\n",
+ ret);
goto out;
}

--
2.27.0



2022-06-03 07:40:53

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH 2/2] spi: core: Display return code when failing to transfer message

Hello,

On Wed, May 25, 2022 at 11:58:52AM -0500, Eddie James wrote:
> All the other calls to the controller driver display the error
> return code. The return code is helpful to understand what went
> wrong, so include it when failing to transfer one message.
>
> Signed-off-by: Eddie James <[email protected]>
> ---
> drivers/spi/spi.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 481edea77c62..ea09d1b42bf6 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -1654,7 +1654,8 @@ static void __spi_pump_messages(struct spi_controller *ctlr, bool in_kthread)
> ret = ctlr->transfer_one_message(ctlr, msg);
> if (ret) {
> dev_err(&ctlr->dev,
> - "failed to transfer one message from queue\n");
> + "failed to transfer one message from queue: %d\n",
> + ret);

(I know it's too late, just stumbled over this commit in mainline by
chance. So maybe just a suggestion for the next similar change...)

A tad nicer would be to use %pe instead of %d that results in

mydev mybus: failed to transfer one message from queue: -EIO

instead of

mydev mybus: failed to transfer one message from queue: -5

and so is more descriptive. (Note you need ERR_PTR(ret) for %pe.)

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | https://www.pengutronix.de/ |


Attachments:
(No filename) (1.45 kB)
signature.asc (499.00 B)
Download all attachments