linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* spidev: fix hang when transfer_one_message fails
@ 2014-01-05 23:39 danielfsantos-fOdFMYwuEsI
       [not found] ` <1388965166-27334-1-git-send-email-daniel.santos-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: danielfsantos-fOdFMYwuEsI @ 2014-01-05 23:39 UTC (permalink / raw)
  To: Mark Brown, linux-spi, LKML; +Cc: Daniel Santos

This corrects a problem in spi_pump_messages() that leads to an spi
message hanging forever when a call to transfer_one_message() fails.
This failure occurs in my MCP2210 driver when the cs_change bit is set
on the last transfer in a message, an operation which the hardware does
not support.

Rationale
Since the transfer_one_message() returns an int, we must presume that it
may fail.  If transfer_one_message() should never fail, it should return
void.  Thus, calls to transfer_one_message() should properly manage a
failure.

Signed-off-by: Daniel Santos <daniel.santos-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org>
---
 drivers/spi/spi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 98f4b77..907122e 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -735,7 +735,9 @@ static void spi_pump_messages(struct kthread_work *work)
 	ret = master->transfer_one_message(master, master->cur_msg);
 	if (ret) {
 		dev_err(&master->dev,
-			"failed to transfer one message from queue\n");
+			"failed to transfer one message from queue: %d\n", ret);
+		master->cur_msg->status = ret;
+		spi_finalize_current_message(master);
 		return;
 	}
 }
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2014-01-27 23:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-05 23:39 spidev: fix hang when transfer_one_message fails danielfsantos-fOdFMYwuEsI
     [not found] ` <1388965166-27334-1-git-send-email-daniel.santos-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org>
2014-01-05 23:52   ` *[PATCH]* " Daniel Santos
2014-01-06 12:53   ` Mark Brown
2014-01-23 16:47   ` Geert Uytterhoeven
2014-01-23 18:17     ` Mark Brown
2014-01-24  2:21       ` Daniel Santos
     [not found]         ` <52E1CE33.7040309-fOdFMYwuEsI@public.gmane.org>
2014-01-24 13:01           ` Mark Brown
     [not found]             ` <20140124130135.GX11727-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-01-27 23:16               ` Daniel Santos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).