~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/net/irda/timer.c

Version: ~ [ 2.4.0 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*********************************************************************
  2  *                
  3  * Filename:      timer.c
  4  * Version:       
  5  * Description:   
  6  * Status:        Experimental.
  7  * Author:        Dag Brattli <dagb@cs.uit.no>
  8  * Created at:    Sat Aug 16 00:59:29 1997
  9  * Modified at:   Wed Dec  8 12:50:34 1999
 10  * Modified by:   Dag Brattli <dagb@cs.uit.no>
 11  * 
 12  *     Copyright (c) 1997, 1999 Dag Brattli <dagb@cs.uit.no>, 
 13  *     All Rights Reserved.
 14  *     
 15  *     This program is free software; you can redistribute it and/or 
 16  *     modify it under the terms of the GNU General Public License as 
 17  *     published by the Free Software Foundation; either version 2 of 
 18  *     the License, or (at your option) any later version.
 19  *
 20  *     Neither Dag Brattli nor University of Tromsų admit liability nor
 21  *     provide warranty for any of this software. This material is 
 22  *     provided "AS-IS" and at no charge.
 23  *
 24  ********************************************************************/
 25 
 26 #include <asm/system.h>
 27 #include <linux/config.h>
 28 #include <linux/delay.h>
 29 
 30 #include <net/irda/timer.h>
 31 #include <net/irda/irda.h>
 32 #include <net/irda/irtty.h>
 33 #include <net/irda/irlap.h>
 34 #include <net/irda/irlmp_event.h>
 35 
 36 static void irlap_slot_timer_expired(void* data);
 37 static void irlap_query_timer_expired(void* data);
 38 static void irlap_final_timer_expired(void* data);
 39 static void irlap_wd_timer_expired(void* data);
 40 static void irlap_backoff_timer_expired(void* data);
 41 
 42 static void irlap_media_busy_expired(void* data); 
 43 /*
 44  * Function irda_start_timer (timer, timeout)
 45  *
 46  *    Start an IrDA timer
 47  *
 48  */
 49 void irda_start_timer(struct timer_list *ptimer, int timeout, void *data,
 50                       TIMER_CALLBACK callback) 
 51 {
 52         del_timer(ptimer);
 53  
 54         ptimer->data = (unsigned long) data;
 55 
 56         /* 
 57          * For most architectures void * is the same as unsigned long, but
 58          * at least we try to use void * as long as possible. Since the 
 59          * timer functions use unsigned long, we cast the function here
 60          */
 61         ptimer->function = (void (*)(unsigned long)) callback;
 62         ptimer->expires = jiffies + timeout;
 63         
 64         add_timer(ptimer);
 65 }
 66 
 67 void irlap_start_slot_timer(struct irlap_cb *self, int timeout)
 68 {
 69         irda_start_timer(&self->slot_timer, timeout, (void *) self, 
 70                          irlap_slot_timer_expired);
 71 }
 72 
 73 void irlap_start_query_timer(struct irlap_cb *self, int timeout)
 74 {
 75         irda_start_timer( &self->query_timer, timeout, (void *) self, 
 76                           irlap_query_timer_expired);
 77 }
 78 
 79 void irlap_start_final_timer(struct irlap_cb *self, int timeout)
 80 {
 81         irda_start_timer(&self->final_timer, timeout, (void *) self, 
 82                          irlap_final_timer_expired);
 83 }
 84 
 85 void irlap_start_wd_timer(struct irlap_cb *self, int timeout)
 86 {
 87         irda_start_timer(&self->wd_timer, timeout, (void *) self, 
 88                          irlap_wd_timer_expired);
 89 }
 90 
 91 void irlap_start_backoff_timer(struct irlap_cb *self, int timeout)
 92 {
 93         irda_start_timer(&self->backoff_timer, timeout, (void *) self, 
 94                          irlap_backoff_timer_expired);
 95 }
 96 
 97 void irlap_start_mbusy_timer(struct irlap_cb *self)
 98 {
 99         irda_start_timer(&self->media_busy_timer, MEDIABUSY_TIMEOUT, 
100                          (void *) self, irlap_media_busy_expired);
101 }
102 
103 void irlap_stop_mbusy_timer(struct irlap_cb *self)
104 {
105         /* If timer is activated, kill it! */
106         if(timer_pending(&self->media_busy_timer))
107                 del_timer(&self->media_busy_timer);
108 
109 #ifdef CONFIG_IRDA_ULTRA
110         /* Send any pending Ultra frames if any */
111         if (!skb_queue_empty(&self->txq_ultra))
112                 /* Note : we don't send the frame, just post an event.
113                  * Frames will be sent only if we are in NDM mode (see
114                  * irlap_event.c).
115                  * Also, moved this code from irlap_media_busy_expired()
116                  * to here to catch properly all cases...
117                  * Jean II */
118                 irlap_do_event(self, SEND_UI_FRAME, NULL, NULL);
119 #endif /* CONFIG_IRDA_ULTRA */
120 }
121 
122 void irlmp_start_watchdog_timer(struct lsap_cb *self, int timeout) 
123 {
124         irda_start_timer(&self->watchdog_timer, timeout, (void *) self,
125                          irlmp_watchdog_timer_expired);
126 }
127 
128 void irlmp_start_discovery_timer(struct irlmp_cb *self, int timeout) 
129 {
130         irda_start_timer(&self->discovery_timer, timeout, (void *) self,
131                          irlmp_discovery_timer_expired);
132 }
133 
134 void irlmp_start_idle_timer(struct lap_cb *self, int timeout) 
135 {
136         irda_start_timer(&self->idle_timer, timeout, (void *) self,
137                          irlmp_idle_timer_expired);
138 }
139 
140 void irlmp_stop_idle_timer(struct lap_cb *self) 
141 {
142         /* If timer is activated, kill it! */
143         if(timer_pending(&self->idle_timer))
144                 del_timer(&self->idle_timer);
145 }
146 
147 /*
148  * Function irlap_slot_timer_expired (data)
149  *
150  *    IrLAP slot timer has expired
151  *
152  */
153 static void irlap_slot_timer_expired(void *data)
154 {
155         struct irlap_cb *self = (struct irlap_cb *) data;
156 
157         ASSERT(self != NULL, return;);
158         ASSERT(self->magic == LAP_MAGIC, return;);
159 
160         irlap_do_event(self, SLOT_TIMER_EXPIRED, NULL, NULL);
161 } 
162 
163 /*
164  * Function irlap_query_timer_expired (data)
165  *
166  *    IrLAP query timer has expired
167  *
168  */
169 static void irlap_query_timer_expired(void *data)
170 {
171         struct irlap_cb *self = (struct irlap_cb *) data;
172 
173         ASSERT(self != NULL, return;);
174         ASSERT(self->magic == LAP_MAGIC, return;);
175 
176         irlap_do_event(self, QUERY_TIMER_EXPIRED, NULL, NULL);
177 } 
178 
179 /*
180  * Function irda_final_timer_expired (data)
181  *
182  *    
183  *
184  */
185 static void irlap_final_timer_expired(void *data)
186 {
187         struct irlap_cb *self = (struct irlap_cb *) data;
188 
189         ASSERT(self != NULL, return;);
190         ASSERT(self->magic == LAP_MAGIC, return;);
191 
192         irlap_do_event(self, FINAL_TIMER_EXPIRED, NULL, NULL);
193 }
194 
195 /*
196  * Function irda_wd_timer_expired (data)
197  *
198  *    
199  *
200  */
201 static void irlap_wd_timer_expired(void *data)
202 {
203         struct irlap_cb *self = (struct irlap_cb *) data;
204         
205         ASSERT(self != NULL, return;);
206         ASSERT(self->magic == LAP_MAGIC, return;);
207         
208         irlap_do_event(self, WD_TIMER_EXPIRED, NULL, NULL);
209 }
210 
211 /*
212  * Function irda_backoff_timer_expired (data)
213  *
214  *    
215  *
216  */
217 static void irlap_backoff_timer_expired(void *data)
218 {
219         struct irlap_cb *self = (struct irlap_cb *) data;
220         
221         ASSERT(self != NULL, return;);
222         ASSERT(self->magic == LAP_MAGIC, return;);
223         
224         irlap_do_event(self, BACKOFF_TIMER_EXPIRED, NULL, NULL);
225 }
226 
227 
228 /*
229  * Function irtty_media_busy_expired (data)
230  *
231  *    
232  */
233 void irlap_media_busy_expired(void* data)
234 {
235         struct irlap_cb *self = (struct irlap_cb *) data;
236 
237         ASSERT(self != NULL, return;);
238 
239         irda_device_set_media_busy(self->netdev, FALSE);
240         /* Note : will deal with Ultra frames */
241 }
242 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.