]> rtime.felk.cvut.cz Git - linux-lin.git/blobdiff - sllin/sllin.c
sllin: rx_timer is also used when waiting for received characters while sending Heade...
[linux-lin.git] / sllin / sllin.c
index ebcfd28007d9859b78232fa7ce1777ea8483f168..6a4e8bf0999bf516d3726ff3828b3c70f3417b0f 100644 (file)
@@ -230,8 +230,6 @@ static void sllin_send_canfr(struct sllin *sl, canid_t id, char *data, int len)
 
        sl->dev->stats.rx_packets++;
        sl->dev->stats.rx_bytes += cf.can_dlc;
-
-
 }
 
 /**
@@ -459,6 +457,16 @@ static void sllin_receive_buf(struct tty_struct *tty,
  */
 void sllin_report_error(struct sllin *sl, int err)
 {
+       switch (err) {
+               case LIN_ERR_CHECKSUM:
+                       sl->dev->stats.rx_crc_errors++;
+                       break;
+
+               case LIN_ERR_RX_TIMEOUT:                
+                       sl->dev->stats.rx_errors++;
+                       break;
+       }
+
        sllin_send_canfr(sl, 0 | CAN_EFF_FLAG |
                (err & ~LIN_ID_MASK), NULL, 0);
 }
@@ -639,7 +647,7 @@ int sllin_send_break(struct sllin *sl)
        if (retval)
                return retval;
 
-       //udelay(712);
+       /* udelay(712); */
        usleep_range_min = (1000000l * SLLIN_SAMPLES_PER_CHAR) / break_baud;
        usleep_range_max = usleep_range_min + 50;
        usleep_range(usleep_range_min, usleep_range_max);
@@ -823,6 +831,9 @@ int sllin_kwthread(void *ptr)
                                clear_bit(SLF_MSGEVENT, &sl->flags);
                                kfree_skb(sl->tx_req_skb);
                                netif_wake_queue(sl->dev);
+                               hrtimer_start(&sl->rx_timer,
+                                       ktime_add(ktime_get(), sl->rx_timer_timeout),
+                                       HRTIMER_MODE_ABS);
                                break;
 
                        case SLSTATE_BREAK_SENT:
@@ -838,6 +849,7 @@ int sllin_kwthread(void *ptr)
                                break;
 
                        case SLSTATE_ID_SENT:
+                               hrtimer_cancel(&sl->rx_timer);
                                sl->id_to_send = false;
                                if (sl->data_to_send) {
                                        sllin_send_tx_buff(sl);
@@ -893,6 +905,7 @@ int sllin_kwthread(void *ptr)
                                        }
                                }
 
+                               /* Be aware, no BREAK here */
                        case SLSTATE_RESPONSE_WAIT_BUS:
                                if (sl->rx_cnt < sl->rx_expect)
                                        continue;
@@ -904,12 +917,11 @@ int sllin_kwthread(void *ptr)
                                if (sllin_rx_validate(sl) == -1) {
                                        pr_debug("sllin: RX validation failed.\n");
                                        sllin_report_error(sl, LIN_ERR_CHECKSUM);
-                                       //FIXME tx_stat.err++
                                } else {
-                                       // send CAN non-RTR frame with data
+                                       /* Send CAN non-RTR frame with data */
                                        pr_debug("sllin: sending NON-RTR CAN"
                                                "frame with LIN payload.");
-                                       sll_bump(sl); //send packet to the network layer
+                                       sll_bump(sl); /* send packet to the network layer */
                                }
 
                                sl->id_to_send = false;
@@ -921,7 +933,7 @@ int sllin_kwthread(void *ptr)
                                if (sl->rx_cnt < sl->tx_lim)
                                        continue;
 
-                               sll_bump(sl); //send packet to the network layer
+                               sll_bump(sl); /* send packet to the network layer */
                                pr_debug("sllin: response sent ID %d len %d\n",
                                        sl->rx_buff[SLLIN_BUFF_ID], sl->rx_cnt - SLLIN_BUFF_DATA - 1);
 
@@ -929,12 +941,6 @@ int sllin_kwthread(void *ptr)
                                sl->lin_state = SLSTATE_IDLE;
                                break;
                }
-
-
-
-
-               /* sl->dev->stats.tx_packets++; send frames statistic */
-               /* netif_wake_queue(sl->dev); allow next Tx packet arrival */
        }
 
        hrtimer_cancel(&sl->rx_timer);