2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License (GPL) Version 2 as
10 * published by the Free Software Foundation
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
18 #include <bfa_timer.h>
19 #include <cs/bfa_debug.h>
22 bfa_timer_init(struct bfa_timer_mod_s
*mod
)
24 INIT_LIST_HEAD(&mod
->timer_q
);
28 bfa_timer_beat(struct bfa_timer_mod_s
*mod
)
30 struct list_head
*qh
= &mod
->timer_q
;
31 struct list_head
*qe
, *qe_next
;
32 struct bfa_timer_s
*elem
;
33 struct list_head timedout_q
;
35 INIT_LIST_HEAD(&timedout_q
);
40 qe_next
= bfa_q_next(qe
);
42 elem
= (struct bfa_timer_s
*) qe
;
43 if (elem
->timeout
<= BFA_TIMER_FREQ
) {
46 list_add_tail(&elem
->qe
, &timedout_q
);
48 elem
->timeout
-= BFA_TIMER_FREQ
;
51 qe
= qe_next
; /* go to next elem */
55 * Pop all the timeout entries
57 while (!list_empty(&timedout_q
)) {
58 bfa_q_deq(&timedout_q
, &elem
);
59 elem
->timercb(elem
->arg
);
64 * Should be called with lock protection
67 bfa_timer_begin(struct bfa_timer_mod_s
*mod
, struct bfa_timer_s
*timer
,
68 void (*timercb
) (void *), void *arg
, unsigned int timeout
)
71 bfa_assert(timercb
!= NULL
);
72 bfa_assert(!bfa_q_is_on_q(&mod
->timer_q
, timer
));
74 timer
->timeout
= timeout
;
75 timer
->timercb
= timercb
;
78 list_add_tail(&timer
->qe
, &mod
->timer_q
);
82 * Should be called with lock protection
85 bfa_timer_stop(struct bfa_timer_s
*timer
)
87 bfa_assert(!list_empty(&timer
->qe
));
This page took 0.032642 seconds and 6 git commands to generate.