ARM: 6246/1: mmci: support larger MMCIDATALENGTH register
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / scsi / bfa / bfa_timer.c
blobcb76481f5cb1a25c93c359d482e53225049eb812
1 /*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
3 * All rights reserved
4 * www.brocade.com
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>
21 void
22 bfa_timer_init(struct bfa_timer_mod_s *mod)
24 INIT_LIST_HEAD(&mod->timer_q);
27 void
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);
37 qe = bfa_q_next(qh);
39 while (qe != qh) {
40 qe_next = bfa_q_next(qe);
42 elem = (struct bfa_timer_s *) qe;
43 if (elem->timeout <= BFA_TIMER_FREQ) {
44 elem->timeout = 0;
45 list_del(&elem->qe);
46 list_add_tail(&elem->qe, &timedout_q);
47 } else {
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);
63 /**
64 * Should be called with lock protection
66 void
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;
76 timer->arg = arg;
78 list_add_tail(&timer->qe, &mod->timer_q);
81 /**
82 * Should be called with lock protection
84 void
85 bfa_timer_stop(struct bfa_timer_s *timer)
87 bfa_assert(!list_empty(&timer->qe));
89 list_del(&timer->qe);