Blame view
net/irda/timer.c
6.29 KB
1da177e4c Linux-2.6.12-rc2 |
1 |
/********************************************************************* |
6819bc2e1 [NET] IRDA: Fix w... |
2 |
* |
1da177e4c Linux-2.6.12-rc2 |
3 |
* Filename: timer.c |
6819bc2e1 [NET] IRDA: Fix w... |
4 5 |
* Version: * Description: |
1da177e4c Linux-2.6.12-rc2 |
6 7 8 9 10 |
* Status: Experimental. * Author: Dag Brattli <dagb@cs.uit.no> * Created at: Sat Aug 16 00:59:29 1997 * Modified at: Wed Dec 8 12:50:34 1999 * Modified by: Dag Brattli <dagb@cs.uit.no> |
6819bc2e1 [NET] IRDA: Fix w... |
11 12 |
* * Copyright (c) 1997, 1999 Dag Brattli <dagb@cs.uit.no>, |
1da177e4c Linux-2.6.12-rc2 |
13 14 |
* All Rights Reserved. * Copyright (c) 2000-2002 Jean Tourrilhes <jt@hpl.hp.com> |
6819bc2e1 [NET] IRDA: Fix w... |
15 16 17 18 |
* * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of |
1da177e4c Linux-2.6.12-rc2 |
19 20 |
* the License, or (at your option) any later version. * |
db955170d more UTF-8 conver... |
21 |
* Neither Dag Brattli nor University of Tromsø admit liability nor |
6819bc2e1 [NET] IRDA: Fix w... |
22 |
* provide warranty for any of this software. This material is |
1da177e4c Linux-2.6.12-rc2 |
23 24 25 |
* provided "AS-IS" and at no charge. * ********************************************************************/ |
1da177e4c Linux-2.6.12-rc2 |
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
#include <linux/delay.h> #include <net/irda/timer.h> #include <net/irda/irda.h> #include <net/irda/irda_device.h> #include <net/irda/irlap.h> #include <net/irda/irlmp.h> extern int sysctl_slot_timeout; static void irlap_slot_timer_expired(void* data); static void irlap_query_timer_expired(void* data); static void irlap_final_timer_expired(void* data); static void irlap_wd_timer_expired(void* data); static void irlap_backoff_timer_expired(void* data); |
6819bc2e1 [NET] IRDA: Fix w... |
41 |
static void irlap_media_busy_expired(void* data); |
1da177e4c Linux-2.6.12-rc2 |
42 43 44 |
void irlap_start_slot_timer(struct irlap_cb *self, int timeout) { |
6819bc2e1 [NET] IRDA: Fix w... |
45 |
irda_start_timer(&self->slot_timer, timeout, (void *) self, |
1da177e4c Linux-2.6.12-rc2 |
46 47 48 49 50 51 52 53 54 55 56 57 58 |
irlap_slot_timer_expired); } void irlap_start_query_timer(struct irlap_cb *self, int S, int s) { int timeout; /* Calculate when the peer discovery should end. Normally, we * get the end-of-discovery frame, so this is just in case * we miss it. * Basically, we multiply the number of remaining slots by our * slot time, plus add some extra time to properly receive the last * discovery packet (which is longer due to extra discovery info), |
d82603c6d treewide: Replace... |
59 |
* to avoid messing with for incoming connections requests and |
25985edce Fix common misspe... |
60 |
* to accommodate devices that perform discovery slower than us. |
1da177e4c Linux-2.6.12-rc2 |
61 |
* Jean II */ |
005e8709c irda: use msecs_t... |
62 63 |
timeout = msecs_to_jiffies(sysctl_slot_timeout) * (S - s) + XIDEXTRA_TIMEOUT + SMALLBUSY_TIMEOUT; |
1da177e4c Linux-2.6.12-rc2 |
64 65 66 67 |
/* Set or re-set the timer. We reset the timer for each received * discovery query, which allow us to automatically adjust to * the speed of the peer discovery (faster or slower). Jean II */ |
6819bc2e1 [NET] IRDA: Fix w... |
68 |
irda_start_timer( &self->query_timer, timeout, (void *) self, |
1da177e4c Linux-2.6.12-rc2 |
69 70 71 72 73 |
irlap_query_timer_expired); } void irlap_start_final_timer(struct irlap_cb *self, int timeout) { |
6819bc2e1 [NET] IRDA: Fix w... |
74 |
irda_start_timer(&self->final_timer, timeout, (void *) self, |
1da177e4c Linux-2.6.12-rc2 |
75 76 77 78 79 |
irlap_final_timer_expired); } void irlap_start_wd_timer(struct irlap_cb *self, int timeout) { |
6819bc2e1 [NET] IRDA: Fix w... |
80 |
irda_start_timer(&self->wd_timer, timeout, (void *) self, |
1da177e4c Linux-2.6.12-rc2 |
81 82 83 84 85 |
irlap_wd_timer_expired); } void irlap_start_backoff_timer(struct irlap_cb *self, int timeout) { |
6819bc2e1 [NET] IRDA: Fix w... |
86 |
irda_start_timer(&self->backoff_timer, timeout, (void *) self, |
1da177e4c Linux-2.6.12-rc2 |
87 88 89 90 91 |
irlap_backoff_timer_expired); } void irlap_start_mbusy_timer(struct irlap_cb *self, int timeout) { |
6819bc2e1 [NET] IRDA: Fix w... |
92 |
irda_start_timer(&self->media_busy_timer, timeout, |
1da177e4c Linux-2.6.12-rc2 |
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
(void *) self, irlap_media_busy_expired); } void irlap_stop_mbusy_timer(struct irlap_cb *self) { /* If timer is activated, kill it! */ del_timer(&self->media_busy_timer); /* If we are in NDM, there is a bunch of events in LAP that * that be pending due to the media_busy condition, such as * CONNECT_REQUEST and SEND_UI_FRAME. If we don't generate * an event, they will wait forever... * Jean II */ if (self->state == LAP_NDM) irlap_do_event(self, MEDIA_BUSY_TIMER_EXPIRED, NULL, NULL); } |
6819bc2e1 [NET] IRDA: Fix w... |
109 |
void irlmp_start_watchdog_timer(struct lsap_cb *self, int timeout) |
1da177e4c Linux-2.6.12-rc2 |
110 111 112 113 |
{ irda_start_timer(&self->watchdog_timer, timeout, (void *) self, irlmp_watchdog_timer_expired); } |
6819bc2e1 [NET] IRDA: Fix w... |
114 |
void irlmp_start_discovery_timer(struct irlmp_cb *self, int timeout) |
1da177e4c Linux-2.6.12-rc2 |
115 116 117 118 |
{ irda_start_timer(&self->discovery_timer, timeout, (void *) self, irlmp_discovery_timer_expired); } |
6819bc2e1 [NET] IRDA: Fix w... |
119 |
void irlmp_start_idle_timer(struct lap_cb *self, int timeout) |
1da177e4c Linux-2.6.12-rc2 |
120 121 122 123 |
{ irda_start_timer(&self->idle_timer, timeout, (void *) self, irlmp_idle_timer_expired); } |
6819bc2e1 [NET] IRDA: Fix w... |
124 |
void irlmp_stop_idle_timer(struct lap_cb *self) |
1da177e4c Linux-2.6.12-rc2 |
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
{ /* If timer is activated, kill it! */ del_timer(&self->idle_timer); } /* * Function irlap_slot_timer_expired (data) * * IrLAP slot timer has expired * */ static void irlap_slot_timer_expired(void *data) { struct irlap_cb *self = (struct irlap_cb *) data; IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self->magic == LAP_MAGIC, return;); irlap_do_event(self, SLOT_TIMER_EXPIRED, NULL, NULL); |
6819bc2e1 [NET] IRDA: Fix w... |
144 |
} |
1da177e4c Linux-2.6.12-rc2 |
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
/* * Function irlap_query_timer_expired (data) * * IrLAP query timer has expired * */ static void irlap_query_timer_expired(void *data) { struct irlap_cb *self = (struct irlap_cb *) data; IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self->magic == LAP_MAGIC, return;); irlap_do_event(self, QUERY_TIMER_EXPIRED, NULL, NULL); |
6819bc2e1 [NET] IRDA: Fix w... |
160 |
} |
1da177e4c Linux-2.6.12-rc2 |
161 162 163 164 |
/* * Function irda_final_timer_expired (data) * |
6819bc2e1 [NET] IRDA: Fix w... |
165 |
* |
1da177e4c Linux-2.6.12-rc2 |
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
* */ static void irlap_final_timer_expired(void *data) { struct irlap_cb *self = (struct irlap_cb *) data; IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self->magic == LAP_MAGIC, return;); irlap_do_event(self, FINAL_TIMER_EXPIRED, NULL, NULL); } /* * Function irda_wd_timer_expired (data) * |
6819bc2e1 [NET] IRDA: Fix w... |
181 |
* |
1da177e4c Linux-2.6.12-rc2 |
182 183 184 185 186 |
* */ static void irlap_wd_timer_expired(void *data) { struct irlap_cb *self = (struct irlap_cb *) data; |
6819bc2e1 [NET] IRDA: Fix w... |
187 |
|
1da177e4c Linux-2.6.12-rc2 |
188 189 |
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self->magic == LAP_MAGIC, return;); |
6819bc2e1 [NET] IRDA: Fix w... |
190 |
|
1da177e4c Linux-2.6.12-rc2 |
191 192 193 194 195 196 |
irlap_do_event(self, WD_TIMER_EXPIRED, NULL, NULL); } /* * Function irda_backoff_timer_expired (data) * |
6819bc2e1 [NET] IRDA: Fix w... |
197 |
* |
1da177e4c Linux-2.6.12-rc2 |
198 199 200 201 202 |
* */ static void irlap_backoff_timer_expired(void *data) { struct irlap_cb *self = (struct irlap_cb *) data; |
6819bc2e1 [NET] IRDA: Fix w... |
203 |
|
1da177e4c Linux-2.6.12-rc2 |
204 205 |
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self->magic == LAP_MAGIC, return;); |
6819bc2e1 [NET] IRDA: Fix w... |
206 |
|
1da177e4c Linux-2.6.12-rc2 |
207 208 209 210 211 212 213 |
irlap_do_event(self, BACKOFF_TIMER_EXPIRED, NULL, NULL); } /* * Function irtty_media_busy_expired (data) * |
6819bc2e1 [NET] IRDA: Fix w... |
214 |
* |
1da177e4c Linux-2.6.12-rc2 |
215 |
*/ |
5eaa65b24 net: Make static |
216 |
static void irlap_media_busy_expired(void *data) |
1da177e4c Linux-2.6.12-rc2 |
217 218 219 220 221 222 223 224 225 226 |
{ struct irlap_cb *self = (struct irlap_cb *) data; IRDA_ASSERT(self != NULL, return;); irda_device_set_media_busy(self->netdev, FALSE); /* Note : the LAP event will be send in irlap_stop_mbusy_timer(), * to catch other cases where the flag is cleared (for example * after a discovery) - Jean II */ } |