patch-2.2.15 linux/net/irda/timer.c

Next file: linux/net/irda/wrapper.c
Previous file: linux/net/irda/qos.c
Back to the patch index
Back to the overall index

diff -u --new-file --recursive --exclude-from ../../exclude v2.2.14/net/irda/timer.c linux/net/irda/timer.c
@@ -6,10 +6,11 @@
  * Status:        Experimental.
  * Author:        Dag Brattli <dagb@cs.uit.no>
  * Created at:    Sat Aug 16 00:59:29 1997
- * Modified at:   Thu Feb  4 10:49:38 1999
+ * Modified at:   Wed Dec  8 12:50:34 1999
  * Modified by:   Dag Brattli <dagb@cs.uit.no>
  * 
- *     Copyright (c) 1997 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved.
+ *     Copyright (c) 1997, 1999 Dag Brattli <dagb@cs.uit.no>, 
+ *     All Rights Reserved.
  *     
  *     This program is free software; you can redistribute it and/or 
  *     modify it under the terms of the GNU General Public License as 
@@ -31,84 +32,88 @@
 #include <net/irda/irlap.h>
 #include <net/irda/irlmp_event.h>
 
-static void irlap_slot_timer_expired( unsigned long data);
-static void irlap_query_timer_expired( unsigned long data);
-static void irlap_final_timer_expired( unsigned long data);
-static void irlap_wd_timer_expired( unsigned long data);
-static void irlap_backoff_timer_expired( unsigned long data);
+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);
 
-static void irda_device_media_busy_expired( unsigned long data); 
+static void irlap_media_busy_expired(void* data); 
 /*
  * Function irda_start_timer (timer, timeout)
  *
  *    Start an IrDA timer
  *
  */
-void irda_start_timer( struct timer_list *ptimer, int timeout, int data,
-		       TIMER_CALLBACK callback) 
+void irda_start_timer(struct timer_list *ptimer, int timeout, void *data,
+		      TIMER_CALLBACK callback) 
 {
-	del_timer( ptimer);
+	del_timer(ptimer);
  
 	ptimer->data = (unsigned long) data;
-	ptimer->function = callback;
+
+	/* 
+	 * For most architectures void * is the same as unsigned long, but
+	 * at least we try to use void * as long as possible. Since the 
+	 * timer functions use unsigned long, we cast the function here
+	 */
+	ptimer->function = (void (*)(unsigned long)) callback;
 	ptimer->expires = jiffies + timeout;
 	
-	add_timer( ptimer);
+	add_timer(ptimer);
 }
 
-inline void irlap_start_slot_timer( struct irlap_cb *self, int timeout)
+void irlap_start_slot_timer(struct irlap_cb *self, int timeout)
 {
-	irda_start_timer( &self->slot_timer, timeout, (unsigned long) self, 
-			  irlap_slot_timer_expired);
+	irda_start_timer(&self->slot_timer, timeout, (void *) self, 
+			 irlap_slot_timer_expired);
 }
 
-inline void irlap_start_query_timer( struct irlap_cb *self, int timeout)
+void irlap_start_query_timer(struct irlap_cb *self, int timeout)
 {
-	irda_start_timer( &self->query_timer, timeout, (unsigned long) self, 
+	irda_start_timer( &self->query_timer, timeout, (void *) self, 
 			  irlap_query_timer_expired);
 }
 
-inline void irlap_start_final_timer( struct irlap_cb *self, int timeout)
+void irlap_start_final_timer(struct irlap_cb *self, int timeout)
 {
-	irda_start_timer( &self->final_timer, timeout,  (unsigned long) self, 
-			  irlap_final_timer_expired);
+	irda_start_timer(&self->final_timer, timeout, (void *) self, 
+			 irlap_final_timer_expired);
 }
 
-inline void irlap_start_wd_timer( struct irlap_cb *self, int timeout)
+void irlap_start_wd_timer(struct irlap_cb *self, int timeout)
 {
-	irda_start_timer( &self->wd_timer, timeout, (unsigned long) self, 
-			  irlap_wd_timer_expired);
+	irda_start_timer(&self->wd_timer, timeout, (void *) self, 
+			 irlap_wd_timer_expired);
 }
 
-inline void irlap_start_backoff_timer( struct irlap_cb *self, int timeout)
+void irlap_start_backoff_timer(struct irlap_cb *self, int timeout)
 {
-	irda_start_timer( &self->backoff_timer, timeout, (unsigned long) self, 
-			  irlap_backoff_timer_expired);
+	irda_start_timer(&self->backoff_timer, timeout, (void *) self, 
+			 irlap_backoff_timer_expired);
 }
 
-inline void irda_device_start_mbusy_timer( struct irda_device *self) 
+void irlap_start_mbusy_timer(struct irlap_cb *self)
 {
-	irda_start_timer( &self->media_busy_timer, MEDIABUSY_TIMEOUT, 
-			  (unsigned long) self, 
-			  irda_device_media_busy_expired);
-	
+	irda_start_timer(&self->media_busy_timer, MEDIABUSY_TIMEOUT, 
+			 (void *) self, irlap_media_busy_expired);
 }
 
-inline void irlmp_start_watchdog_timer( struct lsap_cb *self, int timeout) 
+void irlmp_start_watchdog_timer(struct lsap_cb *self, int timeout) 
 {
-	irda_start_timer( &self->watchdog_timer, timeout, (unsigned long) self,
-			  irlmp_watchdog_timer_expired);
+	irda_start_timer(&self->watchdog_timer, timeout, (void *) self,
+			 irlmp_watchdog_timer_expired);
 }
 
-inline void irlmp_start_discovery_timer(struct irlmp_cb *self, int timeout) 
+void irlmp_start_discovery_timer(struct irlmp_cb *self, int timeout) 
 {
-	irda_start_timer(&self->discovery_timer, timeout, (unsigned long) self,
+	irda_start_timer(&self->discovery_timer, timeout, (void *) self,
 			 irlmp_discovery_timer_expired);
 }
 
-inline void irlmp_start_idle_timer(struct lap_cb *self, int timeout) 
+void irlmp_start_idle_timer(struct lap_cb *self, int timeout) 
 {
-	irda_start_timer(&self->idle_timer, timeout, (unsigned long) self,
+	irda_start_timer(&self->idle_timer, timeout, (void *) self,
 			 irlmp_idle_timer_expired);
 }
 
@@ -118,16 +123,14 @@
  *    IrLAP slot timer has expired
  *
  */
-static void irlap_slot_timer_expired( unsigned long data)
+static void irlap_slot_timer_expired(void *data)
 {
 	struct irlap_cb *self = (struct irlap_cb *) data;
 
-	DEBUG( 4, "Slot timer expired!\n");
-
-	ASSERT( self != NULL, return;);
-	ASSERT( self->magic == LAP_MAGIC, return;);
+	ASSERT(self != NULL, return;);
+	ASSERT(self->magic == LAP_MAGIC, return;);
 
-	irlap_do_event( self, SLOT_TIMER_EXPIRED, NULL, NULL);
+	irlap_do_event(self, SLOT_TIMER_EXPIRED, NULL, NULL);
 } 
 
 /*
@@ -136,16 +139,14 @@
  *    IrLAP query timer has expired
  *
  */
-static void irlap_query_timer_expired( unsigned long data)
+static void irlap_query_timer_expired(void *data)
 {
 	struct irlap_cb *self = (struct irlap_cb *) data;
 
-	DEBUG( 4, "Query timer expired!\n");
+	ASSERT(self != NULL, return;);
+	ASSERT(self->magic == LAP_MAGIC, return;);
 
-	ASSERT( self != NULL, return;);
-	ASSERT( self->magic == LAP_MAGIC, return;);
-
-	irlap_do_event( self, QUERY_TIMER_EXPIRED, NULL, NULL);
+	irlap_do_event(self, QUERY_TIMER_EXPIRED, NULL, NULL);
 } 
 
 /*
@@ -154,16 +155,14 @@
  *    
  *
  */
-static void irlap_final_timer_expired( unsigned long data)
+static void irlap_final_timer_expired(void *data)
 {
 	struct irlap_cb *self = (struct irlap_cb *) data;
 
-	DEBUG( 4, "Final timer expired!\n");
-
-	ASSERT( self != NULL, return;);
-	ASSERT( self->magic == LAP_MAGIC, return;);
+	ASSERT(self != NULL, return;);
+	ASSERT(self->magic == LAP_MAGIC, return;);
 
-	irlap_do_event( self, FINAL_TIMER_EXPIRED, NULL, NULL);
+	irlap_do_event(self, FINAL_TIMER_EXPIRED, NULL, NULL);
 }
 
 /*
@@ -172,16 +171,14 @@
  *    
  *
  */
-static void irlap_wd_timer_expired( unsigned long data)
+static void irlap_wd_timer_expired(void *data)
 {
 	struct irlap_cb *self = (struct irlap_cb *) data;
 	
-	DEBUG( 4, "WD timer expired!\n");
+	ASSERT(self != NULL, return;);
+	ASSERT(self->magic == LAP_MAGIC, return;);
 	
-	ASSERT( self != NULL, return;);
-	ASSERT( self->magic == LAP_MAGIC, return;);
-	
-	irlap_do_event( self, WD_TIMER_EXPIRED, NULL, NULL);
+	irlap_do_event(self, WD_TIMER_EXPIRED, NULL, NULL);
 }
 
 /*
@@ -190,16 +187,14 @@
  *    
  *
  */
-static void irlap_backoff_timer_expired( unsigned long data)
+static void irlap_backoff_timer_expired(void *data)
 {
 	struct irlap_cb *self = (struct irlap_cb *) data;
 	
-	DEBUG( 0, "Backoff timer expired!\n");
-	
-	ASSERT( self != NULL, return;);
-	ASSERT( self->magic == LAP_MAGIC, return;);
+	ASSERT(self != NULL, return;);
+	ASSERT(self->magic == LAP_MAGIC, return;);
 	
-	irlap_do_event( self, BACKOFF_TIMER_EXPIRED, NULL, NULL);
+	irlap_do_event(self, BACKOFF_TIMER_EXPIRED, NULL, NULL);
 }
 
 
@@ -208,14 +203,15 @@
  *
  *    
  */
-void irda_device_media_busy_expired( unsigned long data) 
+void irlap_media_busy_expired(void* data)
 {
-	struct irda_device *self = ( struct irda_device *) data;
+	struct irlap_cb *self = (struct irlap_cb *) data;
 
-	DEBUG( 4, "Mediabusy timer expired!\n");
-	
-	ASSERT( self != NULL, return;);
-	ASSERT( self->magic == IRDA_DEVICE_MAGIC, return;);
+	ASSERT(self != NULL, return;);
+
+	irda_device_set_media_busy(self->netdev, FALSE);
 
-	irda_device_set_media_busy( self, FALSE);
+	/* Send any pending Ultra frames if any */
+	if (!skb_queue_empty(&self->txq_ultra))
+		irlap_do_event(self, SEND_UI_FRAME, NULL, NULL);
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)