rk: revert 20f3d0b+v3.0.66 to v3.0
[firefly-linux-kernel-4.4.55.git] / net / can / bcm.c
index b117bfa4e5363d55699e86257f0b91d8ea01ff93..184a6572b67e6be824ba1ef30b122d065269a262 100644 (file)
@@ -343,18 +343,6 @@ static void bcm_send_to_user(struct bcm_op *op, struct bcm_msg_head *head,
        }
 }
 
-static void bcm_tx_start_timer(struct bcm_op *op)
-{
-       if (op->kt_ival1.tv64 && op->count)
-               hrtimer_start(&op->timer,
-                             ktime_add(ktime_get(), op->kt_ival1),
-                             HRTIMER_MODE_ABS);
-       else if (op->kt_ival2.tv64)
-               hrtimer_start(&op->timer,
-                             ktime_add(ktime_get(), op->kt_ival2),
-                             HRTIMER_MODE_ABS);
-}
-
 static void bcm_tx_timeout_tsklet(unsigned long data)
 {
        struct bcm_op *op = (struct bcm_op *)data;
@@ -376,12 +364,26 @@ static void bcm_tx_timeout_tsklet(unsigned long data)
 
                        bcm_send_to_user(op, &msg_head, NULL, 0);
                }
-               bcm_can_tx(op);
+       }
+
+       if (op->kt_ival1.tv64 && (op->count > 0)) {
 
-       } else if (op->kt_ival2.tv64)
+               /* send (next) frame */
                bcm_can_tx(op);
+               hrtimer_start(&op->timer,
+                             ktime_add(ktime_get(), op->kt_ival1),
+                             HRTIMER_MODE_ABS);
 
-       bcm_tx_start_timer(op);
+       } else {
+               if (op->kt_ival2.tv64) {
+
+                       /* send (next) frame */
+                       bcm_can_tx(op);
+                       hrtimer_start(&op->timer,
+                                     ktime_add(ktime_get(), op->kt_ival2),
+                                     HRTIMER_MODE_ABS);
+               }
+       }
 }
 
 /*
@@ -961,20 +963,23 @@ static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
                        hrtimer_cancel(&op->timer);
        }
 
-       if (op->flags & STARTTIMER) {
-               hrtimer_cancel(&op->timer);
+       if ((op->flags & STARTTIMER) &&
+           ((op->kt_ival1.tv64 && op->count) || op->kt_ival2.tv64)) {
+
                /* spec: send can_frame when starting timer */
                op->flags |= TX_ANNOUNCE;
-       }
 
-       if (op->flags & TX_ANNOUNCE) {
-               bcm_can_tx(op);
-               if (op->count)
-                       op->count--;
+               if (op->kt_ival1.tv64 && (op->count > 0)) {
+                       /* op->count-- is done in bcm_tx_timeout_handler */
+                       hrtimer_start(&op->timer, op->kt_ival1,
+                                     HRTIMER_MODE_REL);
+               } else
+                       hrtimer_start(&op->timer, op->kt_ival2,
+                                     HRTIMER_MODE_REL);
        }
 
-       if (op->flags & STARTTIMER)
-               bcm_tx_start_timer(op);
+       if (op->flags & TX_ANNOUNCE)
+               bcm_can_tx(op);
 
        return msg_head->nframes * CFSIZ + MHSIZ;
 }
@@ -1085,9 +1090,6 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
                op->sk = sk;
                op->ifindex = ifindex;
 
-               /* ifindex for timeout events w/o previous frame reception */
-               op->rx_ifindex = ifindex;
-
                /* initialize uninitialized (kzalloc) structure */
                hrtimer_init(&op->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
                op->timer.function = bcm_rx_timeout_handler;