[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-can
Subject:    [PATCH 08/11] sllin: signal timeout if there are less than configured characters
From:       Alexander Stein <alexander.stein () systec-electronic ! com>
Date:       2013-12-16 7:54:11
Message-ID: 1387180454-1738-9-git-send-email-alexander.stein () systec-electronic ! com
[Download RAW message or body]

We will hit the timeout if there is a larger length configured than
actually received or none at all. Signal this to userspace.

Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
---
 sllin/sllin.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/sllin/sllin.c b/sllin/sllin.c
index 457788c..ffbdf01 100644
--- a/sllin/sllin.c
+++ b/sllin/sllin.c
@@ -949,7 +949,16 @@ static enum hrtimer_restart sllin_rx_timeout_handler(struct hrtimer *hrtimer)
 {
 	struct sllin *sl = container_of(hrtimer, struct sllin, rx_timer);
 
-	if (sl->lin_master) {
+	/*
+	 * Signal timeout when:
+	 * master: We did not receive as much characters as expected
+	 * slave: * we did not receive any data bytes at all
+	 *        * we know the length and didn't receive enough
+	 */
+	if ((sl->lin_master) ||
+			(sl->rx_cnt <= SLLIN_BUFF_DATA) ||
+			((!sl->rx_len_unknown) &&
+			(sl->rx_cnt < sl->rx_expect))) {
 		sllin_report_error(sl, LIN_ERR_RX_TIMEOUT);
 		set_bit(SLF_TMOUTEVENT, &sl->flags);
 	} else {
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-can" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic