sllin: signal timeout if there are less than configured characters
authorAlexander Stein <alexander.stein@systec-electronic.com>
Mon, 16 Dec 2013 07:54:11 +0000 (08:54 +0100)
committerPavel Pisa <pisa@cmp.felk.cvut.cz>
Thu, 16 Jan 2014 23:51:22 +0000 (00:51 +0100)
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

index 457788c..ffbdf01 100644 (file)
@@ -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 {