1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27#include <asm/system.h>
28#include <linux/delay.h>
29
30#include <net/irda/timer.h>
31#include <net/irda/irda.h>
32#include <net/irda/irda_device.h>
33#include <net/irda/irlap.h>
34#include <net/irda/irlmp.h>
35
36extern int sysctl_slot_timeout;
37
38static void irlap_slot_timer_expired(void* data);
39static void irlap_query_timer_expired(void* data);
40static void irlap_final_timer_expired(void* data);
41static void irlap_wd_timer_expired(void* data);
42static void irlap_backoff_timer_expired(void* data);
43static void irlap_media_busy_expired(void* data);
44
45void irlap_start_slot_timer(struct irlap_cb *self, int timeout)
46{
47 irda_start_timer(&self->slot_timer, timeout, (void *) self,
48 irlap_slot_timer_expired);
49}
50
51void irlap_start_query_timer(struct irlap_cb *self, int S, int s)
52{
53 int timeout;
54
55
56
57
58
59
60
61
62
63
64 timeout = ((sysctl_slot_timeout * HZ / 1000) * (S - s)
65 + XIDEXTRA_TIMEOUT + SMALLBUSY_TIMEOUT);
66
67
68
69
70 irda_start_timer( &self->query_timer, timeout, (void *) self,
71 irlap_query_timer_expired);
72}
73
74void irlap_start_final_timer(struct irlap_cb *self, int timeout)
75{
76 irda_start_timer(&self->final_timer, timeout, (void *) self,
77 irlap_final_timer_expired);
78}
79
80void irlap_start_wd_timer(struct irlap_cb *self, int timeout)
81{
82 irda_start_timer(&self->wd_timer, timeout, (void *) self,
83 irlap_wd_timer_expired);
84}
85
86void irlap_start_backoff_timer(struct irlap_cb *self, int timeout)
87{
88 irda_start_timer(&self->backoff_timer, timeout, (void *) self,
89 irlap_backoff_timer_expired);
90}
91
92void irlap_start_mbusy_timer(struct irlap_cb *self, int timeout)
93{
94 irda_start_timer(&self->media_busy_timer, timeout,
95 (void *) self, irlap_media_busy_expired);
96}
97
98void irlap_stop_mbusy_timer(struct irlap_cb *self)
99{
100
101 del_timer(&self->media_busy_timer);
102
103
104
105
106
107
108 if (self->state == LAP_NDM)
109 irlap_do_event(self, MEDIA_BUSY_TIMER_EXPIRED, NULL, NULL);
110}
111
112void irlmp_start_watchdog_timer(struct lsap_cb *self, int timeout)
113{
114 irda_start_timer(&self->watchdog_timer, timeout, (void *) self,
115 irlmp_watchdog_timer_expired);
116}
117
118void irlmp_start_discovery_timer(struct irlmp_cb *self, int timeout)
119{
120 irda_start_timer(&self->discovery_timer, timeout, (void *) self,
121 irlmp_discovery_timer_expired);
122}
123
124void irlmp_start_idle_timer(struct lap_cb *self, int timeout)
125{
126 irda_start_timer(&self->idle_timer, timeout, (void *) self,
127 irlmp_idle_timer_expired);
128}
129
130void irlmp_stop_idle_timer(struct lap_cb *self)
131{
132
133 del_timer(&self->idle_timer);
134}
135
136
137
138
139
140
141
142static void irlap_slot_timer_expired(void *data)
143{
144 struct irlap_cb *self = (struct irlap_cb *) data;
145
146 IRDA_ASSERT(self != NULL, return;);
147 IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
148
149 irlap_do_event(self, SLOT_TIMER_EXPIRED, NULL, NULL);
150}
151
152
153
154
155
156
157
158static void irlap_query_timer_expired(void *data)
159{
160 struct irlap_cb *self = (struct irlap_cb *) data;
161
162 IRDA_ASSERT(self != NULL, return;);
163 IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
164
165 irlap_do_event(self, QUERY_TIMER_EXPIRED, NULL, NULL);
166}
167
168
169
170
171
172
173
174static void irlap_final_timer_expired(void *data)
175{
176 struct irlap_cb *self = (struct irlap_cb *) data;
177
178 IRDA_ASSERT(self != NULL, return;);
179 IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
180
181 irlap_do_event(self, FINAL_TIMER_EXPIRED, NULL, NULL);
182}
183
184
185
186
187
188
189
190static void irlap_wd_timer_expired(void *data)
191{
192 struct irlap_cb *self = (struct irlap_cb *) data;
193
194 IRDA_ASSERT(self != NULL, return;);
195 IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
196
197 irlap_do_event(self, WD_TIMER_EXPIRED, NULL, NULL);
198}
199
200
201
202
203
204
205
206static void irlap_backoff_timer_expired(void *data)
207{
208 struct irlap_cb *self = (struct irlap_cb *) data;
209
210 IRDA_ASSERT(self != NULL, return;);
211 IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
212
213 irlap_do_event(self, BACKOFF_TIMER_EXPIRED, NULL, NULL);
214}
215
216
217
218
219
220
221
222static void irlap_media_busy_expired(void *data)
223{
224 struct irlap_cb *self = (struct irlap_cb *) data;
225
226 IRDA_ASSERT(self != NULL, return;);
227
228 irda_device_set_media_busy(self->netdev, FALSE);
229
230
231
232}
233