fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / net / irda / timer.c
index f05b942..3871a2b 100644 (file)
@@ -25,7 +25,6 @@
  ********************************************************************/
 
 #include <asm/system.h>
-#include <linux/config.h>
 #include <linux/delay.h>
 
 #include <net/irda/timer.h>
@@ -34,6 +33,8 @@
 #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);
@@ -47,8 +48,25 @@ void irlap_start_slot_timer(struct irlap_cb *self, int timeout)
                         irlap_slot_timer_expired);
 }
 
-void irlap_start_query_timer(struct irlap_cb *self, int timeout)
+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),
+        * to avoid messing with for incomming connections requests and
+        * to accomodate devices that perform discovery slower than us.
+        * Jean II */
+       timeout = ((sysctl_slot_timeout * HZ / 1000) * (S - s)
+                  + XIDEXTRA_TIMEOUT + SMALLBUSY_TIMEOUT);
+
+       /* 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 */
        irda_start_timer( &self->query_timer, timeout, (void *) self, 
                          irlap_query_timer_expired);
 }
@@ -125,8 +143,8 @@ static void irlap_slot_timer_expired(void *data)
 {
        struct irlap_cb *self = (struct irlap_cb *) data;
 
-       ASSERT(self != NULL, return;);
-       ASSERT(self->magic == LAP_MAGIC, return;);
+       IRDA_ASSERT(self != NULL, return;);
+       IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
 
        irlap_do_event(self, SLOT_TIMER_EXPIRED, NULL, NULL);
 } 
@@ -141,8 +159,8 @@ static void irlap_query_timer_expired(void *data)
 {
        struct irlap_cb *self = (struct irlap_cb *) data;
 
-       ASSERT(self != NULL, return;);
-       ASSERT(self->magic == LAP_MAGIC, return;);
+       IRDA_ASSERT(self != NULL, return;);
+       IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
 
        irlap_do_event(self, QUERY_TIMER_EXPIRED, NULL, NULL);
 } 
@@ -157,8 +175,8 @@ static void irlap_final_timer_expired(void *data)
 {
        struct irlap_cb *self = (struct irlap_cb *) data;
 
-       ASSERT(self != NULL, return;);
-       ASSERT(self->magic == LAP_MAGIC, return;);
+       IRDA_ASSERT(self != NULL, return;);
+       IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
 
        irlap_do_event(self, FINAL_TIMER_EXPIRED, NULL, NULL);
 }
@@ -173,8 +191,8 @@ static void irlap_wd_timer_expired(void *data)
 {
        struct irlap_cb *self = (struct irlap_cb *) data;
        
-       ASSERT(self != NULL, return;);
-       ASSERT(self->magic == LAP_MAGIC, return;);
+       IRDA_ASSERT(self != NULL, return;);
+       IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
        
        irlap_do_event(self, WD_TIMER_EXPIRED, NULL, NULL);
 }
@@ -189,8 +207,8 @@ static void irlap_backoff_timer_expired(void *data)
 {
        struct irlap_cb *self = (struct irlap_cb *) data;
        
-       ASSERT(self != NULL, return;);
-       ASSERT(self->magic == LAP_MAGIC, return;);
+       IRDA_ASSERT(self != NULL, return;);
+       IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
        
        irlap_do_event(self, BACKOFF_TIMER_EXPIRED, NULL, NULL);
 }
@@ -205,7 +223,7 @@ void irlap_media_busy_expired(void* data)
 {
        struct irlap_cb *self = (struct irlap_cb *) data;
 
-       ASSERT(self != NULL, return;);
+       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(),