X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=net%2Firda%2Ftimer.c;h=3871a2b911f93722e78791203eccb048d7b95a13;hb=refs%2Fheads%2Fvserver;hp=f05b94250ffa6112253657a56fc948c6aacd1182;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/net/irda/timer.c b/net/irda/timer.c index f05b94250..3871a2b91 100644 --- a/net/irda/timer.c +++ b/net/irda/timer.c @@ -25,7 +25,6 @@ ********************************************************************/ #include -#include #include #include @@ -34,6 +33,8 @@ #include #include +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(),