aboutsummaryrefslogtreecommitdiffstats
path: root/net/can/bcm.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/can/bcm.c')
-rw-r--r--net/can/bcm.c54
1 files changed, 25 insertions, 29 deletions
diff --git a/net/can/bcm.c b/net/can/bcm.c
index 184a6572b67e..c84963d2dee6 100644
--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -43,6 +43,7 @@
43 43
44#include <linux/module.h> 44#include <linux/module.h>
45#include <linux/init.h> 45#include <linux/init.h>
46#include <linux/interrupt.h>
46#include <linux/hrtimer.h> 47#include <linux/hrtimer.h>
47#include <linux/list.h> 48#include <linux/list.h>
48#include <linux/proc_fs.h> 49#include <linux/proc_fs.h>
@@ -343,6 +344,18 @@ static void bcm_send_to_user(struct bcm_op *op, struct bcm_msg_head *head,
343 } 344 }
344} 345}
345 346
347static void bcm_tx_start_timer(struct bcm_op *op)
348{
349 if (op->kt_ival1.tv64 && op->count)
350 hrtimer_start(&op->timer,
351 ktime_add(ktime_get(), op->kt_ival1),
352 HRTIMER_MODE_ABS);
353 else if (op->kt_ival2.tv64)
354 hrtimer_start(&op->timer,
355 ktime_add(ktime_get(), op->kt_ival2),
356 HRTIMER_MODE_ABS);
357}
358
346static void bcm_tx_timeout_tsklet(unsigned long data) 359static void bcm_tx_timeout_tsklet(unsigned long data)
347{ 360{
348 struct bcm_op *op = (struct bcm_op *)data; 361 struct bcm_op *op = (struct bcm_op *)data;
@@ -364,26 +377,12 @@ static void bcm_tx_timeout_tsklet(unsigned long data)
364 377
365 bcm_send_to_user(op, &msg_head, NULL, 0); 378 bcm_send_to_user(op, &msg_head, NULL, 0);
366 } 379 }
367 }
368
369 if (op->kt_ival1.tv64 && (op->count > 0)) {
370
371 /* send (next) frame */
372 bcm_can_tx(op); 380 bcm_can_tx(op);
373 hrtimer_start(&op->timer,
374 ktime_add(ktime_get(), op->kt_ival1),
375 HRTIMER_MODE_ABS);
376 381
377 } else { 382 } else if (op->kt_ival2.tv64)
378 if (op->kt_ival2.tv64) { 383 bcm_can_tx(op);
379 384
380 /* send (next) frame */ 385 bcm_tx_start_timer(op);
381 bcm_can_tx(op);
382 hrtimer_start(&op->timer,
383 ktime_add(ktime_get(), op->kt_ival2),
384 HRTIMER_MODE_ABS);
385 }
386 }
387} 386}
388 387
389/* 388/*
@@ -963,23 +962,20 @@ static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
963 hrtimer_cancel(&op->timer); 962 hrtimer_cancel(&op->timer);
964 } 963 }
965 964
966 if ((op->flags & STARTTIMER) && 965 if (op->flags & STARTTIMER) {
967 ((op->kt_ival1.tv64 && op->count) || op->kt_ival2.tv64)) { 966 hrtimer_cancel(&op->timer);
968
969 /* spec: send can_frame when starting timer */ 967 /* spec: send can_frame when starting timer */
970 op->flags |= TX_ANNOUNCE; 968 op->flags |= TX_ANNOUNCE;
971
972 if (op->kt_ival1.tv64 && (op->count > 0)) {
973 /* op->count-- is done in bcm_tx_timeout_handler */
974 hrtimer_start(&op->timer, op->kt_ival1,
975 HRTIMER_MODE_REL);
976 } else
977 hrtimer_start(&op->timer, op->kt_ival2,
978 HRTIMER_MODE_REL);
979 } 969 }
980 970
981 if (op->flags & TX_ANNOUNCE) 971 if (op->flags & TX_ANNOUNCE) {
982 bcm_can_tx(op); 972 bcm_can_tx(op);
973 if (op->count)
974 op->count--;
975 }
976
977 if (op->flags & STARTTIMER)
978 bcm_tx_start_timer(op);
983 979
984 return msg_head->nframes * CFSIZ + MHSIZ; 980 return msg_head->nframes * CFSIZ + MHSIZ;
985} 981}