855f1fe30c041f3c6b0573467767bd967aadfebb
[openwrt.git] / target / linux / brcm2708 / patches-3.10 / 0168-spidev-fix-hang-when-transfer_one_message-fails.patch
1 From b68b4448dc37e5fd510f1bb9bbd62722ad497f41 Mon Sep 17 00:00:00 2001
2 From: Daniel Santos <daniel.santos@pobox.com>
3 Date: Sun, 5 Jan 2014 17:39:26 -0600
4 Subject: [PATCH 168/174] spidev: fix hang when transfer_one_message fails
5
6 commit e120cc0dcf2880a4c5c0a6cb27b655600a1cfa1d upstream.
7
8 This corrects a problem in spi_pump_messages() that leads to an spi
9 message hanging forever when a call to transfer_one_message() fails.
10 This failure occurs in my MCP2210 driver when the cs_change bit is set
11 on the last transfer in a message, an operation which the hardware does
12 not support.
13
14 Rationale
15 Since the transfer_one_message() returns an int, we must presume that it
16 may fail.  If transfer_one_message() should never fail, it should return
17 void.  Thus, calls to transfer_one_message() should properly manage a
18 failure.
19
20 Fixes: ffbbdd21329f3 (spi: create a message queueing infrastructure)
21 Signed-off-by: Daniel Santos <daniel.santos@pobox.com>
22 Signed-off-by: Mark Brown <broonie@linaro.org>
23 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24 ---
25  drivers/spi/spi.c | 4 +++-
26  1 file changed, 3 insertions(+), 1 deletion(-)
27
28 --- a/drivers/spi/spi.c
29 +++ b/drivers/spi/spi.c
30 @@ -584,7 +584,9 @@ static void spi_pump_messages(struct kth
31         ret = master->transfer_one_message(master, master->cur_msg);
32         if (ret) {
33                 dev_err(&master->dev,
34 -                       "failed to transfer one message from queue\n");
35 +                       "failed to transfer one message from queue: %d\n", ret);
36 +               master->cur_msg->status = ret;
37 +               spi_finalize_current_message(master);
38                 return;
39         }
40  }